Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7aadbcc
refactor: Utilized DSR AlertFieldLevel in NoDatabaseResultError
shindigira Jan 5, 2024
7f27a85
refactor: created a const for the sblhelp link
shindigira Jan 5, 2024
0fc8bc8
refactor: InputEntry utilizes DSR's TextInput
shindigira Jan 5, 2024
0b3a026
refactor: Utilized DSR AlertFieldLevel in InputErrorMessage
shindigira Jan 5, 2024
75099ba
dev: placed a way to destroy the login creds during development
shindigira Jan 5, 2024
f708e8f
refactor: auto-format
shindigira Jan 5, 2024
b9b75bf
chore: removed import
shindigira Jan 5, 2024
c92bdfa
Merge branch 'main' of github.com:cfpb/sbl-frontend into 85-dsr-userp…
shindigira Jan 5, 2024
1132062
refactor: Utilized TextIntroduction in Step1FormHeader and resolved T…
shindigira Jan 5, 2024
7b62970
fix: RSSD not RSS
shindigira Jan 8, 2024
131dbf4
chore: changed type to null
shindigira Jan 8, 2024
db5ff92
chore: changed TAX ID to TIN
shindigira Jan 8, 2024
d8cfb37
feat: email text instead of disabled input
shindigira Jan 8, 2024
0a6cd9e
style: adjusted spacing styles on User Profile
shindigira Jan 8, 2024
5997892
Merge branch 'main' of github.com:cfpb/sbl-frontend into 85-dsr-userp…
shindigira Jan 8, 2024
fac1333
chore: added TODO
shindigira Jan 9, 2024
17a49da
refactor: updated content text to the figma
shindigira Jan 9, 2024
f322295
chore: added TODO comment
shindigira Jan 9, 2024
60cecf3
styling: updated Checkbox, 01-09-24 Figma updates to spacing and cont…
shindigira Jan 10, 2024
9d8f286
styling: additional spacing changes
shindigira Jan 10, 2024
7345d67
style: px to rem button group
shindigira Jan 10, 2024
55048d8
chore: updated to latest DSR package
shindigira Jan 10, 2024
3655dd3
fix: disabled user name and LOG OUT during profile-form view
shindigira Jan 11, 2024
ec10c62
comment: indicated workaround for red checkbox border
shindigira Jan 11, 2024
b52498a
style: removed input border under red border during an error
shindigira Jan 11, 2024
3b16dc2
chore: remove unused classes
shindigira Jan 11, 2024
eda5f9c
style: updated content text, removed App.less
shindigira Jan 11, 2024
53aa0ad
style: fixed tailwind overriding styles by removing @tailwind directives
shindigira Jan 11, 2024
7991c7d
style: fixed tailwind overriding styles by removing @tailwind base di…
shindigira Jan 11, 2024
e79c9b5
chore: updated denied email notification based on figma
shindigira Jan 11, 2024
b7fad69
style: uses the listlink in the step1formerrorheader
shindigira Jan 11, 2024
9b21bdc
style: moved error within well
shindigira Jan 11, 2024
fc0ec76
style: small em to rem fix
shindigira Jan 11, 2024
59eba5f
style: style mt fix
shindigira Jan 11, 2024
ee5966a
fix: merge conflicts
shindigira Jan 11, 2024
6b056da
style: style updated spacings
shindigira Jan 11, 2024
0bdb4e9
style: spacing 2
shindigira Jan 11, 2024
424b438
fix: removed unused variable
shindigira Jan 11, 2024
74da277
fix: resolved merge conflicts from authenticatedlanding PRs
shindigira Jan 11, 2024
4fad441
[Task] [User Profile] useRef in Step1FormErrorHeader (#145)
shindigira Jan 11, 2024
9bcb2df
chore: package fix
shindigira Jan 11, 2024
64ad038
chore: CFPB package update
shindigira Jan 11, 2024
d0ec02d
chore: updated content text - checkbox well
shindigira Jan 11, 2024
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
180 changes: 90 additions & 90 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
12 changes: 0 additions & 12 deletions src/App.less

This file was deleted.

80 changes: 50 additions & 30 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/no-misused-promises */
import 'design-system-react/style.css';

import { useQuery } from '@tanstack/react-query';
import fetchInstitutions from 'api/fetchInstitutions';
import fetchIsDomainAllowed from 'api/fetchIsDomainAllowed';
Expand All @@ -8,15 +10,20 @@ import useSblAuth from 'api/useSblAuth';
import classNames from 'classnames';
import LoadingOrError from 'components/LoadingOrError';
import { Button, FooterCfGov, Link, PageHeader } from 'design-system-react';
import 'design-system-react/style.css';
import ViewUserProfile from 'pages/Filing/ViewUserProfile';
import { Scenario } from 'pages/ProfileForm/Step2Form/Step2FormHeader.data';
import type { ReactElement } from 'react';
import { Suspense, lazy } from 'react';
import { BrowserRouter, Navigate, Outlet, Route, Routes, useLocation } from 'react-router-dom';
import {
BrowserRouter,
Navigate,
Outlet,
Route,
Routes,
useLocation,
} from 'react-router-dom';
import useProfileForm from 'store/useProfileForm';
import './App.less';

import { sblHelpLink } from 'utils/common';

const FilingApp = lazy(async () => import('pages/Filing/FilingApp'));
const FilingHome = lazy(async () => import('pages/Filing/FilingHome'));
Expand Down Expand Up @@ -57,7 +64,10 @@ interface NavItemProperties {

function NavItem({ href, label, className }: NavItemProperties): JSX.Element {
return (
<Link {...{ href }} className={classNames(deriveClassname(href), className)}>
<Link
{...{ href }}
className={classNames(deriveClassname(href), className)}
>
{label}
</Link>
);
Expand All @@ -74,13 +84,17 @@ function BasicLayout(): ReactElement {
enabled: !!auth.isAuthenticated,
});

if (userInfo && !(pathname === '/')) {
if (userInfo && !(pathname === '/') && !(pathname === '/profile-form')) {
// Logged in
headerLinks.push(
<span key='user-name'>
<NavItem className="!font-normal " href="/user-profile" label={
userInfo.profile.name ?? userInfo.profile.email ?? 'User profile'
} />
<NavItem
className='!font-normal '
href='/user-profile'
label={
userInfo.profile.name ?? userInfo.profile.email ?? 'User profile'
}
/>
</span>,
<span className='a-link nav-item auth-action' key='logout'>
<Button label='LOG OUT' asLink onClick={auth.onLogout} />
Expand Down Expand Up @@ -128,24 +142,24 @@ function ProtectedRoute({

if (!isEmailDomainAllowed) {
ProfileFormState.setState({ selectedScenario: Scenario.Error1, step: 2 });
return <Navigate replace to="/profile-form" />;
return <Navigate replace to='/profile-form' />;
}

const isUserEmailDomainAssociatedWithAnyInstitution = institutionsAssociatedWithUserEmailDomain.length > 0;
if (!isUserEmailDomainAssociatedWithAnyInstitution){
const isUserEmailDomainAssociatedWithAnyInstitution =
institutionsAssociatedWithUserEmailDomain.length > 0;
if (!isUserEmailDomainAssociatedWithAnyInstitution) {
// TODO: replace this generic SBL Help link with a specific Salesforce form link, see:
// https://github.com/cfpb/sbl-frontend/issues/109
window.location.replace(
'https://sblhelp.consumerfinance.gov/',
);
window.location.replace(sblHelpLink);
return null;
}

const institutionsAssociatedWithUserProfile = UserProfile.institutions;
const isUserProfileAssociatedWithAnyInstitutions = institutionsAssociatedWithUserProfile.length > 0;
if(!isUserProfileAssociatedWithAnyInstitutions) {
const isUserProfileAssociatedWithAnyInstitutions =
institutionsAssociatedWithUserProfile.length > 0;
if (!isUserProfileAssociatedWithAnyInstitutions) {
ProfileFormState.setState({ step: 1 });
return (<Navigate replace to="/profile-form" />);
return <Navigate replace to='/profile-form' />;
}
return children;
}
Expand All @@ -157,20 +171,26 @@ export default function App(): ReactElement {
// TODO: incorporate this into useSblAuth, see:
// https://github.com/cfpb/sbl-frontend/issues/134
// eslint-disable-next-line unicorn/prefer-string-slice
const emailDomain = emailAddress?.substring(emailAddress.lastIndexOf('@')+1);
const emailDomain = emailAddress?.substring(
emailAddress.lastIndexOf('@') + 1,
);

const { isLoading: isFetchInstitutionsLoading, data: institutionsAssociatedWithUserEmailDomain } = useQuery({
queryKey: [`fetch-institutions-${emailDomain}`, emailDomain],
const {
isLoading: isFetchInstitutionsLoading,
data: institutionsAssociatedWithUserEmailDomain,
} = useQuery({
queryKey: [`fetch-institutions-${emailDomain}`, emailDomain],
queryFn: async () => fetchInstitutions(auth, emailDomain),
enabled: !!emailDomain,
});
const { isLoading: isEmailDomainAllowedLoading, data: isEmailDomainAllowed } = useQuery({
queryKey: [`is-domain-allowed-${emailDomain}`, emailDomain],
queryFn: async () => fetchIsDomainAllowed(auth, emailDomain),
enabled: !!emailDomain,
});
const { isLoading: isEmailDomainAllowedLoading, data: isEmailDomainAllowed } =
useQuery({
queryKey: [`is-domain-allowed-${emailDomain}`, emailDomain],
queryFn: async () => fetchIsDomainAllowed(auth, emailDomain),
enabled: !!emailDomain,
});
const { isLoading: isFetchUserProfileLoading, data: UserProfile } = useQuery({
queryKey: [`fetch-user-profile-${emailAddress}`, emailAddress],
queryKey: [`fetch-user-profile-${emailAddress}`, emailAddress],
queryFn: async () => fetchUserProfile(auth),
enabled: !!auth.isAuthenticated,
});
Expand All @@ -179,16 +199,16 @@ export default function App(): ReactElement {
auth.isLoading,
isFetchInstitutionsLoading,
isEmailDomainAllowedLoading,
isFetchUserProfileLoading
isFetchUserProfileLoading,
];
const isAnyAuthorizationLoading = loadingStates.some(Boolean);
const ProtectedRouteAuthorizations = {
...auth,
isEmailDomainAllowed,
institutionsAssociatedWithUserEmailDomain,
UserProfile,
isAnyAuthorizationLoading
}
isAnyAuthorizationLoading,
};

// TODO: add more comprehensive error and loading state handling, see:
// https://github.com/cfpb/sbl-frontend/issues/108
Expand Down
5 changes: 2 additions & 3 deletions src/api/submitUserProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { SblAuthProperties } from 'api/useSblAuth';
import { BASE_URL } from 'api/common';

interface UserProfileObject {
first_name: string;
Expand All @@ -10,7 +9,7 @@ interface UserProfileObject {
export const submitUserProfile = async (
auth: SblAuthProperties,
userProfileObject: UserProfileObject,
): Promise<any> => {
): Promise<null> => {
const response = await fetch(`/v1/admin/me/`, {
headers: {
Authorization: `Bearer ${auth.user?.access_token}`,
Expand All @@ -20,7 +19,7 @@ export const submitUserProfile = async (
body: JSON.stringify(userProfileObject),
});

return response.json() ;
return response.json() as Promise<null>;
};

export default submitUserProfile;
5 changes: 5 additions & 0 deletions src/api/useSblAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const useSblAuth = (): SblAuthProperties => {
auth.signoutRedirect({
post_logout_redirect_uri: window.location.origin,
});

// Note: This is placed here because after logging in with a non-domain email the app hard-forwards the user to sblHelp with no way of stopping this
if (import.meta.env.DEV) {
window.logout = onLogout;
}

return {
...auth,
Expand Down
2 changes: 1 addition & 1 deletion src/components/FieldGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface FieldGroupProperties {
function FieldGroup({ children }: FieldGroupProperties): JSX.Element {
return (
<div
className="bg-[#F7F8F9] p-[30px] !border !border-solid !border-cfpbBorderColor"
className="bg-[#F7F8F9] p-[1.875rem] !border !border-solid !border-cfpbBorderColor"
>
{children}
</div>
Expand Down
12 changes: 3 additions & 9 deletions src/components/InputErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ReactNode } from 'react';
import ErrorIcon from './ErrorIcon';
import { AlertFieldLevel } from 'design-system-react';

interface InputErrorMessageProperties {
children: ReactNode;
Expand All @@ -9,14 +9,8 @@ function InputErrorMessage({
children,
}: InputErrorMessageProperties): JSX.Element {
return (
<div
className='a-form-alert a-form-alert__error mt-[0.9375em]'
role='alert'
>
<ErrorIcon />
<p className='a-form-alert_text ml-6 -translate-y-[6%] text-[#1B1B1B]'>
{children}
</p>
<div className='mt-[0.9375rem]'>
<AlertFieldLevel message={children} status='error' />
</div>
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/ProfileFormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ interface Properties {

function ProfileFormWrapper({children}: Properties): JSX.Element {
return (
<div className="ml-5 mr-5 mt-[45px]">
<div className="max-w-[1200px] mx-auto mb-12">
<div className="max-w-[770px] mx-auto">
<div className="ml-5 mr-5 mt-[2.813rem]">
<div className="max-w-[75rem] mx-auto mb-12">
<div className="max-w-[48.125rem] mx-auto">
{ children }
</div>
</div>
Expand Down
19 changes: 17 additions & 2 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
@tailwind base;
/* @tailwind base; */
@tailwind components;
@tailwind utilities;

/* Modified from cf.gov for tailwind use, see:
https://github.com/search?q=org%3Acfpb+max-width%3A+41.875rem%3B&type=code&p=1
https://v1.tailwindcss.com/docs/adding-base-styles#using-css */

@layer components {
.row dd, .row dt, .row h3, .row h4, .row h5, .row h6, .row li, .row p, .row label {
max-width: 41.875rem;
}
}

.auth-action .a-btn {
font-weight: 600;
color: #43484e;
Expand All @@ -23,6 +33,11 @@
}

/* Checkbox Border error styling - workaround */
.m-form-field__checkbox.error-checkbox .a-label:before, .m-form-field__radio .a-label:before {
.m-form-field__checkbox.error-checkbox .a-label::before, .m-form-field__radio .a-label::before {
@apply !border-errorColor !border-2
}

/* Workaround for styling the institution details on Profile-Form */
.m-form-field__checkbox .invisible::before {
visibility: hidden;
}
5 changes: 3 additions & 2 deletions src/pages/Filing/FilingHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { ReactElement } from 'react';
import { Link as RouterLink } from "react-router-dom";
import './FilingHome.less';
import ProcessStep from './ProcessStep';
import { sblHelpLink, gleifLink } from 'utils/common';

function Home(): ReactElement {
const auth = useSblAuth();
Expand Down Expand Up @@ -55,7 +56,7 @@ function Home(): ReactElement {
>
In order to begin using the filing platform you must have a Legal
Entity Identifier (LEI) for your financial institution. Visit the{' '}
<Link href='https://www.gleif.org/'>Global LEI Foundation (GLEIF)</Link> website for
<Link href={gleifLink}>Global LEI Foundation (GLEIF)</Link> website for
more information on how to obtain an LEI.
</ProcessStep>

Expand Down Expand Up @@ -105,7 +106,7 @@ function Home(): ReactElement {
>
Find answers to frequently asked questions
</Link>,
<Link href='https://sblhelp.consumerfinance.gov/' key='ask-a-question'>
<Link href={sblHelpLink} key='ask-a-question'>
Submit a question
</Link>,
]}
Expand Down
1 change: 1 addition & 0 deletions src/pages/Filing/ViewUserProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useSblAuth from '../../../api/useSblAuth';
import CrumbTrail from '../../../components/CrumbTrail';
import AssociatedInstitutions from './AssociatedInstitutions';
import UserInformation from './UserInformation';
import { sblHelpLink } from 'utils/common';

export default function ViewUserProfile(): JSX.Element {
const auth = useSblAuth();
Expand Down
17 changes: 16 additions & 1 deletion src/pages/ProfileForm/ProfileFormUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import type { ValidationSchema, FormattedUserProfileObjectType } from './types';
import type {
InstitutionDetailsApiType,
InstitutionDetailsApiCheckedType,
ValidationSchema,
FormattedUserProfileObjectType
} from 'pages/ProfileForm/types';

export const formatUserProfileObject = (
userProfileObject: ValidationSchema,
Expand All @@ -7,3 +12,13 @@ export const formatUserProfileObject = (
last_name: userProfileObject.lastName,
leis: userProfileObject.financialInstitutions.map(object => object.lei),
});

export const formatDataCheckedState = (
fiDataInput: InstitutionDetailsApiType[] = [],
): InstitutionDetailsApiCheckedType[] =>
fiDataInput.map(object => ({ ...object, checked: false }));

export default {
formatUserProfileObject,
formatDataCheckedState
}
Loading