Skip to content

Commit

Permalink
Merge branch 'main' into george/FFS-1425-language-invite
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeCodes19 committed Oct 1, 2024
2 parents 598407a + 4a9dd34 commit 4d7e19a
Show file tree
Hide file tree
Showing 20 changed files with 218 additions and 126 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/markdownlint-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
},
{
"pattern": "^https://confluenceent.cms.gov"
},
{
"pattern": "^https://www.hhs.gov"
}
],
"replacementPatterns": [
Expand Down
1 change: 0 additions & 1 deletion app/app/assets/stylesheets/application.postcss.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
@forward "uswds-settings.scss";
@forward "uswds";
@forward "uswds-overrides.scss";
@forward "lds-ripple.scss";
@forward "cbv.scss";
9 changes: 9 additions & 0 deletions app/app/assets/stylesheets/cbv.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,12 @@ html {
.cbv-row-highlight td {
@include u-bg('yellow-5v');
}

.rotate {
animation: 1s linear infinite rotate-con;
}

@keyframes rotate-con {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
53 changes: 0 additions & 53 deletions app/app/assets/stylesheets/lds-ripple.scss

This file was deleted.

1 change: 1 addition & 0 deletions app/app/assets/stylesheets/uswds-settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
$theme-header-logo-text-width: 100%,
$theme-header-min-width: "tablet",
$theme-site-margins-breakpoint: "tablet",
$theme-step-indicator-segment-height: 0,
);
24 changes: 20 additions & 4 deletions app/app/channels/paystubs_channel.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
class PaystubsChannel < ApplicationCable::Channel
periodically :check_pinwheel_account_synchrony, every: 5.seconds

def subscribed
cbv_flow = CbvFlow.find(connection.session[:cbv_flow_id])
stream_for cbv_flow
@cbv_flow = CbvFlow.find(connection.session[:cbv_flow_id])
stream_for @cbv_flow
end

def unsubscribed
# Any cleanup needed when channel is unsubscribed
private

def check_pinwheel_account_synchrony
pinwheel_account = PinwheelAccount.find_by_pinwheel_account_id(params["account_id"])

if pinwheel_account.present?
broadcast_to(@cbv_flow, {
event: "cbv.status_update",
account_id: pinwheel_account.pinwheel_account_id,
employment: pinwheel_account.job_completed?("employment"),
identity: pinwheel_account.job_completed?("identity"),
paystubs: pinwheel_account.job_completed?("paystubs"),
income: pinwheel_account.job_completed?("income"),
has_fully_synced: pinwheel_account.has_fully_synced?
})
end
end
end
2 changes: 2 additions & 0 deletions app/app/controllers/cbv/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def next_path
when "cbv/agreements"
cbv_flow_employer_search_path
when "cbv/employer_searches"
cbv_flow_synchronizations_path
when "cbv/synchronizations"
cbv_flow_payment_details_path
when "cbv/missing_results"
cbv_flow_summary_path
Expand Down
19 changes: 19 additions & 0 deletions app/app/controllers/cbv/synchronizations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Cbv::SynchronizationsController < Cbv::BaseController
helper_method :job_completed?

def show
account_id = params[:user][:account_id]

@pinwheel_account = @cbv_flow.pinwheel_accounts.find_by(pinwheel_account_id: account_id)

if @pinwheel_account && @pinwheel_account.has_fully_synced?
redirect_to cbv_flow_payment_details_path(user: { account_id: @pinwheel_account.pinwheel_account_id })
end
end

private

def job_completed?(job)
@pinwheel_account.present? && @pinwheel_account.job_completed?(job)
end
end
37 changes: 9 additions & 28 deletions app/app/javascript/controllers/cbv/employer_search.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
import { Controller } from "@hotwired/stimulus"
import * as ActionCable from '@rails/actioncable'
import { loadPinwheel, initializePinwheel, fetchToken } from "../../utilities/pinwheel"

export default class extends Controller {
static targets = [
"form",
"searchTerms",
"userAccountId",
"modal",
"employerButton"
];

pinwheel = loadPinwheel();

cable = ActionCable.createConsumer();

connect() {
this.cable.subscriptions.create({ channel: 'PaystubsChannel' }, {
connected: () => {
console.log("Connected to the channel:", this);
},
disconnected: () => {
console.log("Disconnected");
},
received: (data) => {
if (data.event === 'cbv.payroll_data_available') {
const accountId = data.account_id
this.userAccountIdTarget.value = accountId
this.formTarget.submit();
}
}
});
this.errorHandler = document.addEventListener("turbo:frame-missing", this.onTurboError)
}

disconnect() {
document.removeEventListener("turbo:frame-missing", this.errorHandler)
}

onSignInSuccess() {
this.pinwheel.then(pinwheel => pinwheel.close());
this.modalTarget.click();
this.reenableButtons()
}

onTurboError(event) {
console.warn("Got turbo error, redirecting:", event)

Expand All @@ -61,6 +35,14 @@ export default class extends Controller {
}
}

onPinwheelEvent(eventName, eventPayload) {
if (eventName === 'success') {
const { accountId } = eventPayload;
this.userAccountIdTarget.value = accountId
this.formTarget.submit();
}
}

getDocumentLocale() {
return document.documentElement.lang
}
Expand All @@ -75,10 +57,9 @@ export default class extends Controller {

submit(token) {
this.pinwheel.then(Pinwheel => initializePinwheel(Pinwheel, token, {
onEvent: console.log,
onEvent: this.onPinwheelEvent.bind(this),
onError: this.onPinwheelError.bind(this),
onExit: this.reenableButtons.bind(this),
onSuccess: this.onSignInSuccess.bind(this),
}));
}

Expand Down
43 changes: 43 additions & 0 deletions app/app/javascript/controllers/cbv/synchronizations_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Controller } from "@hotwired/stimulus"
import * as ActionCable from '@rails/actioncable'

export default class extends Controller {
static targets = ["form", "userAccountId", "employmentJob", "identityJob", "paystubsJob", "incomeJob"];

cable = ActionCable.createConsumer();

updateIndicatorStatus(element, completed) {
if (completed) {
element.querySelector('.completed').classList.remove('display-none');
element.querySelector('.in-progress').classList.add('display-none');
} else {
element.querySelector('.completed').classList.add('display-none');
element.querySelector('.in-progress').classList.remove('display-none');
}
}

connect() {
this.cable.subscriptions.create({ channel: 'PaystubsChannel', account_id: this.userAccountIdTarget.value }, {
connected: () => {
console.log("Connected to the channel:", this);
},
disconnected: () => {
console.log("Disconnected");
},
received: (data) => {
if (data.event === 'cbv.status_update') {
if (data.has_fully_synced) {
const accountId = data.account_id;
this.userAccountIdTarget.value = accountId;
this.formTarget.submit();
}

this.updateIndicatorStatus(this.employmentJobTarget, data.employment);
this.updateIndicatorStatus(this.identityJobTarget, data.identity);
this.updateIndicatorStatus(this.paystubsJobTarget, data.paystubs);
this.updateIndicatorStatus(this.incomeJobTarget, data.income);
}
}
});
}
}
2 changes: 2 additions & 0 deletions app/app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
import { application } from "./application"

import CbvEmployerSearch from "./cbv/employer_search"
import CbvSynchronizationsController from "./cbv/synchronizations_controller"
application.register("cbv-employer-search", CbvEmployerSearch)
application.register("cbv-synchronizations", CbvSynchronizationsController)
19 changes: 17 additions & 2 deletions app/app/models/pinwheel_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,25 @@ def has_fully_synced?
end

def job_succeeded?(job)
error_column = EVENTS_ERRORS_MAP.select { |key| key.start_with? job }&.values.last
sync_column = EVENTS_MAP.select { |key| key.start_with? job }&.values.last
error_column, sync_column = event_columns_for(job)
return nil unless error_column.present?

supported_jobs.include?(job) && send(sync_column).present? && send(error_column).blank?
end

def job_completed?(job)
error_column, sync_column = event_columns_for(job)
return nil unless error_column.present?

supported_jobs.include?(job) && (send(sync_column).present? || send(error_column).present?)
end

private

def event_columns_for(job)
error_column = EVENTS_ERRORS_MAP.select { |key| key.start_with? job }&.values.last
sync_column = EVENTS_MAP.select { |key| key.start_with? job }&.values.last

[ error_column, sync_column ]
end
end
33 changes: 1 addition & 32 deletions app/app/views/cbv/employer_searches/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<%= form_with url: cbv_flow_employer_search_path, method: :get, class: "usa-search usa-search--big margin-y-4", html: { role: "search" }, data: { turbo_frame: "employers", turbo_action: "advance" } do |f| %>
<%= f.label :query, "Search for your employer", class: "usa-sr-only" %>
<%= f.text_field :query, value: @query, class: "usa-input", type: "search", data: { "cbv-employer-search-target": "searchTerms" } %>
<%= f.text_field :query, value: @query, class: "usa-input", type: "search" %>
<button
class="usa-button"
type="submit"
Expand All @@ -45,35 +45,4 @@
<%= form_with url: next_path, method: :get, class: "display-none", data: { 'cbv-employer-search-target': "form" } do |f| %>
<input type="hidden" name="user[account_id]" data-cbv-employer-search-target="userAccountId" >
<% end %>

<a
href="#data-fetching-modal"
class="display-none"
aria-controls="data-fetching-modal"
data-open-modal
data-cbv-employer-search-target="modal"
></a>
<div class="margin-y-3">
<div
class="usa-modal"
id="data-fetching-modal"
aria-labelledby="modal-3-heading"
aria-describedby="modal-3-description"
data-force-action
>
<div class="usa-modal__content">
<div class="usa-modal__main">
<h2 class="usa-modal__heading" id="modal-3-heading">
<%= t(".fetching_payroll") %>
</h2>
<div class="usa-prose">
<p id="modal-3-description">
<%= t(".fetching_payroll_description") %>
</p>
</div>
<div class="lds-ripple" style="left: 30%;"><div></div><div></div></div>
</div>
</div>
</div>
</div>
</div>
11 changes: 11 additions & 0 deletions app/app/views/cbv/synchronizations/_indicator.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<svg class="in-progress <%= completed ? "display-none" : "" %> usa-icon border-05 rotate border-base-light radius-pill padding-1 usa-icon--size-5" aria-hidden="true" focusable="false" role="img">
<use
xlink:href="<%= asset_path("@uswds/uswds/dist/img/sprite.svg#autorenew") %>"
></use>
</svg>

<svg class="completed <%= !completed ? "display-none" : "" %> usa-icon border-05 bg-primary text-white border-primary radius-pill padding-1 usa-icon--size-5" aria-hidden="true" focusable="false" role="img">
<use
xlink:href="<%= asset_path("@uswds/uswds/dist/img/sprite.svg#check") %>"
></use>
</svg>
Loading

0 comments on commit 4d7e19a

Please sign in to comment.