Skip to content

Commit 105e0c0

Browse files
authored
Merge branch 'main' into kw/fix/SDK-198
2 parents 94b5b5f + c7b0085 commit 105e0c0

22 files changed

+684
-213
lines changed

package-lock.json

Lines changed: 257 additions & 206 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@
9797
"prettier": "^3.7.4",
9898
"react-dnd": "^16.0.1",
9999
"react-dnd-html5-backend": "^16.0.1",
100-
"sass-embedded": "^1.97.1",
100+
"sass-embedded": "^1.97.2",
101101
"ts-morph": "^27.0.2",
102102
"tsx": "^4.21.0",
103-
"typescript-eslint": "^8.51.0",
103+
"typescript-eslint": "^8.52.0",
104104
"vite": "^6.4.1",
105105
"vite-plugin-checker": "^0.12.0",
106106
"vite-plugin-circular-dependency": "^0.5.0",
@@ -128,7 +128,7 @@
128128
"i18next": "^25.7.3",
129129
"react-aria": "^3.44.0",
130130
"react-aria-components": "1.13.0",
131-
"react-error-boundary": "^6.0.1",
131+
"react-error-boundary": "^6.0.2",
132132
"react-hook-form": "^7.70.0",
133133
"react-i18next": "^16.5.1",
134134
"react-robot": "^1.2.0",

