-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into george/FFS-1425-language-invite
- Loading branch information
Showing
20 changed files
with
218 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
app/app/javascript/controllers/cbv/synchronizations_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.