@gusto/embedded-react-sdk 0.10.5 → 0.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/components/Base/Base.js +18 -19
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Common/OnboardingStatusBadge/index.d.ts +1 -1
- package/dist/components/Common/OnboardingStatusBadge/index.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureForm.js +4 -6
- package/dist/components/Common/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormActions.js +6 -7
- package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +7 -8
- package/dist/components/Common/SignatureForm/SignatureFormFields.js.map +1 -1
- package/dist/components/Common/TaxInputs/TaxInputs.d.ts +1 -0
- package/dist/components/Common/TaxInputs/TaxInputs.js +100 -80
- package/dist/components/Common/TaxInputs/TaxInputs.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatory.js +11 -13
- package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js +0 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +2 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +9 -10
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +1 -1
- package/dist/components/Company/AssignSignatory/TitleSelect.js +7 -8
- package/dist/components/Company/AssignSignatory/TitleSelect.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +8 -9
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js +7 -8
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +4 -5
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js +15 -17
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +1 -1
- package/dist/components/Company/DocumentSigner/DocumentSigner.js +24 -22
- package/dist/components/Company/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js +7 -9
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +1 -1
- package/dist/components/Company/FederalTaxes/Actions.js +1 -1
- package/dist/components/Company/FederalTaxes/FederalTaxes.js +15 -17
- package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Form.js +2 -3
- package/dist/components/Company/FederalTaxes/Form.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +1 -1
- package/dist/components/Company/Industry/Actions.js +1 -1
- package/dist/components/Company/Industry/Context.js +1 -1
- package/dist/components/Company/Industry/Edit.js +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +1 -1
- package/dist/components/Company/Locations/LocationForm/Form.js +4 -5
- package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/LocationForm.js +7 -9
- package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +1 -1
- package/dist/components/Company/Locations/LocationsList/Actions.js +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +1 -1
- package/dist/components/Company/Locations/LocationsList/LocationsList.js +9 -11
- package/dist/components/Company/Locations/LocationsList/LocationsList.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +1 -1
- package/dist/components/Company/OnboardingOverview/Completed.js +5 -6
- package/dist/components/Company/OnboardingOverview/Completed.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/MissingRequirements.js +2 -3
- package/dist/components/Company/OnboardingOverview/MissingRequirements.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js +2 -4
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +16 -18
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Actions.js +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +25 -26
- package/dist/components/Company/PaySchedule/_parts/Edit.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Head.js +2 -3
- package/dist/components/Company/PaySchedule/_parts/Head.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/List.js +5 -6
- package/dist/components/Company/PaySchedule/_parts/List.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +14 -14
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +1 -1
- package/dist/components/Contractor/Address/Address.js +0 -2
- package/dist/components/Contractor/Address/Address.js.map +1 -1
- package/dist/components/Contractor/Address/Form.js +6 -7
- package/dist/components/Contractor/Address/Form.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +1 -1
- package/dist/components/Contractor/List/index.js +2 -3
- package/dist/components/Contractor/List/index.js.map +1 -1
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +16 -17
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js +2 -3
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +2 -3
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/Compensation/Actions.js +5 -6
- package/dist/components/Employee/Compensation/Actions.js.map +1 -1
- package/dist/components/Employee/Compensation/Edit.js +2 -3
- package/dist/components/Employee/Compensation/Edit.js.map +1 -1
- package/dist/components/Employee/Compensation/List.js +1 -1
- package/dist/components/Employee/Deductions/Actions.js +1 -1
- package/dist/components/Employee/Deductions/DeductionForm.js +1 -1
- package/dist/components/Employee/Deductions/DeductionsList.js +1 -1
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js +1 -1
- package/dist/components/Employee/Deductions/useDeductions.js +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js +10 -12
- package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/List.js +2 -3
- package/dist/components/Employee/DocumentSigner/DocumentList/List.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +8 -10
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +1 -1
- package/dist/components/Employee/EmployeeList/Actions.js +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js +9 -11
- package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Head.js +2 -3
- package/dist/components/Employee/EmployeeList/Head.js.map +1 -1
- package/dist/components/Employee/EmployeeList/List.js +14 -15
- package/dist/components/Employee/EmployeeList/List.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +1 -1
- package/dist/components/Employee/Landing/Landing.js +6 -7
- package/dist/components/Employee/Landing/Landing.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Actions.js +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +2 -3
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +2 -3
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js +3 -4
- package/dist/components/Employee/PaymentMethod/Split.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +1 -1
- package/dist/components/Employee/Profile/Actions.js +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +9 -10
- package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
- package/dist/components/Employee/Profile/HomeAddress.js +4 -5
- package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +1 -1
- package/dist/components/Employee/Profile/useProfile.js +1 -1
- package/dist/components/Employee/Taxes/Actions.js +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +1 -1
- package/dist/shared/constants.js +1 -1
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/PaySchedule.tsx"],"sourcesContent":["import type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useState } from 'react'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { Frequency } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayschedules'\nimport type { MODE, PayScheduleInputs, PayScheduleOutputs } from './usePaySchedule'\nimport {\n PayScheduleProvider,\n PayScheduleSchema,\n type PayScheduleDefaultValues,\n} from './usePaySchedule'\nimport { Actions, Edit, Head, List } from './_parts'\nimport { Form } from '@/components/Common/Form'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { Flex } from '@/components/Common'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\ninterface PayScheduleProps extends CommonComponentInterface<'Company.PaySchedule'> {\n companyId: string\n defaultValues?: PayScheduleDefaultValues\n}\n\nexport const PaySchedule = ({\n companyId,\n defaultValues,\n dictionary,\n ...props\n}: PayScheduleProps & BaseComponentInterface) => {\n useI18n('Company.PaySchedule')\n useComponentDictionary('Company.PaySchedule', dictionary)\n return (\n <BaseComponent {...props}>\n <Root companyId={companyId} defaultValues={defaultValues}>\n {props.children}\n </Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ companyId, children, defaultValues }: PayScheduleProps) => {\n const { baseSubmitHandler, onEvent, fieldErrors, setError: setBaseError } = useBase()\n const [mode, setMode] = useState<MODE>('LIST_PAY_SCHEDULES')\n const [currentPaySchedule, setCurrentPaySchedule] = useState<PayScheduleType | null>(null)\n const transformedDefaultValues: PayScheduleInputs = {\n frequency: defaultValues?.frequency ?? 'Every week',\n anchorPayDate: defaultValues?.anchorPayDate ? new Date(defaultValues.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: defaultValues?.anchorEndOfPayPeriod\n ? new Date(defaultValues.anchorEndOfPayPeriod)\n : undefined,\n day1: defaultValues?.day1 ?? undefined,\n day2: defaultValues?.day2 ?? undefined,\n customName: defaultValues?.customName ?? '',\n customTwicePerMonth: 'false',\n payPeriodPreviewRange: 0,\n }\n\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({\n companyId,\n })\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const formMethods = useForm<PayScheduleInputs, unknown, PayScheduleOutputs>({\n resolver: zodResolver(PayScheduleSchema),\n defaultValues: transformedDefaultValues,\n })\n const { watch, setValue, reset, clearErrors, setError } = formMethods\n\n useEffect(() => {\n if (fieldErrors) {\n // TODO: These error messages are not being localized correctly\n fieldErrors.forEach(error => {\n setError(error.key as keyof PayScheduleInputs, { message: error.message })\n })\n }\n }, [setError, fieldErrors])\n\n const allValues = watch()\n\n const formattedAnchorPayDate = allValues.anchorPayDate\n ? formatDateToStringDate(allValues.anchorPayDate) || ''\n : ''\n const formattedAnchorEndOfPayPeriod = allValues.anchorEndOfPayPeriod\n ? formatDateToStringDate(allValues.anchorEndOfPayPeriod) || ''\n : ''\n\n const { data: payPreviewData, isLoading } = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: allValues.frequency,\n anchorPayDate: formattedAnchorPayDate,\n anchorEndOfPayPeriod: formattedAnchorEndOfPayPeriod,\n day1: allValues.day1 ?? undefined,\n day2: allValues.day2 ?? undefined,\n },\n {\n enabled: Boolean(\n allValues.anchorPayDate &&\n allValues.anchorEndOfPayPeriod &&\n (mode === 'ADD_PAY_SCHEDULE' || mode === 'EDIT_PAY_SCHEDULE'),\n ),\n },\n )\n\n // Set the custom_twice_per_month value based on the frequency and day_1 and day_2 values as it is not set by the API call\n useEffect(() => {\n if (\n allValues.frequency === 'Twice per month' &&\n allValues.day1 === 15 &&\n allValues.day2 === 31 &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `1st15th`)\n } else if (\n allValues.frequency === 'Twice per month' &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `custom`)\n }\n }, [allValues.frequency, allValues.day1, allValues.day2, setValue, allValues.customTwicePerMonth])\n\n const handleAdd = () => {\n setMode('ADD_PAY_SCHEDULE')\n reset({})\n }\n const handleCancel = () => {\n setMode('LIST_PAY_SCHEDULES')\n reset({})\n clearErrors()\n setBaseError(null)\n }\n const handleEdit = (schedule: PayScheduleType) => {\n reset({\n frequency: schedule.frequency as Frequency,\n anchorPayDate: schedule.anchorPayDate ? new Date(schedule.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: schedule.anchorEndOfPayPeriod\n ? new Date(schedule.anchorEndOfPayPeriod)\n : undefined,\n day1: schedule.day1 ?? undefined,\n day2: schedule.day2 ?? undefined,\n customName: schedule.customName ?? '',\n })\n setCurrentPaySchedule(schedule)\n setMode('EDIT_PAY_SCHEDULE')\n }\n const handleContinue = () => {\n onEvent(componentEvents.PAY_SCHEDULE_DONE)\n }\n const onSubmit: SubmitHandler<PayScheduleOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const formatPayloadDate = (date: Date | undefined): string => {\n return date ? formatDateToStringDate(date) || '' : ''\n }\n\n if (mode === 'ADD_PAY_SCHEDULE') {\n const createPayScheduleResponse = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_CREATED, createPayScheduleResponse)\n reset()\n } else if (mode === 'EDIT_PAY_SCHEDULE') {\n const version = currentPaySchedule?.version\n const updatePayScheduleResponse = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule?.uuid as string,\n companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n version: version as string,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_UPDATED, updatePayScheduleResponse)\n reset()\n }\n setMode('LIST_PAY_SCHEDULES')\n })\n }\n\n return (\n <PayScheduleProvider\n value={{\n companyId,\n handleAdd,\n handleEdit,\n handleCancel,\n handleContinue,\n mode,\n paySchedules: paySchedules.payScheduleList,\n payPeriodPreview: payPreviewData?.object?.payPeriods,\n payPreviewLoading: isLoading,\n currentPaySchedule,\n }}\n >\n <span data-testid=\"pay-schedule-edit-form\">\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Edit />\n <Actions />\n </Flex>\n )}\n </Form>\n </FormProvider>\n </span>\n </PayScheduleProvider>\n )\n}\n\nPaySchedule.Head = Head\nPaySchedule.List = List\nPaySchedule.Edit = Edit\nPaySchedule.Actions = Actions\n"],"names":["PaySchedule","companyId","defaultValues","dictionary","props","useI18n","useComponentDictionary","jsx","BaseComponent","Root","children","baseSubmitHandler","onEvent","fieldErrors","setBaseError","useBase","mode","setMode","useState","currentPaySchedule","setCurrentPaySchedule","transformedDefaultValues","paySchedules","usePaySchedulesGetAllSuspense","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","formMethods","useForm","zodResolver","PayScheduleSchema","watch","setValue","reset","clearErrors","setError","useEffect","error","allValues","formattedAnchorPayDate","formatDateToStringDate","formattedAnchorEndOfPayPeriod","payPreviewData","isLoading","usePaySchedulesGetPreview","handleAdd","handleCancel","handleEdit","schedule","handleContinue","componentEvents","onSubmit","data","payload","formatPayloadDate","date","createPayScheduleResponse","version","updatePayScheduleResponse","PayScheduleProvider","FormProvider","Form","jsxs","Flex","Head","List","Edit","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,OACEC,GAAQ,qBAAqB,GAC7BC,GAAuB,uBAAuBH,CAAU,GAEtD,gBAAAI,EAACC,IAAe,EAAA,GAAGJ,GACjB,UAAA,gBAAAG,EAACE,MAAK,WAAAR,GAAsB,eAAAC,GACzB,UAAME,EAAA,SAAA,CACT,EACF,CAAA,IA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AA,MACC,OAAO;AAAA,QACL,WAAA3D;AAAA,QACA,WAAA6C;AAAA,QACA,YAAAE;AAAA,QACA,cAAAD;AAAA,QACA,gBAAAG;AAAA,QACA,MAAAlC;AAAA,QACA,cAAcM,EAAa;AAAA,QAC3B,kBAAkBqB,GAAgB,QAAQ;AAAA,QAC1C,mBAAmBC;AAAA,QACnB,oBAAAzB;AAAA,MACF;AAAA,MAEA,UAAA,gBAAAZ,EAAC,UAAK,eAAY,0BAChB,4BAACsD,GAAc,EAAA,GAAGjC,GAChB,UAAC,gBAAArB,EAAAuD,IAAA,EAAK,UAAUlC,EAAY,aAAawB,CAAQ,GAC9C,UAAA1C,KAGE,gBAAAqD,EAAAC,IAAA,EAAK,eAAc,UAClB,UAAA;AAAA,QAAA,gBAAAzD,EAAC0D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,GACX,EAAA,CAEJ,GACF,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;AAEApE,EAAY,OAAOiE;AACnBjE,EAAY,OAAOkE;AACnBlE,EAAY,OAAOmE;AACnBnE,EAAY,UAAUoE;"}
|
|
1
|
+
{"version":3,"file":"PaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/PaySchedule.tsx"],"sourcesContent":["import type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useState } from 'react'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { Frequency } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayschedules'\nimport type { MODE, PayScheduleInputs, PayScheduleOutputs } from './usePaySchedule'\nimport {\n PayScheduleProvider,\n PayScheduleSchema,\n type PayScheduleDefaultValues,\n} from './usePaySchedule'\nimport { Actions, Edit, Head, List } from './_parts'\nimport { Form } from '@/components/Common/Form'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { Flex } from '@/components/Common'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\ninterface PayScheduleProps extends CommonComponentInterface<'Company.PaySchedule'> {\n companyId: string\n defaultValues?: PayScheduleDefaultValues\n}\n\nexport const PaySchedule = ({\n companyId,\n defaultValues,\n dictionary,\n ...props\n}: PayScheduleProps & BaseComponentInterface) => {\n useI18n('Company.PaySchedule')\n useComponentDictionary('Company.PaySchedule', dictionary)\n return (\n <BaseComponent {...props}>\n <Root companyId={companyId} defaultValues={defaultValues}>\n {props.children}\n </Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ companyId, children, defaultValues }: PayScheduleProps) => {\n const { baseSubmitHandler, onEvent, fieldErrors, setError: setBaseError } = useBase()\n const [mode, setMode] = useState<MODE>('LIST_PAY_SCHEDULES')\n const [currentPaySchedule, setCurrentPaySchedule] = useState<PayScheduleType | null>(null)\n const transformedDefaultValues: PayScheduleInputs = {\n frequency: defaultValues?.frequency ?? 'Every week',\n anchorPayDate: defaultValues?.anchorPayDate ? new Date(defaultValues.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: defaultValues?.anchorEndOfPayPeriod\n ? new Date(defaultValues.anchorEndOfPayPeriod)\n : undefined,\n day1: defaultValues?.day1 ?? undefined,\n day2: defaultValues?.day2 ?? undefined,\n customName: defaultValues?.customName ?? '',\n customTwicePerMonth: 'false',\n payPeriodPreviewRange: 0,\n }\n\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({\n companyId,\n })\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const formMethods = useForm<PayScheduleInputs, unknown, PayScheduleOutputs>({\n resolver: zodResolver(PayScheduleSchema),\n defaultValues: transformedDefaultValues,\n })\n const { watch, setValue, reset, clearErrors, setError } = formMethods\n\n useEffect(() => {\n if (fieldErrors) {\n // TODO: These error messages are not being localized correctly\n fieldErrors.forEach(error => {\n setError(error.key as keyof PayScheduleInputs, { message: error.message })\n })\n }\n }, [setError, fieldErrors])\n\n const allValues = watch()\n\n const formattedAnchorPayDate = allValues.anchorPayDate\n ? formatDateToStringDate(allValues.anchorPayDate) || ''\n : ''\n const formattedAnchorEndOfPayPeriod = allValues.anchorEndOfPayPeriod\n ? formatDateToStringDate(allValues.anchorEndOfPayPeriod) || ''\n : ''\n\n const { data: payPreviewData, isLoading } = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: allValues.frequency,\n anchorPayDate: formattedAnchorPayDate,\n anchorEndOfPayPeriod: formattedAnchorEndOfPayPeriod,\n day1: allValues.day1 ?? undefined,\n day2: allValues.day2 ?? undefined,\n },\n {\n enabled: Boolean(\n allValues.anchorPayDate &&\n allValues.anchorEndOfPayPeriod &&\n (mode === 'ADD_PAY_SCHEDULE' || mode === 'EDIT_PAY_SCHEDULE'),\n ),\n },\n )\n\n // Set the custom_twice_per_month value based on the frequency and day_1 and day_2 values as it is not set by the API call\n useEffect(() => {\n if (\n allValues.frequency === 'Twice per month' &&\n allValues.day1 === 15 &&\n allValues.day2 === 31 &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `1st15th`)\n } else if (\n allValues.frequency === 'Twice per month' &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `custom`)\n }\n }, [allValues.frequency, allValues.day1, allValues.day2, setValue, allValues.customTwicePerMonth])\n\n const handleAdd = () => {\n setMode('ADD_PAY_SCHEDULE')\n reset({})\n }\n const handleCancel = () => {\n setMode('LIST_PAY_SCHEDULES')\n reset({})\n clearErrors()\n setBaseError(null)\n }\n const handleEdit = (schedule: PayScheduleType) => {\n reset({\n frequency: schedule.frequency as Frequency,\n anchorPayDate: schedule.anchorPayDate ? new Date(schedule.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: schedule.anchorEndOfPayPeriod\n ? new Date(schedule.anchorEndOfPayPeriod)\n : undefined,\n day1: schedule.day1 ?? undefined,\n day2: schedule.day2 ?? undefined,\n customName: schedule.customName ?? '',\n })\n setCurrentPaySchedule(schedule)\n setMode('EDIT_PAY_SCHEDULE')\n }\n const handleContinue = () => {\n onEvent(componentEvents.PAY_SCHEDULE_DONE)\n }\n const onSubmit: SubmitHandler<PayScheduleOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const formatPayloadDate = (date: Date | undefined): string => {\n return date ? formatDateToStringDate(date) || '' : ''\n }\n\n if (mode === 'ADD_PAY_SCHEDULE') {\n const createPayScheduleResponse = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_CREATED, createPayScheduleResponse)\n reset()\n } else if (mode === 'EDIT_PAY_SCHEDULE') {\n const version = currentPaySchedule?.version\n const updatePayScheduleResponse = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule?.uuid as string,\n companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n version: version as string,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_UPDATED, updatePayScheduleResponse)\n reset()\n }\n setMode('LIST_PAY_SCHEDULES')\n })\n }\n\n return (\n <PayScheduleProvider\n value={{\n companyId,\n handleAdd,\n handleEdit,\n handleCancel,\n handleContinue,\n mode,\n paySchedules: paySchedules.payScheduleList,\n payPeriodPreview: payPreviewData?.object?.payPeriods,\n payPreviewLoading: isLoading,\n currentPaySchedule,\n }}\n >\n <span data-testid=\"pay-schedule-edit-form\">\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Edit />\n <Actions />\n </Flex>\n )}\n </Form>\n </FormProvider>\n </span>\n </PayScheduleProvider>\n )\n}\n\nPaySchedule.Head = Head\nPaySchedule.List = List\nPaySchedule.Edit = Edit\nPaySchedule.Actions = Actions\n"],"names":["PaySchedule","companyId","defaultValues","dictionary","props","useI18n","useComponentDictionary","jsx","BaseComponent","Root","children","baseSubmitHandler","onEvent","fieldErrors","setBaseError","useBase","mode","setMode","useState","currentPaySchedule","setCurrentPaySchedule","transformedDefaultValues","paySchedules","usePaySchedulesGetAllSuspense","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","formMethods","useForm","zodResolver","PayScheduleSchema","watch","setValue","reset","clearErrors","setError","useEffect","error","allValues","formattedAnchorPayDate","formatDateToStringDate","formattedAnchorEndOfPayPeriod","payPreviewData","isLoading","usePaySchedulesGetPreview","handleAdd","handleCancel","handleEdit","schedule","handleContinue","componentEvents","onSubmit","data","payload","formatPayloadDate","date","createPayScheduleResponse","version","updatePayScheduleResponse","PayScheduleProvider","FormProvider","Form","jsxs","Flex","Head","List","Edit","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,eAAAC;AAAA,EAC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AAI;AAAA,YAAA;AAAA,UACF;AAAA,QACF,CACD;AACO,QAAA9C,EAAAuC,EAAgB,sBAAsBQ,CAAyB,GACjEzB,EAAA;AAAA,MAAA;AAER,MAAAjB,EAAQ,oBAAoB;AAAA,IAAA,CAC7B;AAAA,EACH;AAGE,SAAA,gBAAAV;AAAA,IAACqD;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,WAAA3D;AAAA,QACA,WAAA6C;AAAA,QACA,YAAAE;AAAA,QACA,cAAAD;AAAA,QACA,gBAAAG;AAAA,QACA,MAAAlC;AAAA,QACA,cAAcM,EAAa;AAAA,QAC3B,kBAAkBqB,GAAgB,QAAQ;AAAA,QAC1C,mBAAmBC;AAAA,QACnB,oBAAAzB;AAAA,MACF;AAAA,MAEA,UAAA,gBAAAZ,EAAC,UAAK,eAAY,0BAChB,4BAACsD,GAAc,EAAA,GAAGjC,GAChB,UAAC,gBAAArB,EAAAuD,IAAA,EAAK,UAAUlC,EAAY,aAAawB,CAAQ,GAC9C,UAAA1C,KAGE,gBAAAqD,EAAAC,IAAA,EAAK,eAAc,UAClB,UAAA;AAAA,QAAA,gBAAAzD,EAAC0D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,GACX,EAAA,CAEJ,GACF,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;AAEApE,EAAY,OAAOiE;AACnBjE,EAAY,OAAOkE;AACnBlE,EAAY,OAAOmE;AACnBnE,EAAY,UAAUoE;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as e, Fragment as d, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as l } from "react-i18next";
|
|
3
3
|
import { usePaySchedule as m } from "../usePaySchedule.js";
|
|
4
|
-
import "
|
|
4
|
+
import "../../../../shared/constants.js";
|
|
5
5
|
import { ActionsLayout as i } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
6
6
|
import { useComponentContext as u } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
7
|
const E = () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as a, jsxs as m } from "react/jsx-runtime";
|
|
2
2
|
import { useFormContext as S, useWatch as u } from "react-hook-form";
|
|
3
3
|
import { useTranslation as T } from "react-i18next";
|
|
4
4
|
import { useState as N, useEffect as h } from "react";
|
|
@@ -6,7 +6,6 @@ import { usePaySchedule as x } from "../usePaySchedule.js";
|
|
|
6
6
|
import n from "./Edit.module.scss.js";
|
|
7
7
|
import { Flex as f } from "../../../Common/Flex/Flex.js";
|
|
8
8
|
import { Grid as E } from "../../../Common/Grid/Grid.js";
|
|
9
|
-
import "classnames";
|
|
10
9
|
import { useComponentContext as R } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
11
10
|
import { formatDateNamedWeekdayShortPlusDate as P } from "../../../../helpers/dateFormatting.js";
|
|
12
11
|
import { TextInputField as O } from "../../../Common/Fields/TextInputField/TextInputField.js";
|
|
@@ -14,16 +13,16 @@ import { SelectField as v } from "../../../Common/Fields/SelectField/SelectField
|
|
|
14
13
|
import { RadioGroupField as F } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
15
14
|
import { NumberInputField as D } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
16
15
|
import { DatePickerField as w } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
|
|
17
|
-
const
|
|
18
|
-
const d = R(), { t: e } = T("Company.PaySchedule"), { payPeriodPreview: t, mode: p, payPreviewLoading: b } = x(), { setValue: o } = S(), [
|
|
16
|
+
const z = () => {
|
|
17
|
+
const d = R(), { t: e } = T("Company.PaySchedule"), { payPeriodPreview: t, mode: p, payPreviewLoading: b } = x(), { setValue: o } = S(), [r, g] = N(0), i = u({ name: "frequency" }), l = u({ name: "customTwicePerMonth" }), y = u({ name: "payPeriodPreviewRange" }), q = i === "Twice per month" && l === "custom" || i === "Monthly", C = i === "Twice per month" && l === "custom";
|
|
19
18
|
return h(() => {
|
|
20
19
|
i === "Twice per month" && l === "1st15th" && (o("day1", 15), o("day2", 31));
|
|
21
20
|
}, [i, l, o]), h(() => {
|
|
22
|
-
y === void 0 && o("payPeriodPreviewRange",
|
|
23
|
-
}, [
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
/* @__PURE__ */
|
|
26
|
-
/* @__PURE__ */
|
|
21
|
+
y === void 0 && o("payPeriodPreviewRange", r);
|
|
22
|
+
}, [r, o, y]), p !== "EDIT_PAY_SCHEDULE" && p !== "ADD_PAY_SCHEDULE" ? null : /* @__PURE__ */ a("div", { className: n.payScheduleContainer, children: /* @__PURE__ */ m(E, { gap: 32, gridTemplateColumns: { base: "1fr", small: "1fr 1fr" }, children: [
|
|
23
|
+
/* @__PURE__ */ a("div", { className: n.payScheduleForm, children: /* @__PURE__ */ m(f, { flexDirection: "column", children: [
|
|
24
|
+
/* @__PURE__ */ a(O, { name: "customName", label: "Name", isRequired: !0 }),
|
|
25
|
+
/* @__PURE__ */ a(
|
|
27
26
|
v,
|
|
28
27
|
{
|
|
29
28
|
name: "frequency",
|
|
@@ -37,7 +36,7 @@ const J = () => {
|
|
|
37
36
|
isRequired: !0
|
|
38
37
|
}
|
|
39
38
|
),
|
|
40
|
-
i === "Twice per month" && /* @__PURE__ */
|
|
39
|
+
i === "Twice per month" && /* @__PURE__ */ a(
|
|
41
40
|
F,
|
|
42
41
|
{
|
|
43
42
|
name: "customTwicePerMonth",
|
|
@@ -49,7 +48,7 @@ const J = () => {
|
|
|
49
48
|
]
|
|
50
49
|
}
|
|
51
50
|
),
|
|
52
|
-
/* @__PURE__ */
|
|
51
|
+
/* @__PURE__ */ a(
|
|
53
52
|
w,
|
|
54
53
|
{
|
|
55
54
|
name: "anchorPayDate",
|
|
@@ -58,7 +57,7 @@ const J = () => {
|
|
|
58
57
|
isRequired: !0
|
|
59
58
|
}
|
|
60
59
|
),
|
|
61
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ a(
|
|
62
61
|
w,
|
|
63
62
|
{
|
|
64
63
|
name: "anchorEndOfPayPeriod",
|
|
@@ -67,11 +66,11 @@ const J = () => {
|
|
|
67
66
|
isRequired: !0
|
|
68
67
|
}
|
|
69
68
|
),
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ a("div", { className: q ? "" : n.visuallyHidden, children: /* @__PURE__ */ a(D, { name: "day1", label: e("labels.firstPayDayOfTheMonth"), isRequired: !0 }) }),
|
|
70
|
+
/* @__PURE__ */ a("div", { className: C ? "" : n.visuallyHidden, children: /* @__PURE__ */ a(D, { name: "day2", label: e("labels.lastPayDayOfTheMonth"), isRequired: !0 }) })
|
|
72
71
|
] }) }),
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
!b && /* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ a(f, { flexDirection: "column", gap: 4, justifyContent: "center", alignItems: "center", children: t && t[r] ? /* @__PURE__ */ m("div", { className: n.calendarContainer, children: [
|
|
73
|
+
!b && /* @__PURE__ */ a(
|
|
75
74
|
v,
|
|
76
75
|
{
|
|
77
76
|
name: "payPeriodPreviewRange",
|
|
@@ -80,42 +79,42 @@ const J = () => {
|
|
|
80
79
|
value: String(c),
|
|
81
80
|
label: `${P(s.startDate)} – ${P(s.endDate)}`
|
|
82
81
|
})),
|
|
83
|
-
defaultValue: String(
|
|
82
|
+
defaultValue: String(r),
|
|
84
83
|
onChange: (s) => {
|
|
85
84
|
const c = Number(s);
|
|
86
85
|
isNaN(c) || g(c);
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
),
|
|
90
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ a(
|
|
91
90
|
d.CalendarPreview,
|
|
92
91
|
{
|
|
93
92
|
dateRange: {
|
|
94
|
-
start: new Date(t[
|
|
95
|
-
end: new Date(t[
|
|
93
|
+
start: new Date(t[r].startDate),
|
|
94
|
+
end: new Date(t[r].endDate),
|
|
96
95
|
label: e("payPreview.payPeriod") || "Pay Period"
|
|
97
96
|
},
|
|
98
97
|
highlightDates: [
|
|
99
98
|
{
|
|
100
|
-
date: new Date(t[
|
|
99
|
+
date: new Date(t[r].checkDate),
|
|
101
100
|
highlightColor: "primary",
|
|
102
101
|
label: e("payPreview.payday") || "Payday"
|
|
103
102
|
},
|
|
104
103
|
{
|
|
105
|
-
date: new Date(t[
|
|
104
|
+
date: new Date(t[r].runPayrollBy),
|
|
106
105
|
highlightColor: "secondary",
|
|
107
106
|
label: e("payPreview.payrollDeadline") || "Payroll Deadline"
|
|
108
107
|
}
|
|
109
108
|
]
|
|
110
109
|
},
|
|
111
|
-
|
|
110
|
+
r
|
|
112
111
|
)
|
|
113
|
-
] }) : /* @__PURE__ */
|
|
112
|
+
] }) : /* @__PURE__ */ a("div", { className: n.calendarContainer, children: /* @__PURE__ */ a(
|
|
114
113
|
d.Alert,
|
|
115
114
|
{
|
|
116
115
|
status: "info",
|
|
117
116
|
label: e("previewAlert.title", "Pay Schedule Preview"),
|
|
118
|
-
children: /* @__PURE__ */
|
|
117
|
+
children: /* @__PURE__ */ a(d.Text, { children: e(
|
|
119
118
|
"previewAlert.description",
|
|
120
119
|
"Complete all the required fields on the left to see a preview of your pay schedule."
|
|
121
120
|
) })
|
|
@@ -124,6 +123,6 @@ const J = () => {
|
|
|
124
123
|
] }) });
|
|
125
124
|
};
|
|
126
125
|
export {
|
|
127
|
-
|
|
126
|
+
z as Edit
|
|
128
127
|
};
|
|
129
128
|
//# sourceMappingURL=Edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Edit.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/Edit.tsx"],"sourcesContent":["import { useFormContext, useWatch } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { useEffect, useState } from 'react'\nimport type { PayScheduleInputs } from '../usePaySchedule'\nimport { usePaySchedule } from '../usePaySchedule'\nimport style from './Edit.module.scss'\nimport {\n Flex,\n SelectField,\n RadioGroupField,\n Grid,\n TextInputField,\n NumberInputField,\n DatePickerField,\n} from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { formatDateNamedWeekdayShortPlusDate } from '@/helpers/dateFormatting'\n\nexport const Edit = () => {\n const Components = useComponentContext()\n const { t } = useTranslation('Company.PaySchedule')\n const { payPeriodPreview, mode, payPreviewLoading } = usePaySchedule()\n const { setValue } = useFormContext<PayScheduleInputs>()\n const [selectedPayPeriodIndex, setSelectedPayPeriodIndex] = useState<number>(0)\n\n const frequency = useWatch({ name: 'frequency' })\n const customTwicePerMonth = useWatch({ name: 'customTwicePerMonth' })\n const payPeriodPreviewRange = useWatch({ name: 'payPeriodPreviewRange' })\n\n const shouldShowDay1 =\n (frequency === 'Twice per month' && customTwicePerMonth === 'custom') || frequency === 'Monthly'\n const shouldShowDay2 = frequency === 'Twice per month' && customTwicePerMonth === 'custom'\n\n useEffect(() => {\n if (frequency === 'Twice per month' && customTwicePerMonth === '1st15th') {\n setValue('day1', 15)\n setValue('day2', 31)\n }\n }, [frequency, customTwicePerMonth, setValue])\n\n // This is a workaround to ensure that the pay period preview range is set when the selected pay period index changes\n // TODO: Once we have a RHF free select, that can be used and this effect can be removed\n useEffect(() => {\n if (payPeriodPreviewRange === undefined) {\n setValue('payPeriodPreviewRange', selectedPayPeriodIndex)\n }\n }, [selectedPayPeriodIndex, setValue, payPeriodPreviewRange])\n\n if (mode !== 'EDIT_PAY_SCHEDULE' && mode !== 'ADD_PAY_SCHEDULE') {\n return null\n }\n\n return (\n <div className={style.payScheduleContainer}>\n <Grid gap={32} gridTemplateColumns={{ base: '1fr', small: '1fr 1fr' }}>\n <div className={style.payScheduleForm}>\n <Flex flexDirection={'column'}>\n <TextInputField name=\"customName\" label=\"Name\" isRequired />\n <SelectField\n name=\"frequency\"\n label={t('labels.frequency')}\n options={[\n { value: 'Every week', label: t('frequencies.everyWeek') },\n { value: 'Every other week', label: t('frequencies.everyOtherWeek') },\n { value: 'Twice per month', label: t('frequencies.twicePerMonth') },\n { value: 'Monthly', label: t('frequencies.monthly') },\n ]}\n isRequired\n />\n {frequency === 'Twice per month' && (\n <RadioGroupField\n name=\"customTwicePerMonth\"\n label={t('labels.frequencyOptions')}\n description={t('descriptions.frequencyOptionsDescription')}\n options={[\n { value: '1st15th', label: t('frequencyOptions.15thAndLast') },\n { value: 'custom', label: t('frequencyOptions.custom') },\n ]}\n />\n )}\n <DatePickerField\n name=\"anchorPayDate\"\n label={t('labels.firstPayDate')}\n description={t('descriptions.anchorPayDateDescription')}\n isRequired\n />\n <DatePickerField\n name=\"anchorEndOfPayPeriod\"\n label={t('labels.firstPayPeriodEndDate')}\n description={t('descriptions.anchorEndOfPayPeriodDescription')}\n isRequired\n />\n <div className={shouldShowDay1 ? '' : style.visuallyHidden}>\n <NumberInputField name=\"day1\" label={t('labels.firstPayDayOfTheMonth')} isRequired />\n </div>\n <div className={shouldShowDay2 ? '' : style.visuallyHidden}>\n <NumberInputField name=\"day2\" label={t('labels.lastPayDayOfTheMonth')} isRequired />\n </div>\n </Flex>\n </div>\n <Flex flexDirection=\"column\" gap={4} justifyContent=\"center\" alignItems=\"center\">\n {payPeriodPreview && payPeriodPreview[selectedPayPeriodIndex] ? (\n <div className={style.calendarContainer}>\n {!payPreviewLoading && (\n <SelectField\n name=\"payPeriodPreviewRange\"\n label={t('labels.preview')}\n options={payPeriodPreview.map((period, index) => {\n return {\n value: String(index),\n label: `${formatDateNamedWeekdayShortPlusDate(period.startDate)} – ${formatDateNamedWeekdayShortPlusDate(period.endDate)}`,\n }\n })}\n defaultValue={String(selectedPayPeriodIndex)}\n onChange={(value: string) => {\n const numericValue = Number(value)\n if (!isNaN(numericValue)) {\n setSelectedPayPeriodIndex(numericValue)\n }\n }}\n />\n )}\n <Components.CalendarPreview\n key={selectedPayPeriodIndex}\n dateRange={{\n start: new Date(payPeriodPreview[selectedPayPeriodIndex].startDate as string),\n end: new Date(payPeriodPreview[selectedPayPeriodIndex].endDate as string),\n label: t('payPreview.payPeriod') || 'Pay Period',\n }}\n highlightDates={[\n {\n date: new Date(payPeriodPreview[selectedPayPeriodIndex].checkDate as string),\n highlightColor: 'primary',\n label: t('payPreview.payday') || 'Payday',\n },\n {\n date: new Date(payPeriodPreview[selectedPayPeriodIndex].runPayrollBy as string),\n highlightColor: 'secondary',\n label: t('payPreview.payrollDeadline') || 'Payroll Deadline',\n },\n ]}\n />\n </div>\n ) : (\n <div className={style.calendarContainer}>\n <Components.Alert\n status=\"info\"\n label={t('previewAlert.title', 'Pay Schedule Preview')}\n >\n <Components.Text>\n {t(\n 'previewAlert.description',\n 'Complete all the required fields on the left to see a preview of your pay schedule.',\n )}\n </Components.Text>\n </Components.Alert>\n </div>\n )}\n </Flex>\n </Grid>\n </div>\n )\n}\n"],"names":["Edit","Components","useComponentContext","t","useTranslation","payPeriodPreview","mode","payPreviewLoading","usePaySchedule","setValue","useFormContext","selectedPayPeriodIndex","setSelectedPayPeriodIndex","useState","frequency","useWatch","customTwicePerMonth","payPeriodPreviewRange","shouldShowDay1","shouldShowDay2","useEffect","jsx","style","jsxs","Grid","Flex","TextInputField","SelectField","RadioGroupField","DatePickerField","NumberInputField","period","index","formatDateNamedWeekdayShortPlusDate","value","numericValue"],"mappings":";;;;;;;;;;;;;;;;AAkBO,MAAMA,IAAO,MAAM;AACxB,QAAMC,IAAaC,EAAoB,GACjC,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5C,EAAE,kBAAAC,GAAkB,MAAAC,GAAM,mBAAAC,EAAA,IAAsBC,EAAe,GAC/D,EAAE,UAAAC,EAAS,IAAIC,EAAkC,GACjD,CAACC,GAAwBC,CAAyB,IAAIC,EAAiB,CAAC,GAExEC,IAAYC,EAAS,EAAE,MAAM,aAAa,GAC1CC,IAAsBD,EAAS,EAAE,MAAM,uBAAuB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A,EAEJ,CAAA;AAAA,MAAA;AAAA,OAEJ,EAEJ,CAAA;AAAA,EAAA,EAAA,CACF,EACF,CAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Edit.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/Edit.tsx"],"sourcesContent":["import { useFormContext, useWatch } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { useEffect, useState } from 'react'\nimport type { PayScheduleInputs } from '../usePaySchedule'\nimport { usePaySchedule } from '../usePaySchedule'\nimport style from './Edit.module.scss'\nimport {\n Flex,\n SelectField,\n RadioGroupField,\n Grid,\n TextInputField,\n NumberInputField,\n DatePickerField,\n} from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { formatDateNamedWeekdayShortPlusDate } from '@/helpers/dateFormatting'\n\nexport const Edit = () => {\n const Components = useComponentContext()\n const { t } = useTranslation('Company.PaySchedule')\n const { payPeriodPreview, mode, payPreviewLoading } = usePaySchedule()\n const { setValue } = useFormContext<PayScheduleInputs>()\n const [selectedPayPeriodIndex, setSelectedPayPeriodIndex] = useState<number>(0)\n\n const frequency = useWatch({ name: 'frequency' })\n const customTwicePerMonth = useWatch({ name: 'customTwicePerMonth' })\n const payPeriodPreviewRange = useWatch({ name: 'payPeriodPreviewRange' })\n\n const shouldShowDay1 =\n (frequency === 'Twice per month' && customTwicePerMonth === 'custom') || frequency === 'Monthly'\n const shouldShowDay2 = frequency === 'Twice per month' && customTwicePerMonth === 'custom'\n\n useEffect(() => {\n if (frequency === 'Twice per month' && customTwicePerMonth === '1st15th') {\n setValue('day1', 15)\n setValue('day2', 31)\n }\n }, [frequency, customTwicePerMonth, setValue])\n\n // This is a workaround to ensure that the pay period preview range is set when the selected pay period index changes\n // TODO: Once we have a RHF free select, that can be used and this effect can be removed\n useEffect(() => {\n if (payPeriodPreviewRange === undefined) {\n setValue('payPeriodPreviewRange', selectedPayPeriodIndex)\n }\n }, [selectedPayPeriodIndex, setValue, payPeriodPreviewRange])\n\n if (mode !== 'EDIT_PAY_SCHEDULE' && mode !== 'ADD_PAY_SCHEDULE') {\n return null\n }\n\n return (\n <div className={style.payScheduleContainer}>\n <Grid gap={32} gridTemplateColumns={{ base: '1fr', small: '1fr 1fr' }}>\n <div className={style.payScheduleForm}>\n <Flex flexDirection={'column'}>\n <TextInputField name=\"customName\" label=\"Name\" isRequired />\n <SelectField\n name=\"frequency\"\n label={t('labels.frequency')}\n options={[\n { value: 'Every week', label: t('frequencies.everyWeek') },\n { value: 'Every other week', label: t('frequencies.everyOtherWeek') },\n { value: 'Twice per month', label: t('frequencies.twicePerMonth') },\n { value: 'Monthly', label: t('frequencies.monthly') },\n ]}\n isRequired\n />\n {frequency === 'Twice per month' && (\n <RadioGroupField\n name=\"customTwicePerMonth\"\n label={t('labels.frequencyOptions')}\n description={t('descriptions.frequencyOptionsDescription')}\n options={[\n { value: '1st15th', label: t('frequencyOptions.15thAndLast') },\n { value: 'custom', label: t('frequencyOptions.custom') },\n ]}\n />\n )}\n <DatePickerField\n name=\"anchorPayDate\"\n label={t('labels.firstPayDate')}\n description={t('descriptions.anchorPayDateDescription')}\n isRequired\n />\n <DatePickerField\n name=\"anchorEndOfPayPeriod\"\n label={t('labels.firstPayPeriodEndDate')}\n description={t('descriptions.anchorEndOfPayPeriodDescription')}\n isRequired\n />\n <div className={shouldShowDay1 ? '' : style.visuallyHidden}>\n <NumberInputField name=\"day1\" label={t('labels.firstPayDayOfTheMonth')} isRequired />\n </div>\n <div className={shouldShowDay2 ? '' : style.visuallyHidden}>\n <NumberInputField name=\"day2\" label={t('labels.lastPayDayOfTheMonth')} isRequired />\n </div>\n </Flex>\n </div>\n <Flex flexDirection=\"column\" gap={4} justifyContent=\"center\" alignItems=\"center\">\n {payPeriodPreview && payPeriodPreview[selectedPayPeriodIndex] ? (\n <div className={style.calendarContainer}>\n {!payPreviewLoading && (\n <SelectField\n name=\"payPeriodPreviewRange\"\n label={t('labels.preview')}\n options={payPeriodPreview.map((period, index) => {\n return {\n value: String(index),\n label: `${formatDateNamedWeekdayShortPlusDate(period.startDate)} – ${formatDateNamedWeekdayShortPlusDate(period.endDate)}`,\n }\n })}\n defaultValue={String(selectedPayPeriodIndex)}\n onChange={(value: string) => {\n const numericValue = Number(value)\n if (!isNaN(numericValue)) {\n setSelectedPayPeriodIndex(numericValue)\n }\n }}\n />\n )}\n <Components.CalendarPreview\n key={selectedPayPeriodIndex}\n dateRange={{\n start: new Date(payPeriodPreview[selectedPayPeriodIndex].startDate as string),\n end: new Date(payPeriodPreview[selectedPayPeriodIndex].endDate as string),\n label: t('payPreview.payPeriod') || 'Pay Period',\n }}\n highlightDates={[\n {\n date: new Date(payPeriodPreview[selectedPayPeriodIndex].checkDate as string),\n highlightColor: 'primary',\n label: t('payPreview.payday') || 'Payday',\n },\n {\n date: new Date(payPeriodPreview[selectedPayPeriodIndex].runPayrollBy as string),\n highlightColor: 'secondary',\n label: t('payPreview.payrollDeadline') || 'Payroll Deadline',\n },\n ]}\n />\n </div>\n ) : (\n <div className={style.calendarContainer}>\n <Components.Alert\n status=\"info\"\n label={t('previewAlert.title', 'Pay Schedule Preview')}\n >\n <Components.Text>\n {t(\n 'previewAlert.description',\n 'Complete all the required fields on the left to see a preview of your pay schedule.',\n )}\n </Components.Text>\n </Components.Alert>\n </div>\n )}\n </Flex>\n </Grid>\n </div>\n )\n}\n"],"names":["Edit","Components","useComponentContext","t","useTranslation","payPeriodPreview","mode","payPreviewLoading","usePaySchedule","setValue","useFormContext","selectedPayPeriodIndex","setSelectedPayPeriodIndex","useState","frequency","useWatch","customTwicePerMonth","payPeriodPreviewRange","shouldShowDay1","shouldShowDay2","useEffect","jsx","style","jsxs","Grid","Flex","TextInputField","SelectField","RadioGroupField","DatePickerField","NumberInputField","period","index","formatDateNamedWeekdayShortPlusDate","value","numericValue"],"mappings":";;;;;;;;;;;;;;;AAkBO,MAAMA,IAAO,MAAM;AACxB,QAAMC,IAAaC,EAAoB,GACjC,EAAE,G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AA,MAAA;AAAA,IAkBP,GACF,IAEA,gBAAAU,EAAC,OAAI,EAAA,WAAWC,EAAM,mBACpB,UAAA,gBAAAD;AAAA,MAACpB,EAAW;AAAA,MAAX;AAAA,QACC,QAAO;AAAA,QACP,OAAOE,EAAE,sBAAsB,sBAAsB;AAAA,QAErD,UAAA,gBAAAkB,EAACpB,EAAW,MAAX,EACE,UAAAE;AAAA,UACC;AAAA,UACA;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,OAEJ,EAEJ,CAAA;AAAA,EAAA,EAAA,CACF,EACF,CAAA;AAEJ;"}
|
|
@@ -2,9 +2,8 @@ import { jsx as e, jsxs as r, Fragment as o } from "react/jsx-runtime";
|
|
|
2
2
|
import { useTranslation as c, Trans as a } from "react-i18next";
|
|
3
3
|
import { usePaySchedule as d } from "../usePaySchedule.js";
|
|
4
4
|
import { Flex as h } from "../../../Common/Flex/Flex.js";
|
|
5
|
-
import "classnames";
|
|
6
5
|
import { useComponentContext as l } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
|
-
const
|
|
6
|
+
const y = () => {
|
|
8
7
|
const { t } = c("Company.PaySchedule"), n = l(), { mode: s } = d();
|
|
9
8
|
let i = /* @__PURE__ */ e(o, {});
|
|
10
9
|
switch (s) {
|
|
@@ -43,6 +42,6 @@ const D = () => {
|
|
|
43
42
|
return /* @__PURE__ */ e(h, { justifyContent: "space-between", flexDirection: "column", gap: 4, children: /* @__PURE__ */ e("header", { children: i }) });
|
|
44
43
|
};
|
|
45
44
|
export {
|
|
46
|
-
|
|
45
|
+
y as Head
|
|
47
46
|
};
|
|
48
47
|
//# sourceMappingURL=Head.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Head.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/Head.tsx"],"sourcesContent":["import { Trans, useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport { Flex } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\n// Head slot for PaySchedule component\nexport const Head = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const Components = useComponentContext()\n\n const { mode } = usePaySchedule()\n let headingOutput: React.ReactElement = <></>\n\n switch (mode) {\n case 'LIST_PAY_SCHEDULES':\n headingOutput = (\n <>\n <Components.Heading as=\"h2\">{t('headings.pageTitle')}</Components.Heading>\n <Components.Text>\n <Trans\n i18nKey={'listDescription'}\n t={t}\n components={{\n how_to_choose_schedule: <Components.Link />,\n }}\n />\n </Components.Text>\n <Components.Text>\n <Trans\n i18nKey={'listDescription2'}\n t={t}\n components={{\n payment_law_doc: <Components.Link />,\n }}\n />\n </Components.Text>\n </>\n )\n break\n case 'ADD_PAY_SCHEDULE':\n headingOutput = (\n <Components.Heading as=\"h2\">{t('headings.addPaySchedule')}</Components.Heading>\n )\n break\n case 'EDIT_PAY_SCHEDULE':\n headingOutput = (\n <Components.Heading as=\"h2\">{t('headings.editPaySchedule')}</Components.Heading>\n )\n break\n default:\n }\n\n return (\n <Flex justifyContent=\"space-between\" flexDirection={'column'} gap={4}>\n <header>{headingOutput}</header>\n </Flex>\n )\n}\n"],"names":["Head","useTranslation","Components","useComponentContext","mode","usePaySchedule","headingOutput","jsx","Fragment","jsxs","Trans","Flex"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Head.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/Head.tsx"],"sourcesContent":["import { Trans, useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport { Flex } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\n// Head slot for PaySchedule component\nexport const Head = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const Components = useComponentContext()\n\n const { mode } = usePaySchedule()\n let headingOutput: React.ReactElement = <></>\n\n switch (mode) {\n case 'LIST_PAY_SCHEDULES':\n headingOutput = (\n <>\n <Components.Heading as=\"h2\">{t('headings.pageTitle')}</Components.Heading>\n <Components.Text>\n <Trans\n i18nKey={'listDescription'}\n t={t}\n components={{\n how_to_choose_schedule: <Components.Link />,\n }}\n />\n </Components.Text>\n <Components.Text>\n <Trans\n i18nKey={'listDescription2'}\n t={t}\n components={{\n payment_law_doc: <Components.Link />,\n }}\n />\n </Components.Text>\n </>\n )\n break\n case 'ADD_PAY_SCHEDULE':\n headingOutput = (\n <Components.Heading as=\"h2\">{t('headings.addPaySchedule')}</Components.Heading>\n )\n break\n case 'EDIT_PAY_SCHEDULE':\n headingOutput = (\n <Components.Heading as=\"h2\">{t('headings.editPaySchedule')}</Components.Heading>\n )\n break\n default:\n }\n\n return (\n <Flex justifyContent=\"space-between\" flexDirection={'column'} gap={4}>\n <header>{headingOutput}</header>\n </Flex>\n )\n}\n"],"names":["Head","useTranslation","Components","useComponentContext","mode","usePaySchedule","headingOutput","jsx","Fragment","jsxs","Trans","Flex"],"mappings":";;;;;AAMO,MAAMA,IAAO,MAAM;AACxB,QAAM,EAAE,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAoB,GAEjC,EAAE,MAAAC,EAAK,IAAIC,EAAe;AAChC,MAAIC,IAAsC,gBAAAC,EAAAC,GAAA,EAAA;AAE1C,UAAQJ,GAAM;AAAA,IACZ,KAAK;AACH,MAAAE,IAEI,gBAAAG,EAAAD,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAD,EAACL,EAAW,SAAX,EAAmB,IAAG,MAAM,UAAA,EAAE,oBAAoB,GAAE;AAAA,QACrD,gBAAAK,EAACL,EAAW,MAAX,EACC,UAAA,gBAAAK;AAAA,UAACG;AAAA,UAAA;AAAA,YACC,SAAS;AAAA,YACT;AAAA,YACA,YAAY;AAAA,cACV,wBAAwB,gBAAAH,EAACL,EAAW,MAAX,CAAgB,CAAA;AAAA,YAAA;AAAA,UAC3C;AAAA,QAAA,GAEJ;AAAA,QACA,gBAAAK,EAACL,EAAW,MAAX,EACC,UAAA,gBAAAK;AAAA,UAACG;AAAA,UAAA;AAAA,YACC,SAAS;AAAA,YACT;AAAA,YACA,YAAY;AAAA,cACV,iBAAiB,gBAAAH,EAACL,EAAW,MAAX,CAAgB,CAAA;AAAA,YAAA;AAAA,UACpC;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA,GACF;AAEF;AAAA,IACF,KAAK;AAED,MAAAI,IAAA,gBAAAC,EAACL,EAAW,SAAX,EAAmB,IAAG,MAAM,UAAA,EAAE,yBAAyB,GAAE;AAE5D;AAAA,IACF,KAAK;AAED,MAAAI,IAAA,gBAAAC,EAACL,EAAW,SAAX,EAAmB,IAAG,MAAM,UAAA,EAAE,0BAA0B,GAAE;AAE7D;AAAA,EACF;AAIA,SAAA,gBAAAK,EAACI,GAAK,EAAA,gBAAe,iBAAgB,eAAe,UAAU,KAAK,GACjE,UAAA,gBAAAJ,EAAC,UAAQ,EAAA,UAAAD,EAAc,CAAA,GACzB;AAEJ;"}
|
|
@@ -3,16 +3,15 @@ import { useTranslation as h } from "react-i18next";
|
|
|
3
3
|
import { usePaySchedule as y } from "../usePaySchedule.js";
|
|
4
4
|
import o from "./List.module.scss.js";
|
|
5
5
|
import { Flex as s } from "../../../Common/Flex/Flex.js";
|
|
6
|
-
import "classnames";
|
|
7
6
|
import f from "../../../../assets/icons/pencil.svg.js";
|
|
8
7
|
import { useComponentContext as S } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
9
8
|
import { HamburgerMenu as v } from "../../../Common/HamburgerMenu/HamburgerMenu.js";
|
|
10
9
|
import { VisuallyHidden as g } from "../../../Common/VisuallyHidden/VisuallyHidden.js";
|
|
11
10
|
import { useDataView as L } from "../../../Common/DataView/useDataView.js";
|
|
12
11
|
import { DataView as C } from "../../../Common/DataView/DataView.js";
|
|
13
|
-
const
|
|
14
|
-
const { t: n } = h("Company.PaySchedule"), r = S(), { paySchedules:
|
|
15
|
-
data:
|
|
12
|
+
const H = () => {
|
|
13
|
+
const { t: n } = h("Company.PaySchedule"), r = S(), { paySchedules: c, mode: m, handleEdit: l } = y(), { ...d } = L({
|
|
14
|
+
data: c || [],
|
|
16
15
|
columns: [
|
|
17
16
|
{
|
|
18
17
|
title: n("payScheduleList.name"),
|
|
@@ -50,9 +49,9 @@ const B = () => {
|
|
|
50
49
|
}
|
|
51
50
|
)
|
|
52
51
|
});
|
|
53
|
-
return
|
|
52
|
+
return m !== "LIST_PAY_SCHEDULES" ? null : /* @__PURE__ */ e(C, { label: "test", ...d });
|
|
54
53
|
};
|
|
55
54
|
export {
|
|
56
|
-
|
|
55
|
+
H as List
|
|
57
56
|
};
|
|
58
57
|
//# sourceMappingURL=List.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport styles from './List.module.scss'\nimport { useDataView, DataView, Flex, VisuallyHidden } from '@/components/Common'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\n\nexport const List = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const Components = useComponentContext()\n const { paySchedules, mode, handleEdit } = usePaySchedule()\n\n const { ...dataViewProps } = useDataView({\n data: paySchedules || [],\n columns: [\n {\n title: t('payScheduleList.name'),\n key: 'customName',\n render: schedule => {\n const hasName = !!schedule.name\n let displayName = hasName ? schedule.name : schedule.customName\n if (displayName && displayName.length > 1) {\n displayName = displayName.charAt(0).toUpperCase() + displayName.slice(1)\n } else {\n displayName = schedule.customName\n }\n const displayFrequency = schedule.customName\n return (\n <Flex flexDirection={'column'} gap={0}>\n <div className={styles.content}>\n <div>{displayName}</div>\n {hasName && <div>{displayFrequency}</div>}\n </div>\n </Flex>\n )\n },\n },\n {\n title: <VisuallyHidden>{t('payScheduleList.active')}</VisuallyHidden>,\n key: 'active',\n render: schedule => (\n <Flex alignItems={'center'} justifyContent={'center'}>\n <div className={styles.content}>\n {schedule.active ? (\n <Components.Badge status=\"success\">{t('payScheduleList.active')}</Components.Badge>\n ) : (\n <Components.Badge status=\"info\">{t('payScheduleList.inactive')}</Components.Badge>\n )}\n </div>\n </Flex>\n ),\n },\n ],\n itemMenu: schedule => {\n return (\n <HamburgerMenu\n triggerLabel=\"Actions\"\n items={[\n {\n label: t('payScheduleList.edit'),\n onClick: () => {\n handleEdit(schedule)\n },\n icon: <PencilSvg aria-hidden />,\n },\n ]}\n />\n )\n },\n })\n\n if (mode !== 'LIST_PAY_SCHEDULES') {\n return null\n }\n\n return <DataView label=\"test\" {...dataViewProps} />\n}\n"],"names":["List","t","useTranslation","Components","useComponentContext","paySchedules","mode","handleEdit","usePaySchedule","dataViewProps","useDataView","schedule","hasName","displayName","displayFrequency","jsx","Flex","jsxs","styles","VisuallyHidden","HamburgerMenu","PencilSvg","DataView"],"mappings":"
|
|
1
|
+
{"version":3,"file":"List.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport styles from './List.module.scss'\nimport { useDataView, DataView, Flex, VisuallyHidden } from '@/components/Common'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\n\nexport const List = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const Components = useComponentContext()\n const { paySchedules, mode, handleEdit } = usePaySchedule()\n\n const { ...dataViewProps } = useDataView({\n data: paySchedules || [],\n columns: [\n {\n title: t('payScheduleList.name'),\n key: 'customName',\n render: schedule => {\n const hasName = !!schedule.name\n let displayName = hasName ? schedule.name : schedule.customName\n if (displayName && displayName.length > 1) {\n displayName = displayName.charAt(0).toUpperCase() + displayName.slice(1)\n } else {\n displayName = schedule.customName\n }\n const displayFrequency = schedule.customName\n return (\n <Flex flexDirection={'column'} gap={0}>\n <div className={styles.content}>\n <div>{displayName}</div>\n {hasName && <div>{displayFrequency}</div>}\n </div>\n </Flex>\n )\n },\n },\n {\n title: <VisuallyHidden>{t('payScheduleList.active')}</VisuallyHidden>,\n key: 'active',\n render: schedule => (\n <Flex alignItems={'center'} justifyContent={'center'}>\n <div className={styles.content}>\n {schedule.active ? (\n <Components.Badge status=\"success\">{t('payScheduleList.active')}</Components.Badge>\n ) : (\n <Components.Badge status=\"info\">{t('payScheduleList.inactive')}</Components.Badge>\n )}\n </div>\n </Flex>\n ),\n },\n ],\n itemMenu: schedule => {\n return (\n <HamburgerMenu\n triggerLabel=\"Actions\"\n items={[\n {\n label: t('payScheduleList.edit'),\n onClick: () => {\n handleEdit(schedule)\n },\n icon: <PencilSvg aria-hidden />,\n },\n ]}\n />\n )\n },\n })\n\n if (mode !== 'LIST_PAY_SCHEDULES') {\n return null\n }\n\n return <DataView label=\"test\" {...dataViewProps} />\n}\n"],"names":["List","t","useTranslation","Components","useComponentContext","paySchedules","mode","handleEdit","usePaySchedule","dataViewProps","useDataView","schedule","hasName","displayName","displayFrequency","jsx","Flex","jsxs","styles","VisuallyHidden","HamburgerMenu","PencilSvg","DataView"],"mappings":";;;;;;;;;;;AAQO,MAAMA,IAAO,MAAM;AACxB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAoB,GACjC,EAAE,cAAAC,GAAc,MAAAC,GAAM,YAAAC,EAAA,IAAeC,EAAe,GAEpD,EAAE,GAAGC,EAAc,IAAIC,EAAY;AAAA,IACvC,MAAML,KAAgB,CAAC;AAAA,IACvB,SAAS;AAAA,MACP;AAAA,QACE,OAAOJ,EAAE,sBAAsB;AAAA,QAC/B,KAAK;AAAA,QACL,QAAQ,CAAYU,MAAA;AACZ,gBAAAC,IAAU,CAAC,CAACD,EAAS;AAC3B,cAAIE,IAAcD,IAAUD,EAAS,OAAOA,EAAS;AACjD,UAAAE,K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AAIf,MAAS,uBACJ,OAGD,gBAAAS,EAAAO,GAAA,EAAS,OAAM,QAAQ,GAAGb,GAAe;AACnD;"}
|
|
@@ -9,9 +9,9 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
9
9
|
import "@tanstack/react-query";
|
|
10
10
|
import "../../Base/useBase.js";
|
|
11
11
|
import "../../../shared/constants.js";
|
|
12
|
-
import "classnames";
|
|
13
12
|
import "dompurify";
|
|
14
13
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
|
+
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
15
15
|
import { createCompoundContext as e } from "../../Base/createCompoundContext.js";
|
|
16
16
|
const w = o.object({
|
|
17
17
|
frequency: o.enum(["Every week", "Every other week", "Twice per month", "Monthly"]),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as i, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as a } from "react-i18next";
|
|
3
3
|
import { useStateTaxesForm as s } from "./context.js";
|
|
4
|
-
import "
|
|
4
|
+
import "../../../../shared/constants.js";
|
|
5
5
|
import { ActionsLayout as m } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
6
6
|
import { useComponentContext as c } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
7
|
function x() {
|
|
@@ -3,7 +3,7 @@ import { useForm as K, FormProvider as M } from "react-hook-form";
|
|
|
3
3
|
import { zodResolver as w } from "@hookform/resolvers/zod";
|
|
4
4
|
import { useTaxRequirementsUpdateStateMutation as z } from "@gusto/embedded-api/react-query/taxRequirementsUpdateState";
|
|
5
5
|
import { useTaxRequirementsGetSuspense as G } from "@gusto/embedded-api/react-query/taxRequirementsGet";
|
|
6
|
-
import { z as
|
|
6
|
+
import { z as a } from "zod";
|
|
7
7
|
import { useMemo as L } from "react";
|
|
8
8
|
import { useTranslation as X } from "react-i18next";
|
|
9
9
|
import { Head as A } from "./Head.js";
|
|
@@ -16,12 +16,12 @@ import { Flex as J } from "../../../Common/Flex/Flex.js";
|
|
|
16
16
|
import { Form as Q } from "../../../Common/Form/Form.js";
|
|
17
17
|
import { componentEvents as k } from "../../../../shared/constants.js";
|
|
18
18
|
import { useBase as W } from "../../../Base/useBase.js";
|
|
19
|
-
function x(
|
|
20
|
-
return /* @__PURE__ */ t($, { ...
|
|
19
|
+
function x(n) {
|
|
20
|
+
return /* @__PURE__ */ t($, { ...n, children: /* @__PURE__ */ t(Z, { ...n, children: n.children }) });
|
|
21
21
|
}
|
|
22
|
-
function Z({ companyId:
|
|
22
|
+
function Z({ companyId: n, state: S, className: q, children: v }) {
|
|
23
23
|
I("Company.StateTaxes");
|
|
24
|
-
const { onEvent: F, baseSubmitHandler: C } = W(), { t: l } = X("Company.StateTaxes", { keyPrefix: "form" }), { data: E } = G({ companyUuid:
|
|
24
|
+
const { onEvent: F, baseSubmitHandler: C } = W(), { t: l } = X("Company.StateTaxes", { keyPrefix: "form" }), { data: E } = G({ companyUuid: n, state: S }), f = E.taxRequirementsState, { mutateAsync: N, isPending: R } = z(), { dynamicSchema: V, defaultValues: O } = L(() => {
|
|
25
25
|
const d = {}, i = {};
|
|
26
26
|
return f.requirementSets?.forEach((e) => {
|
|
27
27
|
if (!e.key) return;
|
|
@@ -29,26 +29,26 @@ function Z({ companyId: a, state: S, className: q, children: v }) {
|
|
|
29
29
|
e.requirements?.forEach((o) => {
|
|
30
30
|
if (!o.key) return;
|
|
31
31
|
const g = o.key;
|
|
32
|
-
p[g] =
|
|
33
|
-
let y =
|
|
32
|
+
p[g] = o.value ?? "";
|
|
33
|
+
let y = a.string().min(1);
|
|
34
34
|
const c = o.metadata?.validation;
|
|
35
35
|
if (c && o.metadata?.type === "tax_rate")
|
|
36
36
|
if (c.type === "min_max") {
|
|
37
37
|
const r = parseFloat(c.min), u = parseFloat(c.max);
|
|
38
|
-
!isNaN(r) && !isNaN(u) && (y =
|
|
38
|
+
!isNaN(r) && !isNaN(u) && (y = a.preprocess(
|
|
39
39
|
(h) => Number(h),
|
|
40
|
-
|
|
40
|
+
a.number().min(r, l("validations.minValue", { min: r })).max(u, l("validations.maxValue", { max: u })).transform((h) => String(h))
|
|
41
41
|
));
|
|
42
42
|
} else {
|
|
43
43
|
const r = c.rates;
|
|
44
|
-
y =
|
|
44
|
+
y = a.string().min(1).refine((u) => r.includes(u), {
|
|
45
45
|
message: l("validations.oneOf", { values: r.join(", ") })
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
o.metadata?.type === "radio" && (y =
|
|
49
|
-
}), Object.keys(s).length > 0 && (d[m] =
|
|
48
|
+
o.metadata?.type === "radio" && (y = a.boolean()), s[g] = y;
|
|
49
|
+
}), Object.keys(s).length > 0 && (d[m] = a.object(s), i[m] = p);
|
|
50
50
|
}), {
|
|
51
|
-
dynamicSchema:
|
|
51
|
+
dynamicSchema: a.object(d),
|
|
52
52
|
defaultValues: i
|
|
53
53
|
};
|
|
54
54
|
}, [f, l]), { control: U, ...T } = K({
|
|
@@ -70,7 +70,7 @@ function Z({ companyId: a, state: S, className: q, children: v }) {
|
|
|
70
70
|
});
|
|
71
71
|
await N({
|
|
72
72
|
request: {
|
|
73
|
-
companyUuid:
|
|
73
|
+
companyUuid: n,
|
|
74
74
|
requestBody: { requirementSets: b },
|
|
75
75
|
state: S
|
|
76
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTaxesForm.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTaxRequirementsUpdateStateMutation } from '@gusto/embedded-api/react-query/taxRequirementsUpdateState'\nimport { useTaxRequirementsGetSuspense } from '@gusto/embedded-api/react-query/taxRequirementsGet'\nimport { z } from 'zod'\nimport { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { Head } from './Head'\nimport { StateTaxesFormProvider } from './context'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { componentEvents } from '@/shared/constants'\nimport { useBase } from '@/components/Base'\n\ninterface StateTaxesFormProps extends CommonComponentInterface {\n companyId: string\n state: string\n}\n\nexport function StateTaxesForm(props: StateTaxesFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, state, className, children }: StateTaxesFormProps) {\n useI18n('Company.StateTaxes')\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { data } = useTaxRequirementsGetSuspense({ companyUuid: companyId, state })\n const stateTaxRequirements = data.taxRequirementsState!\n\n const { mutateAsync: updateStateTax, isPending: isPendingUpdate } =\n useTaxRequirementsUpdateStateMutation()\n\n // Schema and default value generation\n const { dynamicSchema, defaultValues } = useMemo(() => {\n const schemaShape: Record<string, z.ZodObject<Record<string, z.ZodTypeAny>>> = {}\n const values: Partial<Record<string, Record<string, string>>> = {}\n\n //Looping through each requirement set\n stateTaxRequirements.requirementSets?.forEach(requirementSet => {\n if (!requirementSet.key) return\n\n const requirementSetKey = requirementSet.key\n const requirementShape: Record<string, z.ZodTypeAny> = {}\n const requirementValues: Record<string, string> = {}\n\n requirementSet.requirements?.forEach(requirement => {\n if (!requirement.key) return\n\n const requirementKey = requirement.key\n\n // --- Default Value Logic ---\n requirementValues[requirementKey] = String(requirement.value ?? '')\n\n // --- Schema Logic ---\n // Start with a basic string schema\n let fieldSchema: z.ZodTypeAny = z.string().min(1)\n\n const validation = requirement.metadata?.validation\n // Not all requirements have validation\n if (validation) {\n if (requirement.metadata?.type === 'tax_rate') {\n if (validation.type === 'min_max') {\n const min = parseFloat(validation.min as string)\n const max = parseFloat(validation.max as string)\n\n if (!isNaN(min) && !isNaN(max)) {\n fieldSchema = z.preprocess(\n val => Number(val),\n z\n .number()\n .min(min, t('validations.minValue', { min }))\n .max(max, t('validations.maxValue', { max }))\n .transform(num => String(num)),\n )\n }\n } else {\n //Type is one_of\n const oneOfValues = validation.rates as string[]\n fieldSchema = z\n .string()\n .min(1)\n .refine(val => oneOfValues.includes(val), {\n message: t('validations.oneOf', { values: oneOfValues.join(', ') }),\n })\n }\n }\n }\n if (requirement.metadata?.type === 'radio') {\n fieldSchema = z.boolean()\n }\n requirementShape[requirementKey] = fieldSchema\n // --- End Schema Logic ---\n })\n\n if (Object.keys(requirementShape).length > 0) {\n schemaShape[requirementSetKey] = z.object(requirementShape)\n values[requirementSetKey] = requirementValues\n }\n })\n\n const finalSchema = z.object(schemaShape)\n\n // Return both the schema and the default values\n return {\n dynamicSchema: finalSchema,\n defaultValues: values as z.infer<typeof finalSchema>,\n }\n }, [stateTaxRequirements, t])\n\n // Infer the type from the schema\n type InferredFormInputs = z.infer<typeof dynamicSchema>\n\n const { control, ...methods } = useForm<InferredFormInputs>({\n resolver: zodResolver(dynamicSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InferredFormInputs) => {\n await baseSubmitHandler(formData, async payload => {\n const requirementSets = stateTaxRequirements.requirementSets\n ?.filter(rs => rs.key && payload[rs.key])\n .map(requirementSet => {\n const requirementSetKey = requirementSet.key as string\n const payloadSet = payload[requirementSetKey] as Record<string, unknown>\n return {\n state: requirementSet.state,\n key: requirementSetKey,\n effectiveFrom: requirementSet.effectiveFrom,\n requirements: Object.entries(payloadSet).map(([key, value]) => ({\n key,\n value: String(value),\n })),\n }\n })\n await updateStateTax({\n request: {\n companyUuid: companyId,\n requestBody: { requirementSets },\n state,\n },\n })\n onEvent(componentEvents.COMPANY_STATE_TAX_UPDATED)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <StateTaxesFormProvider\n value={{ stateTaxRequirements, isPending: isPendingUpdate, state, handleCancel }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </StateTaxesFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n\nStateTaxesForm.Head = Head\nStateTaxesForm.Form = Form\nStateTaxesForm.Actions = Actions\n"],"names":["StateTaxesForm","props","jsx","BaseComponent","Root","companyId","state","className","children","useI18n","onEvent","baseSubmitHandler","useBase","t","useTranslation","data","useTaxRequirementsGetSuspense","stateTaxRequirements","updateStateTax","isPendingUpdate","useTaxRequirementsUpdateStateMutation","dynamicSchema","defaultValues","useMemo","schemaShape","values","requirementSet","requirementSetKey","requirementShape","requirementValues","requirement","requirementKey","fieldSchema","z","validation","min","max","val","num","oneOfValues","control","methods","useForm","zodResolver","onSubmit","formData","payload","requirementSets","rs","payloadSet","key","value","componentEvents","handleCancel","FormProvider","HtmlForm","StateTaxesFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,SAASA,EAAeC,GAAqD;AAEhF,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,OAAAC,GAAO,WAAAC,GAAW,UAAAC,KAAiC;AAC5E,EAAAC,EAAQ,oBAAoB;AAC5B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,MAAAC,MAASC,EAA8B,EAAE,aAAaX,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zC;AAAA,QAAA;AAAA,MACF,CACD,GACDI,EAAQ0C,EAAgB,yBAAyB;AAAA,IAAA,CAClD;AAAA,EACH,GAEMC,IAAe,MAAM;AACzB,IAAA3C,EAAQ0C,EAAgB,MAAM;AAAA,EAChC;AAEA,SACG,gBAAAlD,EAAA,WAAA,EAAQ,WAAAK,GACP,UAAA,gBAAAL,EAACoD,KAAc,GAAGb,GAAS,SAAAD,GACzB,UAAA,gBAAAtC,EAACqD,GAAS,EAAA,UAAUd,EAAQ,aAAaG,CAAQ,GAC/C,UAAA,gBAAA1C;AAAA,IAACsD;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,sBAAAvC,GAAsB,WAAWE,GAAiB,OAAAb,GAAO,cAAA+C,EAAa;AAAA,MAE/E,UAAA,gBAAAnD,EAACuD,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAAjD,KAIG,gBAAAkD,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAzD,EAAC0D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,EAAA,CACX,EAEJ,CAAA;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA,GACF;AAEJ;AAEA9D,EAAe,OAAO4D;AACtB5D,EAAe,OAAO6D;AACtB7D,EAAe,UAAU8D;"}
|
|
1
|
+
{"version":3,"file":"StateTaxesForm.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTaxRequirementsUpdateStateMutation } from '@gusto/embedded-api/react-query/taxRequirementsUpdateState'\nimport { useTaxRequirementsGetSuspense } from '@gusto/embedded-api/react-query/taxRequirementsGet'\nimport { z } from 'zod'\nimport { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { Head } from './Head'\nimport { StateTaxesFormProvider } from './context'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { componentEvents } from '@/shared/constants'\nimport { useBase } from '@/components/Base'\n\ninterface StateTaxesFormProps extends CommonComponentInterface {\n companyId: string\n state: string\n}\n\nexport function StateTaxesForm(props: StateTaxesFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, state, className, children }: StateTaxesFormProps) {\n useI18n('Company.StateTaxes')\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { data } = useTaxRequirementsGetSuspense({ companyUuid: companyId, state })\n const stateTaxRequirements = data.taxRequirementsState!\n\n const { mutateAsync: updateStateTax, isPending: isPendingUpdate } =\n useTaxRequirementsUpdateStateMutation()\n\n // Schema and default value generation\n const { dynamicSchema, defaultValues } = useMemo(() => {\n const schemaShape: Record<string, z.ZodObject<Record<string, z.ZodTypeAny>>> = {}\n const values: Partial<Record<string, Record<string, string | boolean>>> = {}\n\n //Looping through each requirement set\n stateTaxRequirements.requirementSets?.forEach(requirementSet => {\n if (!requirementSet.key) return\n\n const requirementSetKey = requirementSet.key\n const requirementShape: Record<string, z.ZodTypeAny> = {}\n const requirementValues: Record<string, string | boolean> = {}\n\n requirementSet.requirements?.forEach(requirement => {\n if (!requirement.key) return\n\n const requirementKey = requirement.key\n\n // --- Default Value Logic ---\n requirementValues[requirementKey] = requirement.value ?? ''\n\n // --- Schema Logic ---\n // Start with a basic string schema\n let fieldSchema: z.ZodTypeAny = z.string().min(1)\n\n const validation = requirement.metadata?.validation\n // Not all requirements have validation\n if (validation) {\n if (requirement.metadata?.type === 'tax_rate') {\n if (validation.type === 'min_max') {\n const min = parseFloat(validation.min as string)\n const max = parseFloat(validation.max as string)\n\n if (!isNaN(min) && !isNaN(max)) {\n fieldSchema = z.preprocess(\n val => Number(val),\n z\n .number()\n .min(min, t('validations.minValue', { min }))\n .max(max, t('validations.maxValue', { max }))\n .transform(num => String(num)),\n )\n }\n } else {\n //Type is one_of\n const oneOfValues = validation.rates as string[]\n fieldSchema = z\n .string()\n .min(1)\n .refine(val => oneOfValues.includes(val), {\n message: t('validations.oneOf', { values: oneOfValues.join(', ') }),\n })\n }\n }\n }\n if (requirement.metadata?.type === 'radio') {\n fieldSchema = z.boolean()\n }\n requirementShape[requirementKey] = fieldSchema\n // --- End Schema Logic ---\n })\n\n if (Object.keys(requirementShape).length > 0) {\n schemaShape[requirementSetKey] = z.object(requirementShape)\n values[requirementSetKey] = requirementValues\n }\n })\n\n const finalSchema = z.object(schemaShape)\n\n // Return both the schema and the default values\n return {\n dynamicSchema: finalSchema,\n defaultValues: values as z.infer<typeof finalSchema>,\n }\n }, [stateTaxRequirements, t])\n\n // Infer the type from the schema\n type InferredFormInputs = z.infer<typeof dynamicSchema>\n\n const { control, ...methods } = useForm<InferredFormInputs>({\n resolver: zodResolver(dynamicSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InferredFormInputs) => {\n await baseSubmitHandler(formData, async payload => {\n const requirementSets = stateTaxRequirements.requirementSets\n ?.filter(rs => rs.key && payload[rs.key])\n .map(requirementSet => {\n const requirementSetKey = requirementSet.key as string\n const payloadSet = payload[requirementSetKey] as Record<string, unknown>\n return {\n state: requirementSet.state,\n key: requirementSetKey,\n effectiveFrom: requirementSet.effectiveFrom,\n requirements: Object.entries(payloadSet).map(([key, value]) => ({\n key,\n value: String(value),\n })),\n }\n })\n await updateStateTax({\n request: {\n companyUuid: companyId,\n requestBody: { requirementSets },\n state,\n },\n })\n onEvent(componentEvents.COMPANY_STATE_TAX_UPDATED)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <StateTaxesFormProvider\n value={{ stateTaxRequirements, isPending: isPendingUpdate, state, handleCancel }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </StateTaxesFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n\nStateTaxesForm.Head = Head\nStateTaxesForm.Form = Form\nStateTaxesForm.Actions = Actions\n"],"names":["StateTaxesForm","props","jsx","BaseComponent","Root","companyId","state","className","children","useI18n","onEvent","baseSubmitHandler","useBase","t","useTranslation","data","useTaxRequirementsGetSuspense","stateTaxRequirements","updateStateTax","isPendingUpdate","useTaxRequirementsUpdateStateMutation","dynamicSchema","defaultValues","useMemo","schemaShape","values","requirementSet","requirementSetKey","requirementShape","requirementValues","requirement","requirementKey","fieldSchema","z","validation","min","max","val","num","oneOfValues","control","methods","useForm","zodResolver","onSubmit","formData","payload","requirementSets","rs","payloadSet","key","value","componentEvents","handleCancel","FormProvider","HtmlForm","StateTaxesFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,SAASA,EAAeC,GAAqD;AAEhF,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,OAAAC,GAAO,WAAAC,GAAW,UAAAC,KAAiC;AAC5E,EAAAC,EAAQ,oBAAoB;AAC5B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,MAAAC,MAASC,EAA8B,EAAE,aAAaX,GAA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AA,MACF,CACD,GACDI,EAAQ0C,EAAgB,yBAAyB;AAAA,IAAA,CAClD;AAAA,EACH,GAEMC,IAAe,MAAM;AACzB,IAAA3C,EAAQ0C,EAAgB,MAAM;AAAA,EAChC;AAEA,SACG,gBAAAlD,EAAA,WAAA,EAAQ,WAAAK,GACP,UAAA,gBAAAL,EAACoD,KAAc,GAAGb,GAAS,SAAAD,GACzB,UAAA,gBAAAtC,EAACqD,GAAS,EAAA,UAAUd,EAAQ,aAAaG,CAAQ,GAC/C,UAAA,gBAAA1C;AAAA,IAACsD;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,sBAAAvC,GAAsB,WAAWE,GAAiB,OAAAb,GAAO,cAAA+C,EAAa;AAAA,MAE/E,UAAA,gBAAAnD,EAACuD,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAAjD,KAIG,gBAAAkD,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAzD,EAAC0D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,EAAA,CACX,EAEJ,CAAA;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA,GACF;AAEJ;AAEA9D,EAAe,OAAO4D;AACtB5D,EAAe,OAAO6D;AACtB7D,EAAe,UAAU8D;"}
|
|
@@ -8,9 +8,9 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
8
8
|
import "@tanstack/react-query";
|
|
9
9
|
import "../../../Base/useBase.js";
|
|
10
10
|
import "../../../../shared/constants.js";
|
|
11
|
-
import "classnames";
|
|
12
11
|
import "dompurify";
|
|
13
12
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
+
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
14
14
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
15
15
|
const [c, d] = t("StateTaxesFormContext");
|
|
16
16
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as i } from "react-i18next";
|
|
3
3
|
import { useStateTaxesList as e } from "./context.js";
|
|
4
|
-
import "
|
|
4
|
+
import "../../../../shared/constants.js";
|
|
5
5
|
import { ActionsLayout as m } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
6
6
|
import { useComponentContext as s } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
7
|
function l() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, Fragment as p } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as o } from "react-i18next";
|
|
3
3
|
import { useStateTaxesList as l } from "./context.js";
|
|
4
|
-
import "
|
|
4
|
+
import "../../../../shared/constants.js";
|
|
5
5
|
import { EmptyData as c } from "../../../Common/EmptyData/EmptyData.js";
|
|
6
6
|
import { useComponentContext as u } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
7
|
import { useDataView as d } from "../../../Common/DataView/useDataView.js";
|
|
@@ -8,9 +8,9 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
8
8
|
import "@tanstack/react-query";
|
|
9
9
|
import "../../../Base/useBase.js";
|
|
10
10
|
import "../../../../shared/constants.js";
|
|
11
|
-
import "classnames";
|
|
12
11
|
import "dompurify";
|
|
13
12
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
+
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
14
14
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
15
15
|
const [c, d] = t("StateTaxesListContext");
|
|
16
16
|
export {
|
|
@@ -11,8 +11,6 @@ import { Actions as f } from "./Actions.js";
|
|
|
11
11
|
import { Form as N } from "../../Common/Form/Form.js";
|
|
12
12
|
import { useComponentDictionary as j, useI18n as q } from "../../../i18n/I18n.js";
|
|
13
13
|
import { Flex as w } from "../../Common/Flex/Flex.js";
|
|
14
|
-
import "react-i18next";
|
|
15
|
-
import "classnames";
|
|
16
14
|
import { BaseComponent as G } from "../../Base/Base.js";
|
|
17
15
|
import { useBase as M } from "../../Base/useBase.js";
|
|
18
16
|
import { contractorEvents as a } from "../../../shared/constants.js";
|