src/components/Contractor/Payments/CreatePayment/CreatePayment.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useForm } from 'react-hook-form'
88
import { zodResolver } from '@hookform/resolvers/zod'
99
import { useTranslation } from 'react-i18next'
1010
import type { ContractorPaymentGroupPreview } from '@gusto/embedded-api/models/components/contractorpaymentgrouppreview'
11+
import { useBankAccountsGet } from '@gusto/embedded-api/react-query/bankAccountsGet'
1112
import type { InternalAlert } from '../types'
1213
import { CreatePaymentPresentation } from './CreatePaymentPresentation'
1314
import {
@@ -57,6 +58,9 @@ export const Root = ({ companyId, dictionary, onEvent }: CreatePaymentProps) =>
5758
contractor.isActive &&
5859
contractor.onboardingStatus === ContractorOnboardingStatus.ONBOARDING_COMPLETED,
5960
)
61+
const { data: bankAccounts } = useBankAccountsGet({ companyId })
62+
// Currently, we only support a single default bank account per company.
63+
const bankAccount = bankAccounts?.companyBankAccounts?.[0]
6064
const initialContractorPayments: (ContractorPayments & { isTouched: boolean })[] = useMemo(
6165
() =>
6266
contractors.map(contractor => ({
@@ -248,6 +252,7 @@ export const Root = ({ companyId, dictionary, onEvent }: CreatePaymentProps) =>
248252
onBackToEdit={onBackToEdit}
249253
onSubmit={onCreatePaymentGroup}
250254
isLoading={isCreatingContractorPaymentGroup || isPreviewingContractorPaymentGroup}
255+
bankAccount={bankAccount}
251256
/>
252257
)}
253258
{!previewData && (

src/components/Contractor/Payments/CreatePayment/PreviewPresentation.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ContractorPaymentGroupPreview } from '@gusto/embedded-api/models/c
33
import type { ContractorPaymentForGroupPreview } from '@gusto/embedded-api/models/components/contractorpaymentforgrouppreview'
44
import { useMemo } from 'react'
55
import type { Contractor } from '@gusto/embedded-api/models/components/contractor'
6+
import type { CompanyBankAccount } from '@gusto/embedded-api/models/components/companybankaccount'
67
import { getContractorDisplayName } from './helpers'
78
import { DataView, Flex } from '@/components/Common'
89
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
@@ -18,6 +19,7 @@ interface PreviewPresentationProps {
1819
onBackToEdit: () => void
1920
onSubmit: () => void
2021
isLoading: boolean
22+
bankAccount?: CompanyBankAccount
2123
}
2224

2325
export const PreviewPresentation = ({
@@ -26,6 +28,7 @@ export const PreviewPresentation = ({
2628
onBackToEdit,
2729
onSubmit,
2830
isLoading,
31+
bankAccount,
2932
}: PreviewPresentationProps) => {
3033
const { Button, Text, Heading, Alert } = useComponentContext()
3134
useI18n('Contractor.Payments.CreatePayment')
@@ -105,7 +108,7 @@ export const PreviewPresentation = ({
105108
},
106109
{
107110
title: t('summaryTableHeaders.debitAccount'),
108-
render: () => <Text>{'debitAccount'}</Text>,
111+
render: () => <Text>{bankAccount?.hiddenAccountNumber ?? t('naDebitAccount')}</Text>,
109112
},
110113
{
111114
title: t('summaryTableHeaders.debitDate'),
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { useTranslation } from 'react-i18next'
2+
import { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'
3+
import type { OnEventType } from '@/components/Base/useBase'
4+
import { ActionsLayout, Flex } from '@/components/Common'
5+
import { Form } from '@/components/Common/Form'
6+
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
7+
import { useComponentDictionary, useI18n } from '@/i18n'
8+
import { informationRequestEvents, type EventType } from '@/shared/constants'
9+
10+
const INFORMATION_REQUEST_FORM_ID = 'gusto-sdk-information-request-form'
11+
12+
interface InformationRequestFormProps extends BaseComponentInterface<'Payroll.InformationRequestForm'> {
13+
requestId: string
14+
onEvent: OnEventType<EventType, unknown>
15+
}
16+
17+
export function InformationRequestForm(props: InformationRequestFormProps) {
18+
return (
19+
<BaseComponent {...props}>
20+
<Root {...props}>{props.children}</Root>
21+
</BaseComponent>
22+
)
23+
}
24+
25+
function Root({ dictionary }: InformationRequestFormProps) {
26+
useComponentDictionary('Payroll.InformationRequestForm', dictionary)
27+
useI18n('Payroll.InformationRequestForm')
28+
const { t } = useTranslation('Payroll.InformationRequestForm')
29+
const { Heading, Text } = useComponentContext()
30+
const { onEvent, baseSubmitHandler } = useBase()
31+
32+
// TODO: Wire up form submission with API call using the custom RFI submission endpoint created in SC-56
33+
const onSubmit = async () => {
34+
// TODO: remove this lint ignore once we wire this up and await the api call
35+
// eslint-disable-next-line @typescript-eslint/require-await
36+
await baseSubmitHandler({}, async () => {
37+
// TODO: Call API submission endpoint here
38+
onEvent(informationRequestEvents.INFORMATION_REQUEST_FORM_DONE)
39+
})
40+
}
41+
42+
return (
43+
<Flex flexDirection="column" gap={16}>
44+
<Heading as="h2">{t('title')}</Heading>
45+
<Text>Placeholder: Form content will be rendered here</Text>
46+
<Form id={INFORMATION_REQUEST_FORM_ID} onSubmit={onSubmit}>
47+
{/* TODO: Add form fields here */}
48+
</Form>
49+
</Flex>
50+
)
51+
}
52+
53+
const Footer = ({ onEvent }: { onEvent: OnEventType<EventType, unknown> }) => {
54+
useI18n('Payroll.InformationRequestForm')
55+
const { t } = useTranslation('Payroll.InformationRequestForm')
56+
const { Button } = useComponentContext()
57+
58+
const handleCancel = () => {
59+
onEvent(informationRequestEvents.INFORMATION_REQUEST_FORM_CANCEL)
60+
}
61+
62+
return (
63+
<ActionsLayout>
64+
<Button variant="secondary" onClick={handleCancel}>
65+
{t('cta.cancel')}
66+
</Button>
67+
<Button variant="primary" type="submit" form={INFORMATION_REQUEST_FORM_ID}>
68+
{t('cta.submit')}
69+
</Button>
70+
</ActionsLayout>
71+
)
72+
}
73+
74+
InformationRequestForm.Footer = Footer
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { InformationRequestForm } from './InformationRequestForm'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.root {
2+
display: flex;
3+
flex-direction: column;
4+
gap: toRem(20);
5+
}
6+
7+
.header {
8+
display: flex;
9+
flex-direction: column;
10+
gap: toRem(2);
11+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { useTranslation } from 'react-i18next'
2+
import styles from './InformationRequestList.module.scss'
3+
import { BaseComponent, type BaseComponentInterface } from '@/components/Base'
4+
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
5+
import { useComponentDictionary, useI18n } from '@/i18n'
6+
import { DataView } from '@/components/Common/DataView/DataView'
7+
import { useDataView } from '@/components/Common/DataView/useDataView'
8+
import { Flex, FlexItem } from '@/components/Common'
9+
import { informationRequestEvents } from '@/shared/constants'
10+
11+
interface InformationRequestListProps extends BaseComponentInterface<'Payroll.InformationRequestList'> {
12+
companyId: string
13+
onEvent: BaseComponentInterface['onEvent']
14+
}
15+
16+
export function InformationRequestList(props: InformationRequestListProps) {
17+
return (
18+
<BaseComponent {...props}>
19+
<Root {...props}>{props.children}</Root>
20+
</BaseComponent>
21+
)
22+
}
23+
24+
function Root({ dictionary, onEvent }: InformationRequestListProps) {
25+
useComponentDictionary('Payroll.InformationRequestList', dictionary)
26+
useI18n('Payroll.InformationRequestList')
27+
const { t } = useTranslation('Payroll.InformationRequestList')
28+
const { Heading, Text, Button, Badge } = useComponentContext()
29+
30+
// TODO: Replace with actual RFI data and add it to the following table
31+
32+
const dataViewProps = useDataView({
33+
data: [{ id: 'placeholder' }],
34+
columns: [
35+
{
36+
title: 'Type',
37+
render: () => (
38+
<FlexItem flexGrow={1}>
39+
<Text weight="semibold">Company onboarding</Text>
40+
</FlexItem>
41+
),
42+
},
43+
{
44+
title: 'Status',
45+
render: () => (
46+
<Flex gap={8} alignItems="center">
47+
<Badge status="info">Replace with status</Badge>
48+
</Flex>
49+
),
50+
},
51+
{
52+
title: '',
53+
render: () => (
54+
<Flex justifyContent="flex-end" alignItems="center">
55+
<Button
56+
variant="secondary"
57+
onClick={() => {
58+
onEvent(informationRequestEvents.INFORMATION_REQUEST_RESPOND, {
59+
requestId: 'placeholder-id',
60+
})
61+
}}
62+
>
63+
{t('cta.respond')}
64+
</Button>
65+
</Flex>
66+
),
67+
},
68+
],
69+
})
70+
71+
return (
72+
<div className={styles.root}>
73+
<Flex flexDirection="column" gap={24}>
74+
<div className={styles.header}>
75+
<Heading as="h2" styledAs="h3">
76+
{t('title')}
77+
</Heading>
78+
<Text>{t('description')}</Text>
79+
</div>
80+
81+
<DataView {...dataViewProps} label={t('title')} />
82+
</Flex>
83+
</div>
84+
)
85+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { InformationRequestList } from './InformationRequestList'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.footer {
2+
display: flex;
3+
justify-content: center;
4+
align-items: center;
5+
width: 100%;
6+
}

0 commit comments

Comments
 (0)