Skip to content

Commit

Permalink
feat: add continue button to company document list
Browse files Browse the repository at this point in the history
  • Loading branch information
serikjensen committed Feb 25, 2025
1 parent 1e283b1 commit 81c2cc5
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 9 deletions.
19 changes: 19 additions & 0 deletions src/components/Company/DocumentSigner/DocumentList/Actions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ActionsLayout, Button } from '@/components/Common'

import { useTranslation } from 'react-i18next'
import { useDocumentList } from './DocumentList'

export function Actions() {
const { t } = useTranslation('Company.DocumentList')
const { companyForms, handleContinue, isSelfSignatory } = useDocumentList()

const hasSignedAllForms = companyForms.every(companyForm => !companyForm.requires_signing)

return (
<ActionsLayout>
<Button onPress={handleContinue} isDisabled={isSelfSignatory && !hasSignedAllForms}>
{t('continueCta')}
</Button>
</ActionsLayout>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import { companyEvents } from '@/shared/constants'
import { Head } from './Head'
import { List } from './List'
import { ManageSignatories } from './ManageSignatories'

import { Actions } from './Actions'
type DocumentListContextType = {
companyForms: Schemas['Form'][]
documentListError: Error | null
handleRequestFormToSign: (form: Schemas['Form']) => void
handleChangeSignatory: () => void
handleContinue: () => void
isSelfSignatory: boolean
signatory?: Schemas['Signatory']
}
Expand Down Expand Up @@ -74,6 +75,10 @@ function Root({ companyId, signatoryId, className, children }: DocumentListProps
onEvent(companyEvents.COMPANY_FORM_EDIT_SIGNATORY, signatory)
}

const handleContinue = () => {
onEvent(companyEvents.COMPANY_FORMS_DONE)
}

return (
<section className={className}>
<DocumentListProvider
Expand All @@ -82,7 +87,8 @@ function Root({ companyId, signatoryId, className, children }: DocumentListProps
documentListError,
handleRequestFormToSign,
handleChangeSignatory,
isSelfSignatory,
handleContinue,
isSelfSignatory: true,
signatory,
}}
>
Expand All @@ -94,6 +100,7 @@ function Root({ companyId, signatoryId, className, children }: DocumentListProps
<Head />
<ManageSignatories />
<List />
<Actions />
</>
)}
</Flex>
Expand All @@ -105,3 +112,4 @@ function Root({ companyId, signatoryId, className, children }: DocumentListProps
DocumentList.Head = Head
DocumentList.ManageSignatories = ManageSignatories
DocumentList.List = List
DocumentList.Actions = Actions
3 changes: 1 addition & 2 deletions src/components/Company/DocumentSigner/DocumentList/Head.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useTranslation } from 'react-i18next'

export function Head() {
// @ts-expect-error HACK missing translations
const { t } = useTranslation('Company.DocumentSigner')
const { t } = useTranslation('Company.DocumentList')

return <h2>{t('documentListTitle')}</h2>
}
4 changes: 2 additions & 2 deletions src/components/Company/DocumentSigner/DocumentList/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useDocumentList } from './DocumentList'
function List() {
const { companyForms, handleRequestFormToSign, documentListError, isSelfSignatory } =
useDocumentList()
// @ts-expect-error HACK missing translations
const { t } = useTranslation('Company.DocumentSigner')

const { t } = useTranslation('Company.DocumentList')

const onRequestSign = (requestedForm: FormData) => {
const companyForm = companyForms.find(currentForm => currentForm.uuid === requestedForm.uuid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ function isValidSignatoryTitle(
}

function ManageSignatories() {
// @ts-expect-error HACK missing translations
const { t } = useTranslation('Company.DocumentSigner')
const { t } = useTranslation('Company.DocumentList')
const { isSelfSignatory, signatory, handleChangeSignatory } = useDocumentList()

let signatorySubtext = t('noSignatorySubtext')
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en/Company.DocumentList.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"signDocumentComplete": "Complete",
"notSigned": "Not signed",
"documentListError": "Could not load your documents, try again later.",
"emptyTableTitle": "No documents found"
"emptyTableTitle": "No documents found",
"continueCta": "Continue"
}
1 change: 1 addition & 0 deletions src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const companyEvents = {
COMPANY_ASSIGN_SIGNATORY_DONE: 'company/signatory/assignSignatory/done',
COMPANY_VIEW_FORM_TO_SIGN: 'company/forms/view',
COMPANY_FORM_EDIT_SIGNATORY: 'company/forms/editSignatory',
COMPANY_FORMS_DONE: 'company/forms/done',
} as const

export const componentEvents = {
Expand Down
1 change: 1 addition & 0 deletions src/types/i18next.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface CompanyDocumentList{
"notSigned":string;
"documentListError":string;
"emptyTableTitle":string;
"continueCta":string;
};
export interface CompanyFederalTaxes{
"pageTitle":string;
Expand Down

0 comments on commit 81c2cc5

Please sign in to comment.