Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mvickstrivve committed Oct 5, 2023
1 parent 70434e5 commit b6f0fab
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 29 deletions.
4 changes: 2 additions & 2 deletions public/main.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/component/AccountLinkView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AccountLinkForm from './AccountLinkForm';
import AccountLinkContainer from './AccountLinkContainer';
import { mountAccountLinkViewProps } from '../types';
import withBase, { BaseProps } from './withBase';
import AccountLinkCore, { AccountLinkState } from '../core/accountLink';
import AccountLinkCore, { AccountLinkState, failedStatus } from '../core/accountLink';
import SecurityIcon from './SecurityIcon';
import StatusModal from './StatusModal';
import PendingModal from './PendingModal';
Expand All @@ -32,6 +32,9 @@ export function AccountLinkView({
PENDING_TFA: 'Enter One-Time Passcode',
};

const isSuccessJob = state?.message?.termination_type === 'BILLABLE'
const isFailedJob = failedStatus.includes(state?.message?.termination_type);

useEffect(() => {
const accountLink = core.createAccountLink(options);
accountLink.subscribe((state: AccountLinkState) => {
Expand Down Expand Up @@ -175,9 +178,9 @@ export function AccountLinkView({
</div>
<StatusModal
open={state?.success}
variant="pending"
title="We’re Still Finishing Up"
description={
variant={isFailedJob ? "error" : isSuccessJob ? "success" : "pending"}
title={isFailedJob ? "Error!" : isSuccessJob ? "Success!" : "We’re Still Finishing Up"}
description={ isFailedJob ? state.message?.status_message : isSuccessJob ? "Your card details were successfully placed on this site." :
'This might take a minute. Select another site to update while you wait.'
}
buttonText="Browse More Sites"
Expand Down Expand Up @@ -315,7 +318,7 @@ export function AccountLinkView({
site: host,
});
}}
forgotLink={accountLinkCore?.site?.forgot_password_page}
forgotLink={accountLinkCore?.site?.forgot_password_page || accountLinkCore?.site?.login_page}
core={core}
site={accountLinkCore?.site}
/>
Expand Down
20 changes: 5 additions & 15 deletions src/component/MySiteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ function MySiteList({
if (isDisabled) {
} else if (isSuccess) {
setOpenStatus(item);
} else if (isError) {
setOpenStatus(item);
} else {
onSelectItem(item);
}
Expand Down Expand Up @@ -108,17 +110,6 @@ function MySiteList({
{timeAgo(item.job?.last_updated_on)}
</div>
)}
{isError && (
<div className="errorText" css={appearance.elements?.errorText}>
Problem logging in.{' '}
<a
style={{ cursor: 'pointer' }}
onClick={() => setOpenStatus(item)}
>
See details
</a>
</div>
)}
</div>
{isSuccess && <SuccessIcon />}
{isError && <ErrorIcon />}
Expand Down Expand Up @@ -163,10 +154,9 @@ function MySiteList({
>
{errors.length > 0 && (
<div>
<p css={appearance.elements?.mySiteTitle}>Errors</p>
<p css={appearance.elements?.mySiteTitle}>Failures</p>
<p css={appearance.elements?.mySiteDescription}>
The following site encountered a login error. Click for more
details.
We were unable to place your card on the following sites.
</p>
{errors?.map(renderitem)}
</div>
Expand All @@ -182,7 +172,7 @@ function MySiteList({
)}
{successful.length > 0 && (
<div>
<p css={appearance.elements?.mySiteTitle}>Successful placement</p>
<p css={appearance.elements?.mySiteTitle}>Successful placements</p>
<p css={appearance.elements?.mySiteDescription}>
Your card details were successfully placed on the following sites.
</p>
Expand Down
9 changes: 5 additions & 4 deletions src/component/SelectSiteView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ export function SelectSiteView({
: [];

const failedJobs = (state?.jobs || []).filter((item) =>
errorStatus.includes(item.termination_type)
errorStatus.includes(item?.termination_type)
);


if (state?.loading) {
return (
<div
Expand Down Expand Up @@ -92,14 +93,14 @@ export function SelectSiteView({
{failedJobs.length > 0 &&
failedJobs.length === state?.jobs.length ? (
<>
See you recent{' '}
See your recent{' '}
<a
onClick={() => {
core.push(StrivveCoreMount.SELECT_SITE_LINKED);
}}
css={appearance.elements?.selectSiteTitleLink}
>
{failedJobs.length} site(s)
{failedJobs.length} site(s).
</a>{' '}
that failed.
</>
Expand All @@ -112,7 +113,7 @@ export function SelectSiteView({
}}
css={appearance.elements?.selectSiteTitleLink}
>
{totalSuccessJob} sites.
{totalSuccessJob} site(s).
</a>
</>
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/component/StatusModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PendingIcon from './icons/PendingIcon';
type StatusModalProps = {
open?: boolean;
title: string;
description: string;
description?: string;
buttonText: string;
onClickButton?: () => void;
onClickClose?: () => void;
Expand Down
2 changes: 1 addition & 1 deletion src/core/accountLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export default class AccountLinkCore {
: message.auth_percent_complete;

if (message?.termination_type || data?.type === 'error' || isComplete) {
if (failedStatus.includes(message.termination_type)) {
if (failedStatus.includes(message?.termination_type)) {
this.updateState({
percent,
message,
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default class StrivveCore {
const jobs = this?.jobs || [];
const item = this.jobs?.[jobs.length - 1];

if (!item.termination_type) {
if (!item?.termination_type) {
this.service.cancelJob(item.id);
this.onMessage(item.id, {
status: 'CANCELLED',
Expand Down

0 comments on commit b6f0fab

Please sign in to comment.