Skip to content

Commit

Permalink
Demo draft
Browse files Browse the repository at this point in the history
  • Loading branch information
allthesignals committed Apr 24, 2024
1 parent 61450d4 commit 575d405
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 15 deletions.
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
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">
<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>
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ 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
fr: Français
zh: 中文
skip_link: Skip to main content
welcome:

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
5 changes: 5 additions & 0 deletions spec/models/provider_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe Provider, type: :model 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

0 comments on commit 575d405

Please sign in to comment.