Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo draft #4

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/assets/stylesheets/uswds-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
@forward "usa-header";
@forward "usa-banner";
@forward "usa-section";
@forward "usa-alert";
@forward "usa-combo-box";
@forward "usa-accordion";
// add additional packages here as you use them
2 changes: 1 addition & 1 deletion app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class PagesController < ApplicationController
def home
def welcome
end
end
26 changes: 26 additions & 0 deletions app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class ProvidersController < ApplicationController
ENDPOINT = 'https://sampleapps.argyle.com/employer-search/api/search?q=';

def index
end

def search
# sample endpoint — let's replace with a real sandbox
# https://sampleapps.argyle.com/employer-search/api/search?q=nava
# results = Net::HTTP.get(URI.parse("#{ENDPOINT}#{params.q}"))
end

def confirm
@employer = employer_params[:employer]
@payments = [
{ amount: 810, start: 'March 25', end: 'June 15', hours: 54, rate: 15 },
{ amount: 195, start: 'January 1', end: 'February 23', hours: 13, rate: 15 }
]
end

private

def employer_params
params.permit(:employer)
end
end
2 changes: 2 additions & 0 deletions app/helpers/providers_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ProvidersHelper
end
7 changes: 0 additions & 7 deletions app/javascript/controllers/hello_controller.js

This file was deleted.

5 changes: 3 additions & 2 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

import { application } from "./application"

import HelloController from "./hello_controller"
application.register("hello", HelloController)
import ProvidersController from "./providers_controller"
application.register("providers", ProvidersController)

44 changes: 44 additions & 0 deletions app/javascript/controllers/providers_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Controller } from "@hotwired/stimulus"

function toOptionHTML({ value }) {
return `<option value='${value}'>${value}</option>`;
}

const DEFAULT_OPTIONS = [
{
value: 'Uber'
},
{
value: 'Instacart'
},
{
value: 'Walmart'
},
{
value: 'Lyft'
}
].map(toOptionHTML);

export default class extends Controller {
static targets = ["options", "continue"];

selection = null;

connect() {
if (this.hasOptionsTarget) {
this.optionsTarget.innerHTML = DEFAULT_OPTIONS;
}
}

search(event) {
const input = event.target.value;
this.optionsTarget.innerHTML = [...DEFAULT_OPTIONS, toOptionHTML({ value: input })].join('');
}

select(event) {
console.log(event.detail);
this.selection = event.detail;

this.continueTarget.disabled = false;
}
}
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="<%= I18n.locale %>">
<head>
<title>IvCbvPayroll</title>
<title>Verify.gov</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
Expand All @@ -19,7 +19,7 @@
<%= render "application/usa_banner" %>
<%= render "application/header" %>
<main id="main-content">
<div class="grid-container usa-section">
<div class="grid-container usa-section margin-2">
<%= yield %>
</div>
</main>
Expand Down
1 change: 0 additions & 1 deletion app/views/pages/home.html.erb

This file was deleted.

16 changes: 16 additions & 0 deletions app/views/pages/welcome.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1>Hello, Matt</h1>
<h2>Let's verify your payment information.</h2>

<p>We'll connect to your payment records to get proof of payments to your caseworker and get benfits faster.</p>

<div class="usa-alert usa-alert--info margin-bottom-3">
<div class="usa-alert__body">
<p class="usa-alert__text">
Your information is secure. We will not share or keep your log in information. You will be able to preview and approve everything that is shared with your caseworker.
</p>
</div>
</div>

<%= link_to '/providers' do %>
<button class="usa-button usa-button--outline" type="button">Get Started</button>
<% end %>
25 changes: 25 additions & 0 deletions app/views/providers/confirm.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<h2>Review payment information from <%= @employer %></h2>
<p>Below is payment information from <%= @employer %> for the past 90 days.</p>

<h3 class="site-preview-heading">Total Payments: $<%= @payments.reduce(0) { |sum, payment| sum + payment[:amount] } %></h3>
<div class="usa-accordion margin-bottom-4">
<% @payments.each_with_index do |payment, index| %>
<div class="usa-accordion__heading">
<button
type="button"
class="usa-accordion__button"
aria-expanded="false"
aria-controls="<%= index %>"
>
Payment of $<%= payment[:amount] %>, <%= payment[:start] %> to <%= payment[:end] %>
</button>
</div>
<div id="<%= index %>" class="usa-accordion__content usa-prose">
<p>
<%= payment[:hours] %> hours at $<%= payment[:rate] %> per hour.
</p>
</div>
<% end %>
</div>

<button class="usa-button margin-top-3 usa-button--outline" type="button">Share payment information</button>
11 changes: 11 additions & 0 deletions app/views/providers/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h2>Get payment info from your employer.</h2>

<form data-controller="providers" action="/providers/confirm" method="get">
<label class="usa-label" for="employer">Search for an employer</label>
<div class="usa-combo-box margin-bottom-3" data-action="input->providers#search">
<select class="usa-select" name="employer" id="employer" data-providers-target="options" data-action="change->providers#select">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Did you figure all this out this morning? Nice. I guess this prevents us from needing to bring in React on the frontend, so that's kind of neat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! The Hotwire stuff is kinda nice. It sorta plays well with the USWDS stuff? Thanks to event bubbling. We may start to push up against some UX jank, though.

<option value>Select an employer</option>
</select>
</div>
<button class="usa-button usa-button--outline" disabled="disabled" type="submit" data-providers-target="continue">Continue</button>
</form>
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ en:
demo_banner: TEST SITE - Do not use real personal information (demo purposes only) - TEST SITE
menu: Menu
primary: Primary navigation
title: Iv Cbv Payroll
title: Verify.gov
languages:
en: English
es: Español
Expand Down
9 changes: 7 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
end
scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
# Your application routes go here
root "pages#home"
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
root "pages#welcome"

# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
get "providers/search" => "providers#search"
get "providers/confirm" => "providers#confirm"
resources :providers
# Defines the root path route ("/")
# root "articles#index"


end
end
15 changes: 15 additions & 0 deletions spec/helpers/providers_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the ProvidersHelper. For example:
#
# describe ProvidersHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe ProvidersHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
7 changes: 7 additions & 0 deletions spec/requests/providers_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'rails_helper'

RSpec.describe "Providers", type: :request do
describe "GET /index" do
pending "add some examples (or delete) #{__FILE__}"
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require "rails_helper"

RSpec.describe "pages/home.html.erb", type: :view do
RSpec.describe "pages/welcome.html.erb", type: :view do
it "displays the gov banner" do
render template: "pages/home", layout: "layouts/application"
render template: "pages/welcome", layout: "layouts/application"
expect(rendered).to match "An official website of the United States government"
end
end
Loading