@gusto/embedded-react-sdk 0.54.0 → 0.54.1

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.
Files changed (168) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/components/Common/Loading/Loading.d.ts +6 -1
  3. package/dist/components/Common/Loading/Loading.js +13 -12
  4. package/dist/components/Common/Loading/Loading.js.map +1 -1
  5. package/dist/components/Common/Loading/Loading.module.scss.js +1 -1
  6. package/dist/components/Common/PayrollLoading/PayrollLoading.js +1 -1
  7. package/dist/components/Common/PayrollLoading/PayrollLoading.js.map +1 -1
  8. package/dist/components/Common/UI/Alert/Alert.js +8 -8
  9. package/dist/components/Common/UI/Alert/Alert.js.map +1 -1
  10. package/dist/components/Common/UI/Alert/Alert.module.scss.js +18 -16
  11. package/dist/components/Common/UI/Alert/Alert.module.scss.js.map +1 -1
  12. package/dist/components/Common/UI/Breadcrumbs/Breadcrumbs.js +1 -1
  13. package/dist/components/Common/UI/FileInput/FileInput.js +1 -1
  14. package/dist/components/Common/UI/Menu/Menu.js +19 -18
  15. package/dist/components/Common/UI/Menu/Menu.js.map +1 -1
  16. package/dist/components/Common/UI/ProgressBar/ProgressBar.js +4 -4
  17. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -5
  18. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  19. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -5
  20. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  21. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -7
  22. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  23. package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -5
  24. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  25. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -5
  26. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  27. package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
  28. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +8 -10
  29. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  30. package/dist/components/Company/Industry/Context.js +6 -8
  31. package/dist/components/Company/Industry/Context.js.map +1 -1
  32. package/dist/components/Company/Industry/Industry.js +2 -2
  33. package/dist/components/Company/Industry/Industry.js.map +1 -1
  34. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -5
  35. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  36. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -5
  37. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  38. package/dist/components/Company/OnboardingOverview/OnboardingOverview.js +20 -19
  39. package/dist/components/Company/OnboardingOverview/OnboardingOverview.js.map +1 -1
  40. package/dist/components/Company/OnboardingOverview/context.js +3 -5
  41. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  42. package/dist/components/Company/PaySchedule/PaySchedule.js +20 -19
  43. package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
  44. package/dist/components/Company/PaySchedule/PayScheduleForm.js +29 -28
  45. package/dist/components/Company/PaySchedule/PayScheduleForm.js.map +1 -1
  46. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.d.ts +1 -1
  47. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
  48. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js.map +1 -1
  49. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.js +24 -21
  50. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.js.map +1 -1
  51. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js +11 -11
  52. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js.map +1 -1
  53. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -5
  54. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  55. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -5
  56. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  57. package/dist/components/Company/StateTaxes/TaxRateManagement/TaxRateHistorySection.js +14 -13
  58. package/dist/components/Company/StateTaxes/TaxRateManagement/TaxRateHistorySection.js.map +1 -1
  59. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +3 -5
  60. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
  61. package/dist/components/Contractor/ContractorList/management/ManagementContractorListView.js +22 -21
  62. package/dist/components/Contractor/ContractorList/management/ManagementContractorListView.js.map +1 -1
  63. package/dist/components/Contractor/Documents/shared/SignatureForm/useContractorSignatureForm/fields.js +8 -8
  64. package/dist/components/Contractor/Landing/Landing.js +30 -29
  65. package/dist/components/Contractor/Landing/Landing.js.map +1 -1
  66. package/dist/components/Contractor/OnboardingSummary/OnboardingSummary.js +18 -17
  67. package/dist/components/Contractor/OnboardingSummary/OnboardingSummary.js.map +1 -1
  68. package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/fields.js +1 -1
  69. package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.d.ts +41 -0
  70. package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js +175 -0
  71. package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js.map +1 -0
  72. package/dist/components/Contractor/Payments/CreateHistoricalPayment/index.d.ts +1 -0
  73. package/dist/components/Contractor/Payments/CreateHistoricalPayment/useFormDictionary.d.ts +18 -0
  74. package/dist/components/Contractor/Payments/{HistoricalPaymentAmounts → CreateHistoricalPayment}/useFormDictionary.js +37 -7
  75. package/dist/components/Contractor/Payments/CreateHistoricalPayment/useFormDictionary.js.map +1 -0
  76. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.d.ts +30 -0
  77. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js +56 -0
  78. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js.map +1 -0
  79. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/index.d.ts +1 -0
  80. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/useFormDictionary.d.ts +9 -0
  81. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/useFormDictionary.js +33 -0
  82. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/useFormDictionary.js.map +1 -0
  83. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.js +46 -131
  84. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.js.map +1 -1
  85. package/dist/components/Contractor/Payments/PaymentSummary/useFormDictionary.d.ts +9 -0
  86. package/dist/components/Contractor/Payments/PaymentSummary/useFormDictionary.js +36 -0
  87. package/dist/components/Contractor/Payments/PaymentSummary/useFormDictionary.js.map +1 -0
  88. package/dist/components/Contractor/Payments/shared/PaymentSummaryBlock/PaymentSummaryBlock.d.ts +83 -0
  89. package/dist/components/Contractor/Payments/shared/PaymentSummaryBlock/PaymentSummaryBlock.js +124 -0
  90. package/dist/components/Contractor/Payments/shared/PaymentSummaryBlock/PaymentSummaryBlock.js.map +1 -0
  91. package/dist/components/Contractor/Payments/shared/PaymentSummaryBlock/index.d.ts +1 -0
  92. package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/fields.js +16 -16
  93. package/dist/components/Contractor/exports/contractorManagement.d.ts +2 -2
  94. package/dist/components/Contractor/exports/contractorManagement.js +20 -20
  95. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
  96. package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
  97. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
  98. package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
  99. package/dist/components/Employee/Documents/management/DocumentManager.js +2 -1
  100. package/dist/components/Employee/Documents/management/DocumentManager.js.map +1 -1
  101. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -5
  102. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  103. package/dist/components/Employee/Documents/shared/useSignEmployeeForm/fields.js +1 -1
  104. package/dist/components/Employee/FederalTaxes/shared/FederalTaxesView.js +1 -1
  105. package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +4 -4
  106. package/dist/components/Employee/Landing/Landing.js +31 -30
  107. package/dist/components/Employee/Landing/Landing.js.map +1 -1
  108. package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js +59 -58
  109. package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js.map +1 -1
  110. package/dist/components/Employee/PaymentMethod/management/PaymentMethodBankForm.js +4 -4
  111. package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js +4 -4
  112. package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
  113. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
  114. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
  115. package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +5 -5
  116. package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
  117. package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
  118. package/dist/components/Flow/Flow.js +27 -20
  119. package/dist/components/Flow/Flow.js.map +1 -1
  120. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +44 -44
  121. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
  122. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +108 -108
  123. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  124. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +1 -1
  125. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
  126. package/dist/components/Payroll/usePreparedPayrollData.js +8 -10
  127. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  128. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js +23 -23
  129. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js.map +1 -1
  130. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.d.ts +4 -11
  131. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.js +8 -8
  132. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.js.map +1 -1
  133. package/dist/i18n/I18n.js +7 -7
  134. package/dist/i18n/I18n.js.map +1 -1
  135. package/dist/i18n/en/Company.PaySchedule.json.js +5 -5
  136. package/dist/i18n/en/Company.StateTaxes.json.js +1 -1
  137. package/dist/i18n/en/Company.TimeOff.EmployeeTable.json.js +20 -18
  138. package/dist/i18n/en/Company.TimeOff.EmployeeTable.json.js.map +1 -1
  139. package/dist/i18n/en/Contractor.ManagementContractorList.json.js +46 -44
  140. package/dist/i18n/en/Contractor.ManagementContractorList.json.js.map +1 -1
  141. package/dist/i18n/en/Contractor.Payments.CreateHistoricalPayment.json.js +36 -0
  142. package/dist/i18n/en/Contractor.Payments.CreateHistoricalPayment.json.js.map +1 -0
  143. package/dist/i18n/en/Contractor.Payments.HistoricalPaymentSummary.json.js +48 -0
  144. package/dist/i18n/en/Contractor.Payments.HistoricalPaymentSummary.json.js.map +1 -0
  145. package/dist/i18n/en/Contractor.Payments.PaymentSummary.json.js +7 -7
  146. package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +29 -27
  147. package/dist/i18n/en/Payroll.PayrollConfiguration.json.js.map +1 -1
  148. package/dist/i18n/types.d.ts +219 -105
  149. package/dist/shared/constants.d.ts +12 -4
  150. package/dist/shared/constants.js +23 -19
  151. package/dist/shared/constants.js.map +1 -1
  152. package/dist/style.css +1 -1
  153. package/docs/guides/endpoint-inventory.json +30 -1
  154. package/package.json +17 -16
  155. package/dist/components/Contractor/Payments/HistoricalPaymentAmounts/HistoricalPaymentAmounts.d.ts +0 -33
  156. package/dist/components/Contractor/Payments/HistoricalPaymentAmounts/HistoricalPaymentAmounts.js +0 -62
  157. package/dist/components/Contractor/Payments/HistoricalPaymentAmounts/HistoricalPaymentAmounts.js.map +0 -1
  158. package/dist/components/Contractor/Payments/HistoricalPaymentAmounts/index.d.ts +0 -1
  159. package/dist/components/Contractor/Payments/HistoricalPaymentAmounts/useFormDictionary.d.ts +0 -9
  160. package/dist/components/Contractor/Payments/HistoricalPaymentAmounts/useFormDictionary.js.map +0 -1
  161. package/dist/components/Contractor/Payments/HistoricalPaymentContractors/HistoricalPaymentContractors.d.ts +0 -27
  162. package/dist/components/Contractor/Payments/HistoricalPaymentContractors/HistoricalPaymentContractors.js +0 -56
  163. package/dist/components/Contractor/Payments/HistoricalPaymentContractors/HistoricalPaymentContractors.js.map +0 -1
  164. package/dist/components/Contractor/Payments/HistoricalPaymentContractors/index.d.ts +0 -1
  165. package/dist/i18n/en/Contractor.Payments.HistoricalPaymentAmounts.json.js +0 -36
  166. package/dist/i18n/en/Contractor.Payments.HistoricalPaymentAmounts.json.js.map +0 -1
  167. package/dist/i18n/en/Contractor.Payments.HistoricalPaymentContractors.json.js +0 -18
  168. package/dist/i18n/en/Contractor.Payments.HistoricalPaymentContractors.json.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PayScheduleForm.js","sources":["../../../../src/components/Company/PaySchedule/PayScheduleForm.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { usePayScheduleForm } from './shared/usePayScheduleForm'\nimport type { UsePayScheduleFormProps, PayScheduleFrequency } from './shared/usePayScheduleForm'\nimport style from './PayScheduleForm.module.scss'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { Form } from '@/components/Common/Form'\nimport { Flex, Grid, ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { normalizeToDate } from '@/helpers/dateFormatting'\nimport type { LoaderComponentType } from '@/components/Base'\n\ninterface PayScheduleFormProps extends UsePayScheduleFormProps {\n onEvent: OnEventType<EventType, unknown>\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n// Pay period preview dates are RFCDate (`YYYY-MM-DD`) instances; normalizeToDate parses\n// them as local midnight instead of new Date's UTC midnight, which CalendarPreview would\n// otherwise roll back a day for timezones behind UTC. The format is always valid here.\nconst toLocalDate = (rfcDate: { toString(): string }): Date => normalizeToDate(rfcDate.toString())!\n\n/** @internal */\nexport function PayScheduleForm({ onEvent, LoaderComponent, ...hookProps }: PayScheduleFormProps) {\n return (\n <BaseBoundaries componentName=\"Company.PayScheduleForm\" LoaderComponent={LoaderComponent}>\n <PayScheduleFormRoot onEvent={onEvent} LoaderComponent={LoaderComponent} {...hookProps} />\n </BaseBoundaries>\n )\n}\n\nfunction PayScheduleFormRoot({ onEvent, LoaderComponent, ...hookProps }: PayScheduleFormProps) {\n const { t } = useTranslation('Company.PaySchedule')\n const Components = useComponentContext()\n const dateFormatter = useDateFormatter()\n const paySchedule = usePayScheduleForm(hookProps)\n const [selectedPayPeriodIndex, setSelectedPayPeriodIndex] = useState(0)\n\n if (paySchedule.isLoading) {\n return (\n <BaseLayout\n isLoading\n error={paySchedule.errorHandling.errors}\n LoaderComponent={LoaderComponent}\n />\n )\n }\n\n const handleSubmit = async () => {\n const result = await paySchedule.actions.onSubmit()\n if (result) {\n onEvent(\n result.mode === 'create'\n ? componentEvents.PAY_SCHEDULE_CREATED\n : componentEvents.PAY_SCHEDULE_UPDATED,\n { paySchedule: result.data },\n )\n }\n }\n\n const { Fields } = paySchedule.form\n const { paymentSpeedDays, payPreviewLoading } = paySchedule.data\n const payPeriodPreview = paySchedule.data.payPeriodPreview\n\n const frequencyLabels: Record<PayScheduleFrequency, string> = {\n 'Every week': t('frequencies.everyWeek'),\n 'Every other week': t('frequencies.everyOtherWeek'),\n 'Twice per month': t('frequencies.twicePerMonth'),\n Monthly: t('frequencies.monthly'),\n }\n\n const twicePerMonthLabels: Record<string, string> = {\n '1st15th': t('frequencyOptions.15thAndLast'),\n custom: t('frequencyOptions.custom'),\n }\n\n return (\n <BaseLayout error={paySchedule.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <SDKFormProvider formHookResult={paySchedule}>\n <Form onSubmit={() => void handleSubmit()}>\n <Flex flexDirection=\"column\">\n <Flex justifyContent=\"space-between\" flexDirection=\"column\" gap={4}>\n <header>\n <Components.Heading as=\"h2\">\n {paySchedule.status.mode === 'create'\n ? t('headings.addPaySchedule')\n : t('headings.editPaySchedule')}\n </Components.Heading>\n </header>\n </Flex>\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 <Fields.CustomName\n label={t('labels.name')}\n validationMessages={{ REQUIRED: t('validations.name') }}\n />\n <Fields.Frequency\n label={t('labels.frequency')}\n placeholder={t('labels.frequencyPlaceholder')}\n getOptionLabel={(entry: PayScheduleFrequency) => frequencyLabels[entry]}\n validationMessages={{ REQUIRED: t('validations.frequency') }}\n />\n {Fields.CustomTwicePerMonth && (\n <Fields.CustomTwicePerMonth\n label={t('labels.frequencyOptions')}\n description={t('descriptions.frequencyOptionsDescription')}\n getOptionLabel={(entry: string) => twicePerMonthLabels[entry] ?? entry}\n />\n )}\n <Fields.AnchorPayDate\n label={t('labels.firstPayDate')}\n description={t('descriptions.anchorPayDateDescription', {\n count: paymentSpeedDays,\n })}\n validationMessages={{ REQUIRED: t('validations.firstPayDate') }}\n minDate={new Date()}\n />\n <Fields.AnchorEndOfPayPeriod\n label={t('labels.firstPayPeriodEndDate')}\n description={t('descriptions.anchorEndOfPayPeriodDescription')}\n validationMessages={{ REQUIRED: t('validations.firstPayPeriodEndDate') }}\n />\n {Fields.Day1 && (\n <Fields.Day1\n label={t('labels.firstPayDayOfTheMonth')}\n validationMessages={{\n REQUIRED: t('validations.firstPayDayOfTheMonth'),\n DAY_RANGE: t('validations.dayRange'),\n }}\n />\n )}\n {Fields.Day2 && (\n <Fields.Day2\n label={t('labels.lastPayDayOfTheMonth')}\n validationMessages={{\n REQUIRED: t('validations.lastPayDayOfTheMonth'),\n DAY_RANGE: t('validations.dayRange'),\n }}\n />\n )}\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 <Components.Select\n label={t('labels.preview')}\n placeholder=\"\"\n isRequired\n options={payPeriodPreview.map((period, index) => ({\n value: String(index),\n label: dateFormatter.formatPayPeriodRange(\n period.startDate.toString(),\n period.endDate.toString(),\n ),\n }))}\n value={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: toLocalDate(payPeriodPreview[selectedPayPeriodIndex].startDate),\n end: toLocalDate(payPeriodPreview[selectedPayPeriodIndex].endDate),\n label: t('payPreview.payPeriod') || 'Pay Period',\n }}\n highlightDates={[\n {\n date: toLocalDate(payPeriodPreview[selectedPayPeriodIndex].checkDate),\n highlightColor: 'primary',\n label: t('payPreview.payday') || 'Payday',\n },\n {\n date: toLocalDate(\n payPeriodPreview[selectedPayPeriodIndex].runPayrollBy,\n ),\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 <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.CANCEL)\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\" isLoading={paySchedule.status.isPending}>\n {t('actions.save')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n )\n}\n"],"names":["toLocalDate","rfcDate","normalizeToDate","PayScheduleForm","onEvent","LoaderComponent","hookProps","jsx","BaseBoundaries","PayScheduleFormRoot","t","useTranslation","Components","useComponentContext","dateFormatter","useDateFormatter","paySchedule","usePayScheduleForm","selectedPayPeriodIndex","setSelectedPayPeriodIndex","useState","BaseLayout","handleSubmit","result","componentEvents","Fields","paymentSpeedDays","payPreviewLoading","payPeriodPreview","frequencyLabels","twicePerMonthLabels","SDKFormProvider","Form","jsxs","Flex","style","Grid","entry","period","index","value","numericValue","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAMA,IAAc,CAACC,MAA0CC,EAAgBD,EAAQ,UAAU;AAG1F,SAASE,EAAgB,EAAE,SAAAC,GAAS,iBAAAC,GAAiB,GAAGC,KAAmC;AAChG,SACE,gBAAAC,EAACC,GAAA,EAAe,eAAc,2BAA0B,iBAAAH,GACtD,UAAA,gBAAAE,EAACE,GAAA,EAAoB,SAAAL,GAAkB,iBAAAC,GAA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AAA,MAAA,GAEJ,EAAA,CAEJ;AAAA,IAAA,EAAA,CACF,EAAA,CACF;AAAA,sBACCgC,GAAA,EACC,UAAA;AAAA,MAAA,gBAAAnC;AAAA,QAACK,EAAW;AAAA,QAAX;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,MAAM;AACb,YAAAR,EAAQoB,EAAgB,MAAM;AAAA,UAChC;AAAA,UAEC,YAAE,gBAAgB;AAAA,QAAA;AAAA,MAAA;AAAA,MAErB,gBAAAjB,EAACK,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWI,EAAY,OAAO,WAC5D,UAAAN,EAAE,cAAc,EAAA,CACnB;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
1
+ {"version":3,"file":"PayScheduleForm.js","sources":["../../../../src/components/Company/PaySchedule/PayScheduleForm.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { usePayScheduleForm } from './shared/usePayScheduleForm'\nimport type { UsePayScheduleFormProps, PayScheduleFrequency } from './shared/usePayScheduleForm'\nimport style from './PayScheduleForm.module.scss'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { Form } from '@/components/Common/Form'\nimport { Flex, Grid, ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { normalizeToDate } from '@/helpers/dateFormatting'\nimport type { LoaderComponentType } from '@/components/Base'\n\ninterface PayScheduleFormProps extends UsePayScheduleFormProps {\n onEvent: OnEventType<EventType, unknown>\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n// Pay period preview dates are RFCDate (`YYYY-MM-DD`) instances; normalizeToDate parses\n// them as local midnight instead of new Date's UTC midnight, which CalendarPreview would\n// otherwise roll back a day for timezones behind UTC. The format is always valid here.\nconst toLocalDate = (rfcDate: { toString(): string }): Date => normalizeToDate(rfcDate.toString())!\n\n/** @internal */\nexport function PayScheduleForm({ onEvent, LoaderComponent, ...hookProps }: PayScheduleFormProps) {\n return (\n <BaseBoundaries componentName=\"Company.PayScheduleForm\" LoaderComponent={LoaderComponent}>\n <PayScheduleFormRoot onEvent={onEvent} LoaderComponent={LoaderComponent} {...hookProps} />\n </BaseBoundaries>\n )\n}\n\nfunction PayScheduleFormRoot({ onEvent, LoaderComponent, ...hookProps }: PayScheduleFormProps) {\n const { t } = useTranslation('Company.PaySchedule')\n const Components = useComponentContext()\n const dateFormatter = useDateFormatter()\n const paySchedule = usePayScheduleForm(hookProps)\n const [selectedPayPeriodIndex, setSelectedPayPeriodIndex] = useState(0)\n\n if (paySchedule.isLoading) {\n return (\n <BaseLayout\n isLoading\n error={paySchedule.errorHandling.errors}\n LoaderComponent={LoaderComponent}\n />\n )\n }\n\n const handleSubmit = async () => {\n const result = await paySchedule.actions.onSubmit()\n if (result) {\n onEvent(\n result.mode === 'create'\n ? componentEvents.PAY_SCHEDULE_CREATED\n : componentEvents.PAY_SCHEDULE_UPDATED,\n { paySchedule: result.data },\n )\n }\n }\n\n const { Fields } = paySchedule.form\n const { paymentSpeedDays, payPreviewLoading } = paySchedule.data\n const payPeriodPreview = paySchedule.data.payPeriodPreview\n\n const frequencyLabels: Record<PayScheduleFrequency, string> = {\n 'Every week': t('frequencies.everyWeek'),\n 'Every other week': t('frequencies.everyOtherWeek'),\n 'Twice per month': t('frequencies.twicePerMonth'),\n Monthly: t('frequencies.monthly'),\n }\n\n const twicePerMonthLabels: Record<string, string> = {\n '1st15th': t('frequencyOptions.15thAndLast'),\n custom: t('frequencyOptions.custom'),\n }\n\n return (\n <BaseLayout error={paySchedule.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <SDKFormProvider formHookResult={paySchedule}>\n <Form onSubmit={() => void handleSubmit()}>\n <Flex flexDirection=\"column\">\n <Flex justifyContent=\"space-between\" flexDirection=\"column\" gap={4}>\n <header>\n <Components.Heading as=\"h2\">\n {paySchedule.status.mode === 'create'\n ? t('headings.addPaySchedule')\n : t('headings.editPaySchedule')}\n </Components.Heading>\n </header>\n </Flex>\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 <Fields.CustomName\n label={t('labels.name')}\n validationMessages={{ REQUIRED: t('validations.name') }}\n />\n <Fields.Frequency\n label={t('labels.frequency')}\n placeholder={t('labels.frequencyPlaceholder')}\n getOptionLabel={(entry: PayScheduleFrequency) => frequencyLabels[entry]}\n validationMessages={{ REQUIRED: t('validations.frequency') }}\n />\n {Fields.CustomTwicePerMonth && (\n <Fields.CustomTwicePerMonth\n label={t('labels.frequencyOptions')}\n description={t('descriptions.frequencyOptionsDescription')}\n getOptionLabel={(entry: string) => twicePerMonthLabels[entry] ?? entry}\n validationMessages={{ REQUIRED: t('validations.frequencyOptions') }}\n />\n )}\n <Fields.AnchorPayDate\n label={t('labels.firstPayDate')}\n description={t('descriptions.anchorPayDateDescription', {\n count: paymentSpeedDays,\n })}\n validationMessages={{ REQUIRED: t('validations.firstPayDate') }}\n minDate={new Date()}\n />\n <Fields.AnchorEndOfPayPeriod\n label={t('labels.firstPayPeriodEndDate')}\n description={t('descriptions.anchorEndOfPayPeriodDescription')}\n validationMessages={{ REQUIRED: t('validations.firstPayPeriodEndDate') }}\n />\n {Fields.Day1 && (\n <Fields.Day1\n label={t('labels.firstPayDayOfTheMonth')}\n validationMessages={{\n REQUIRED: t('validations.firstPayDayOfTheMonth'),\n DAY_RANGE: t('validations.dayRange'),\n }}\n />\n )}\n {Fields.Day2 && (\n <Fields.Day2\n label={t('labels.lastPayDayOfTheMonth')}\n validationMessages={{\n REQUIRED: t('validations.lastPayDayOfTheMonth'),\n DAY_RANGE: t('validations.dayRange'),\n }}\n />\n )}\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 <Components.Select\n label={t('labels.preview')}\n placeholder=\"\"\n isRequired\n options={payPeriodPreview.map((period, index) => ({\n value: String(index),\n label: dateFormatter.formatPayPeriodRange(\n period.startDate.toString(),\n period.endDate.toString(),\n ),\n }))}\n value={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: toLocalDate(payPeriodPreview[selectedPayPeriodIndex].startDate),\n end: toLocalDate(payPeriodPreview[selectedPayPeriodIndex].endDate),\n label: t('payPreview.payPeriod') || 'Pay Period',\n }}\n highlightDates={[\n {\n date: toLocalDate(payPeriodPreview[selectedPayPeriodIndex].checkDate),\n highlightColor: 'primary',\n label: t('payPreview.payday') || 'Payday',\n },\n {\n date: toLocalDate(\n payPeriodPreview[selectedPayPeriodIndex].runPayrollBy,\n ),\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 <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.CANCEL)\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\" isLoading={paySchedule.status.isPending}>\n {t('actions.save')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n )\n}\n"],"names":["toLocalDate","rfcDate","normalizeToDate","PayScheduleForm","onEvent","LoaderComponent","hookProps","jsx","BaseBoundaries","PayScheduleFormRoot","t","useTranslation","Components","useComponentContext","dateFormatter","useDateFormatter","paySchedule","usePayScheduleForm","selectedPayPeriodIndex","setSelectedPayPeriodIndex","useState","BaseLayout","handleSubmit","result","componentEvents","Fields","paymentSpeedDays","payPreviewLoading","payPeriodPreview","frequencyLabels","twicePerMonthLabels","SDKFormProvider","Form","jsxs","Flex","style","Grid","entry","period","index","value","numericValue","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAMA,IAAc,CAACC,MAA0CC,EAAgBD,EAAQ,UAAU;AAG1F,SAASE,EAAgB,EAAE,SAAAC,GAAS,iBAAAC,GAAiB,GAAGC,KAAmC;AAChG,SACE,gBAAAC,EAACC,GAAA,EAAe,eAAc,2BAA0B,iBAAAH,GACtD,UAAA,gBAAAE,EAACE,GAAA,EAAoB,SAAAL,GAAkB,iBAAAC,GAAmC,GAAGC,EAAA,CAAW,EAAA,CAC1F;AAEJ;AAEA,SAASG,EAAoB,EAAE,SAAAL,GAAS,iBAAAC,GAAiB,GAAGC,KAAmC;AAC7F,QAAM,EAAE,GAAAI,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAA,GACbC,IAAgBC,EAAA,GAChBC,IAAcC,EAAmBX,CAAS,GAC1C,CAACY,GAAwBC,CAAyB,IAAIC,EAAS,CAAC;AAEtE,MAAIJ,EAAY;AACd,WACE,gBAAAT;AAAA,MAACc;AAAA,MAAA;AAAA,QACC,WAAS;AAAA,QACT,OAAOL,EAAY,cAAc;AAAA,QACjC,iBAAAX;AAAA,MAAA;AAAA,IAAA;AAKN,QAAMiB,IAAe,YAAY;AAC/B,UAAMC,IAAS,MAAMP,EAAY,QAA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F,GACF,GACF;AAEJ;"}
@@ -46,7 +46,7 @@ export declare function FrequencyField(props: FrequencyFieldProps): import("reac
46
46
  *
47
47
  * @public
48
48
  */
49
- export type CustomTwicePerMonthFieldProps = HookFieldProps<RadioGroupHookFieldProps<never, string>>;
49
+ export type CustomTwicePerMonthFieldProps = HookFieldProps<RadioGroupHookFieldProps<RequiredValidation, string>>;
50
50
  /** @internal */
51
51
  export declare function CustomTwicePerMonthField(props: CustomTwicePerMonthFieldProps): import("react").JSX.Element;
52
52
  /**
@@ -1,17 +1,17 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import { TextInputHookField as t } from "../../../../../partner-hook-utils/form/fields/TextInputHookField.js";
3
- import { SelectHookField as i } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
4
2
  import { NumberInputHookField as n } from "../../../../../partner-hook-utils/form/fields/NumberInputHookField.js";
5
3
  import { DatePickerHookField as r } from "../../../../../partner-hook-utils/form/fields/DatePickerHookField.js";
6
- import { RadioGroupHookField as m } from "../../../../../partner-hook-utils/form/fields/RadioGroupHookField.js";
4
+ import { RadioGroupHookField as t } from "../../../../../partner-hook-utils/form/fields/RadioGroupHookField.js";
5
+ import { SelectHookField as i } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
6
+ import { TextInputHookField as m } from "../../../../../partner-hook-utils/form/fields/TextInputHookField.js";
7
7
  function F(e) {
8
- return /* @__PURE__ */ o(t, { ...e, name: "customName" });
8
+ return /* @__PURE__ */ o(m, { ...e, name: "customName" });
9
9
  }
10
10
  function p(e) {
11
11
  return /* @__PURE__ */ o(i, { ...e, name: "frequency" });
12
12
  }
13
13
  function y(e) {
14
- return /* @__PURE__ */ o(m, { ...e, name: "customTwicePerMonth" });
14
+ return /* @__PURE__ */ o(t, { ...e, name: "customTwicePerMonth" });
15
15
  }
16
16
  function P(e) {
17
17
  return /* @__PURE__ */ o(r, { ...e, name: "anchorPayDate" });
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","sources":["../../../../../../src/components/Company/PaySchedule/shared/usePayScheduleForm/fields.tsx"],"sourcesContent":["import type { PayScheduleErrorCodes, PayScheduleFrequency } from './payScheduleSchema'\nimport type { TextInputHookFieldProps } from '@/partner-hook-utils/form/fields/TextInputHookField'\nimport type { SelectHookFieldProps } from '@/partner-hook-utils/form/fields/SelectHookField'\nimport type { RadioGroupHookFieldProps } from '@/partner-hook-utils/form/fields/RadioGroupHookField'\nimport type { DatePickerHookFieldProps } from '@/partner-hook-utils/form/fields/DatePickerHookField'\nimport type { NumberInputHookFieldProps } from '@/partner-hook-utils/form/fields/NumberInputHookField'\nimport {\n TextInputHookField,\n SelectHookField,\n RadioGroupHookField,\n DatePickerHookField,\n NumberInputHookField,\n} from '@/partner-hook-utils/form/fields'\nimport type { HookFieldProps } from '@/partner-hook-utils/types'\n\n/**\n * The required-field error code produced by {@link usePayScheduleForm} fields that only emit `REQUIRED`.\n *\n * @remarks\n * Used as the `validationMessages` key for the custom name, frequency, anchor\n * pay date, and anchor end-of-pay-period fields. See {@link PayScheduleErrorCodes}.\n *\n * @public\n */\nexport type RequiredValidation = typeof PayScheduleErrorCodes.REQUIRED\n\n/**\n * Validation error codes emitted by the `day1` and `day2` fields of {@link usePayScheduleForm}.\n *\n * @remarks\n * Use these as keys in `validationMessages` on `Fields.Day1` and `Fields.Day2`.\n * See {@link PayScheduleErrorCodes}.\n *\n * @public\n */\nexport type DayValidation = (typeof PayScheduleErrorCodes)['REQUIRED' | 'DAY_RANGE']\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.CustomName` component.\n *\n * @public\n */\nexport type CustomNameFieldProps = HookFieldProps<TextInputHookFieldProps<RequiredValidation>>\n\n/** @internal */\nexport function CustomNameField(props: CustomNameFieldProps) {\n return <TextInputHookField {...props} name=\"customName\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.Frequency` component.\n *\n * @public\n */\nexport type FrequencyFieldProps = HookFieldProps<\n SelectHookFieldProps<RequiredValidation, PayScheduleFrequency>\n>\n\n/** @internal */\nexport function FrequencyField(props: FrequencyFieldProps) {\n return <SelectHookField {...props} name=\"frequency\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.CustomTwicePerMonth` component.\n *\n * @public\n */\nexport type CustomTwicePerMonthFieldProps = HookFieldProps<RadioGroupHookFieldProps<never, string>>\n\n/** @internal */\nexport function CustomTwicePerMonthField(props: CustomTwicePerMonthFieldProps) {\n return <RadioGroupHookField {...props} name=\"customTwicePerMonth\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.AnchorPayDate` component.\n *\n * @public\n */\nexport type AnchorPayDateFieldProps = HookFieldProps<DatePickerHookFieldProps<RequiredValidation>>\n\n/** @internal */\nexport function AnchorPayDateField(props: AnchorPayDateFieldProps) {\n return <DatePickerHookField {...props} name=\"anchorPayDate\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.AnchorEndOfPayPeriod` component.\n *\n * @public\n */\nexport type AnchorEndOfPayPeriodFieldProps = HookFieldProps<\n DatePickerHookFieldProps<RequiredValidation>\n>\n\n/** @internal */\nexport function AnchorEndOfPayPeriodField(props: AnchorEndOfPayPeriodFieldProps) {\n return <DatePickerHookField {...props} name=\"anchorEndOfPayPeriod\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.Day1` component.\n *\n * @public\n */\nexport type Day1FieldProps = HookFieldProps<NumberInputHookFieldProps<DayValidation>>\n\n/** @internal */\nexport function Day1Field(props: Day1FieldProps) {\n return <NumberInputHookField {...props} name=\"day1\" min={1} max={31} />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.Day2` component.\n *\n * @public\n */\nexport type Day2FieldProps = HookFieldProps<NumberInputHookFieldProps<DayValidation>>\n\n/** @internal */\nexport function Day2Field(props: Day2FieldProps) {\n return <NumberInputHookField {...props} name=\"day2\" min={1} max={31} />\n}\n"],"names":["CustomNameField","props","jsx","TextInputHookField","FrequencyField","SelectHookField","CustomTwicePerMonthField","RadioGroupHookField","AnchorPayDateField","DatePickerHookField","AnchorEndOfPayPeriodField","Day1Field","NumberInputHookField","Day2Field"],"mappings":";;;;;;AA6CO,SAASA,EAAgBC,GAA6B;AAC3D,SAAO,gBAAAC,EAACC,GAAA,EAAoB,GAAGF,GAAO,MAAK,cAAa;AAC1D;AAYO,SAASG,EAAeH,GAA4B;AACzD,SAAO,gBAAAC,EAACG,GAAA,EAAiB,GAAGJ,GAAO,MAAK,aAAY;AACtD;AAUO,SAASK,EAAyBL,GAAsC;AAC7E,SAAO,gBAAAC,EAACK,GAAA,EAAqB,GAAGN,GAAO,MAAK,uBAAsB;AACpE;AAUO,SAASO,EAAmBP,GAAgC;AACjE,SAAO,gBAAAC,EAACO,GAAA,EAAqB,GAAGR,GAAO,MAAK,iBAAgB;AAC9D;AAYO,SAASS,EAA0BT,GAAuC;AAC/E,SAAO,gBAAAC,EAACO,GAAA,EAAqB,GAAGR,GAAO,MAAK,wBAAuB;AACrE;AAUO,SAASU,EAAUV,GAAuB;AAC/C,SAAO,gBAAAC,EAACU,KAAsB,GAAGX,GAAO,MAAK,QAAO,KAAK,GAAG,KAAK,GAAA,CAAI;AACvE;AAUO,SAASY,EAAUZ,GAAuB;AAC/C,SAAO,gBAAAC,EAACU,KAAsB,GAAGX,GAAO,MAAK,QAAO,KAAK,GAAG,KAAK,GAAA,CAAI;AACvE;"}
1
+ {"version":3,"file":"fields.js","sources":["../../../../../../src/components/Company/PaySchedule/shared/usePayScheduleForm/fields.tsx"],"sourcesContent":["import type { PayScheduleErrorCodes, PayScheduleFrequency } from './payScheduleSchema'\nimport type { TextInputHookFieldProps } from '@/partner-hook-utils/form/fields/TextInputHookField'\nimport type { SelectHookFieldProps } from '@/partner-hook-utils/form/fields/SelectHookField'\nimport type { RadioGroupHookFieldProps } from '@/partner-hook-utils/form/fields/RadioGroupHookField'\nimport type { DatePickerHookFieldProps } from '@/partner-hook-utils/form/fields/DatePickerHookField'\nimport type { NumberInputHookFieldProps } from '@/partner-hook-utils/form/fields/NumberInputHookField'\nimport {\n TextInputHookField,\n SelectHookField,\n RadioGroupHookField,\n DatePickerHookField,\n NumberInputHookField,\n} from '@/partner-hook-utils/form/fields'\nimport type { HookFieldProps } from '@/partner-hook-utils/types'\n\n/**\n * The required-field error code produced by {@link usePayScheduleForm} fields that only emit `REQUIRED`.\n *\n * @remarks\n * Used as the `validationMessages` key for the custom name, frequency, anchor\n * pay date, and anchor end-of-pay-period fields. See {@link PayScheduleErrorCodes}.\n *\n * @public\n */\nexport type RequiredValidation = typeof PayScheduleErrorCodes.REQUIRED\n\n/**\n * Validation error codes emitted by the `day1` and `day2` fields of {@link usePayScheduleForm}.\n *\n * @remarks\n * Use these as keys in `validationMessages` on `Fields.Day1` and `Fields.Day2`.\n * See {@link PayScheduleErrorCodes}.\n *\n * @public\n */\nexport type DayValidation = (typeof PayScheduleErrorCodes)['REQUIRED' | 'DAY_RANGE']\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.CustomName` component.\n *\n * @public\n */\nexport type CustomNameFieldProps = HookFieldProps<TextInputHookFieldProps<RequiredValidation>>\n\n/** @internal */\nexport function CustomNameField(props: CustomNameFieldProps) {\n return <TextInputHookField {...props} name=\"customName\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.Frequency` component.\n *\n * @public\n */\nexport type FrequencyFieldProps = HookFieldProps<\n SelectHookFieldProps<RequiredValidation, PayScheduleFrequency>\n>\n\n/** @internal */\nexport function FrequencyField(props: FrequencyFieldProps) {\n return <SelectHookField {...props} name=\"frequency\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.CustomTwicePerMonth` component.\n *\n * @public\n */\nexport type CustomTwicePerMonthFieldProps = HookFieldProps<\n RadioGroupHookFieldProps<RequiredValidation, string>\n>\n\n/** @internal */\nexport function CustomTwicePerMonthField(props: CustomTwicePerMonthFieldProps) {\n return <RadioGroupHookField {...props} name=\"customTwicePerMonth\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.AnchorPayDate` component.\n *\n * @public\n */\nexport type AnchorPayDateFieldProps = HookFieldProps<DatePickerHookFieldProps<RequiredValidation>>\n\n/** @internal */\nexport function AnchorPayDateField(props: AnchorPayDateFieldProps) {\n return <DatePickerHookField {...props} name=\"anchorPayDate\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.AnchorEndOfPayPeriod` component.\n *\n * @public\n */\nexport type AnchorEndOfPayPeriodFieldProps = HookFieldProps<\n DatePickerHookFieldProps<RequiredValidation>\n>\n\n/** @internal */\nexport function AnchorEndOfPayPeriodField(props: AnchorEndOfPayPeriodFieldProps) {\n return <DatePickerHookField {...props} name=\"anchorEndOfPayPeriod\" />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.Day1` component.\n *\n * @public\n */\nexport type Day1FieldProps = HookFieldProps<NumberInputHookFieldProps<DayValidation>>\n\n/** @internal */\nexport function Day1Field(props: Day1FieldProps) {\n return <NumberInputHookField {...props} name=\"day1\" min={1} max={31} />\n}\n\n/**\n * Props accepted by {@link usePayScheduleForm}'s `Fields.Day2` component.\n *\n * @public\n */\nexport type Day2FieldProps = HookFieldProps<NumberInputHookFieldProps<DayValidation>>\n\n/** @internal */\nexport function Day2Field(props: Day2FieldProps) {\n return <NumberInputHookField {...props} name=\"day2\" min={1} max={31} />\n}\n"],"names":["CustomNameField","props","jsx","TextInputHookField","FrequencyField","SelectHookField","CustomTwicePerMonthField","RadioGroupHookField","AnchorPayDateField","DatePickerHookField","AnchorEndOfPayPeriodField","Day1Field","NumberInputHookField","Day2Field"],"mappings":";;;;;;AA6CO,SAASA,EAAgBC,GAA6B;AAC3D,SAAO,gBAAAC,EAACC,GAAA,EAAoB,GAAGF,GAAO,MAAK,cAAa;AAC1D;AAYO,SAASG,EAAeH,GAA4B;AACzD,SAAO,gBAAAC,EAACG,GAAA,EAAiB,GAAGJ,GAAO,MAAK,aAAY;AACtD;AAYO,SAASK,EAAyBL,GAAsC;AAC7E,SAAO,gBAAAC,EAACK,GAAA,EAAqB,GAAGN,GAAO,MAAK,uBAAsB;AACpE;AAUO,SAASO,EAAmBP,GAAgC;AACjE,SAAO,gBAAAC,EAACO,GAAA,EAAqB,GAAGR,GAAO,MAAK,iBAAgB;AAC9D;AAYO,SAASS,EAA0BT,GAAuC;AAC/E,SAAO,gBAAAC,EAACO,GAAA,EAAqB,GAAGR,GAAO,MAAK,wBAAuB;AACrE;AAUO,SAASU,EAAUV,GAAuB;AAC/C,SAAO,gBAAAC,EAACU,KAAsB,GAAGX,GAAO,MAAK,QAAO,KAAK,GAAG,KAAK,GAAA,CAAI;AACvE;AAUO,SAASY,EAAUZ,GAAuB;AAC/C,SAAO,gBAAAC,EAACU,KAAsB,GAAGX,GAAO,MAAK,QAAO,KAAK,GAAG,KAAK,GAAA,CAAI;AACvE;"}
@@ -1,7 +1,7 @@
1
1
  import { z as o } from "zod";
2
2
  import { buildFormSchema as d } from "../../../../../partner-hook-utils/form/buildFormSchema.js";
3
- import { coerceNaN as n, coerceToISODate as t } from "../../../../../partner-hook-utils/form/preprocessors.js";
4
- const c = {
3
+ import { coerceNaN as s, coerceToISODate as t } from "../../../../../partner-hook-utils/form/preprocessors.js";
4
+ const n = {
5
5
  REQUIRED: "REQUIRED",
6
6
  DAY_RANGE: "DAY_RANGE"
7
7
  }, m = ["Every week", "Every other week", "Twice per month", "Monthly"], a = {
@@ -10,45 +10,48 @@ const c = {
10
10
  customTwicePerMonth: o.string(),
11
11
  anchorPayDate: o.preprocess(t, o.iso.date().nullable()),
12
12
  anchorEndOfPayPeriod: o.preprocess(t, o.iso.date().nullable()),
13
- day1: o.preprocess(n(0), o.number()),
14
- day2: o.preprocess(n(0), o.number())
13
+ day1: o.preprocess(s(0), o.number()),
14
+ day2: o.preprocess(s(0), o.number())
15
15
  };
16
+ function y(e) {
17
+ return e.frequency === "Twice per month";
18
+ }
16
19
  function u(e) {
17
- const r = e.frequency, s = e.customTwicePerMonth;
18
- return r === "Monthly" || r === "Twice per month" && s === "custom";
20
+ const r = e.frequency, c = e.customTwicePerMonth;
21
+ return r === "Monthly" || r === "Twice per month" && c === "custom";
19
22
  }
20
23
  function i(e) {
21
- const r = e.frequency, s = e.customTwicePerMonth;
22
- return r === "Twice per month" && s === "custom";
24
+ const r = e.frequency, c = e.customTwicePerMonth;
25
+ return r === "Twice per month" && c === "custom";
23
26
  }
24
- const y = {
25
- customTwicePerMonth: "never",
27
+ const E = {
28
+ customTwicePerMonth: y,
26
29
  day1: u,
27
30
  day2: i
28
31
  };
29
- function E(e, r) {
32
+ function f(e, r) {
30
33
  u(e) && (e.day1 < 1 || e.day1 > 31) && r.addIssue({
31
34
  code: o.ZodIssueCode.custom,
32
35
  path: ["day1"],
33
- message: e.day1 < 1 ? c.REQUIRED : c.DAY_RANGE
36
+ message: e.day1 < 1 ? n.REQUIRED : n.DAY_RANGE
34
37
  }), i(e) && (e.day2 < 1 || e.day2 > 31) && r.addIssue({
35
38
  code: o.ZodIssueCode.custom,
36
39
  path: ["day2"],
37
- message: e.day2 < 1 ? c.REQUIRED : c.DAY_RANGE
40
+ message: e.day2 < 1 ? n.REQUIRED : n.DAY_RANGE
38
41
  });
39
42
  }
40
- function R(e = {}) {
41
- const { mode: r = "create", optionalFieldsToRequire: s } = e;
43
+ function l(e = {}) {
44
+ const { mode: r = "create", optionalFieldsToRequire: c } = e;
42
45
  return d(a, {
43
- requiredFieldsConfig: y,
44
- requiredErrorCode: c.REQUIRED,
46
+ requiredFieldsConfig: E,
47
+ requiredErrorCode: n.REQUIRED,
45
48
  mode: r,
46
- optionalFieldsToRequire: s,
47
- superRefine: E
49
+ optionalFieldsToRequire: c,
50
+ superRefine: f
48
51
  });
49
52
  }
50
53
  export {
51
- c as PayScheduleErrorCodes,
52
- R as createPayScheduleSchema
54
+ n as PayScheduleErrorCodes,
55
+ l as createPayScheduleSchema
53
56
  };
54
57
  //# sourceMappingURL=payScheduleSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payScheduleSchema.js","sources":["../../../../../../src/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n type OptionalFieldsToRequire,\n} from '@/partner-hook-utils/form/buildFormSchema'\nimport { coerceNaN, coerceToISODate } from '@/partner-hook-utils/form/preprocessors'\n\n// ── Error codes ────────────────────────────────────────────────────────\n\n/**\n * Validation error codes emitted by {@link usePayScheduleForm} fields.\n *\n * @remarks\n * Use these as `validationMessages` keys on the corresponding `Fields.*` components.\n *\n * @public\n */\nexport const PayScheduleErrorCodes = {\n REQUIRED: 'REQUIRED',\n DAY_RANGE: 'DAY_RANGE',\n} as const\n\n/**\n * Union of validation error code strings emitted by the pay schedule form.\n *\n * @public\n */\nexport type PayScheduleErrorCode =\n (typeof PayScheduleErrorCodes)[keyof typeof PayScheduleErrorCodes]\n\n// ── Field validators ───────────────────────────────────────────────────\n\nconst FREQUENCY_VALUES = ['Every week', 'Every other week', 'Twice per month', 'Monthly'] as const\n/**\n * Pay schedule frequency values accepted by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type PayScheduleFrequency = (typeof FREQUENCY_VALUES)[number]\n\nconst fieldValidators = {\n customName: z.string(),\n frequency: z.enum(FREQUENCY_VALUES),\n customTwicePerMonth: z.string(),\n anchorPayDate: z.preprocess(coerceToISODate, z.iso.date().nullable()),\n anchorEndOfPayPeriod: z.preprocess(coerceToISODate, z.iso.date().nullable()),\n day1: z.preprocess(coerceNaN(0), z.number()),\n day2: z.preprocess(coerceNaN(0), z.number()),\n}\n\n/**\n * Union of field names managed by the pay schedule form.\n *\n * @public\n */\nexport type PayScheduleField = keyof typeof fieldValidators\n\n/**\n * Shape of the values managed by the pay schedule form.\n *\n * @public\n * @interface\n */\nexport type PayScheduleFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n/** @internal */\nexport type PayScheduleFormOutputs = PayScheduleFormData\n\n// ── Required fields config ─────────────────────────────────────────────\n\nfunction needsDay1(data: PayScheduleFormData): boolean {\n const freq = data.frequency\n const custom = data.customTwicePerMonth\n return freq === 'Monthly' || (freq === 'Twice per month' && custom === 'custom')\n}\n\nfunction needsDay2(data: PayScheduleFormData): boolean {\n const freq = data.frequency\n const custom = data.customTwicePerMonth\n return freq === 'Twice per month' && custom === 'custom'\n}\n\nconst requiredFieldsConfig = {\n customTwicePerMonth: 'never',\n day1: needsDay1,\n day2: needsDay2,\n} satisfies RequiredFieldConfig<typeof fieldValidators>\n\n/**\n * coerceNaN(0) maps empty inputs to 0, which `isEmpty` does not catch\n * (it only recognizes undefined/null/blank-string). This superRefine\n * enforces the 1–31 range when the field is applicable, which also\n * rejects the 0 sentinel from empty inputs.\n */\nfunction validateDayRanges(data: PayScheduleFormData, ctx: z.RefinementCtx) {\n if (needsDay1(data) && (data.day1 < 1 || data.day1 > 31)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['day1'],\n message: data.day1 < 1 ? PayScheduleErrorCodes.REQUIRED : PayScheduleErrorCodes.DAY_RANGE,\n })\n }\n if (needsDay2(data) && (data.day2 < 1 || data.day2 > 31)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['day2'],\n message: data.day2 < 1 ? PayScheduleErrorCodes.REQUIRED : PayScheduleErrorCodes.DAY_RANGE,\n })\n }\n}\n\n// ── Schema factory ─────────────────────────────────────────────────────\n\n/**\n * Configuration for promoting optional pay schedule fields to required in a given mode.\n *\n * @remarks\n * Only fields that are optional by default can be promoted. Currently\n * `customTwicePerMonth` is the only configurable field.\n *\n * @public\n */\nexport type PayScheduleOptionalFieldsToRequire = OptionalFieldsToRequire<\n typeof requiredFieldsConfig\n>\n\n/** @internal */\ninterface PayScheduleSchemaOptions {\n mode?: 'create' | 'update'\n optionalFieldsToRequire?: PayScheduleOptionalFieldsToRequire\n}\n\n/** @internal */\nexport function createPayScheduleSchema(options: PayScheduleSchemaOptions = {}) {\n const { mode = 'create', optionalFieldsToRequire } = options\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: PayScheduleErrorCodes.REQUIRED,\n mode,\n optionalFieldsToRequire,\n superRefine: validateDayRanges,\n })\n}\n"],"names":["PayScheduleErrorCodes","FREQUENCY_VALUES","fieldValidators","z","coerceToISODate","coerceNaN","needsDay1","data","freq","custom","needsDay2","requiredFieldsConfig","validateDayRanges","ctx","createPayScheduleSchema","options","mode","optionalFieldsToRequire","buildFormSchema"],"mappings":";;;AAkBO,MAAMA,IAAwB;AAAA,EACnC,UAAU;AAAA,EACV,WAAW;AACb,GAYMC,IAAmB,CAAC,cAAc,oBAAoB,mBAAmB,SAAS,GAQlFC,IAAkB;AAAA,EACtB,YAAYC,EAAE,OAAA;AAAA,EACd,WAAWA,EAAE,KAAKF,CAAgB;AAAA,EAClC,qBAAqBE,EAAE,OAAA;AAAA,EACvB,eAAeA,EAAE,WAAWC,GAAiBD,EAAE,IAAI,OAAO,UAAU;AAAA,EACpE,sBAAsBA,EAAE,WAAWC,GAAiBD,EAAE,IAAI,OAAO,UAAU;AAAA,EAC3E,MAAMA,EAAE,WAAWE,EAAU,CAAC,GAAGF,EAAE,QAAQ;AAAA,EAC3C,MAAMA,EAAE,WAAWE,EAAU,CAAC,GAAGF,EAAE,QAAQ;AAC7C;AAuBA,SAASG,EAAUC,GAAoC;AACrD,QAAMC,IAAOD,EAAK,WACZE,IAASF,EAAK;AACpB,SAAOC,MAAS,aAAcA,MAAS,qBAAqBC,MAAW;AACzE;AAEA,SAASC,EAAUH,GAAoC;AACrD,QAAMC,IAAOD,EAAK,WACZE,IAASF,EAAK;AACpB,SAAOC,MAAS,qBAAqBC,MAAW;AAClD;AAEA,MAAME,IAAuB;AAAA,EAC3B,qBAAqB;AAAA,EACrB,MAAML;AAAA,EACN,MAAMI;AACR;AAQA,SAASE,EAAkBL,GAA2BM,GAAsB;AAC1E,EAAIP,EAAUC,CAAI,MAAMA,EAAK,OAAO,KAAKA,EAAK,OAAO,OACnDM,EAAI,SAAS;AAAA,IACX,MAAMV,EAAE,aAAa;AAAA,IACrB,MAAM,CAAC,MAAM;AAAA,IACb,SAASI,EAAK,OAAO,IAAIP,EAAsB,WAAWA,EAAsB;AAAA,EAAA,CACjF,GAECU,EAAUH,CAAI,MAAMA,EAAK,OAAO,KAAKA,EAAK,OAAO,OACnDM,EAAI,SAAS;AAAA,IACX,MAAMV,EAAE,aAAa;AAAA,IACrB,MAAM,CAAC,MAAM;AAAA,IACb,SAASI,EAAK,OAAO,IAAIP,EAAsB,WAAWA,EAAsB;AAAA,EAAA,CACjF;AAEL;AAwBO,SAASc,EAAwBC,IAAoC,IAAI;AAC9E,QAAM,EAAE,MAAAC,IAAO,UAAU,yBAAAC,EAAA,IAA4BF;AAErD,SAAOG,EAAgBhB,GAAiB;AAAA,IACtC,sBAAAS;AAAA,IACA,mBAAmBX,EAAsB;AAAA,IACzC,MAAAgB;AAAA,IACA,yBAAAC;AAAA,IACA,aAAaL;AAAA,EAAA,CACd;AACH;"}
1
+ {"version":3,"file":"payScheduleSchema.js","sources":["../../../../../../src/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n type OptionalFieldsToRequire,\n} from '@/partner-hook-utils/form/buildFormSchema'\nimport { coerceNaN, coerceToISODate } from '@/partner-hook-utils/form/preprocessors'\n\n// ── Error codes ────────────────────────────────────────────────────────\n\n/**\n * Validation error codes emitted by {@link usePayScheduleForm} fields.\n *\n * @remarks\n * Use these as `validationMessages` keys on the corresponding `Fields.*` components.\n *\n * @public\n */\nexport const PayScheduleErrorCodes = {\n REQUIRED: 'REQUIRED',\n DAY_RANGE: 'DAY_RANGE',\n} as const\n\n/**\n * Union of validation error code strings emitted by the pay schedule form.\n *\n * @public\n */\nexport type PayScheduleErrorCode =\n (typeof PayScheduleErrorCodes)[keyof typeof PayScheduleErrorCodes]\n\n// ── Field validators ───────────────────────────────────────────────────\n\nconst FREQUENCY_VALUES = ['Every week', 'Every other week', 'Twice per month', 'Monthly'] as const\n/**\n * Pay schedule frequency values accepted by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type PayScheduleFrequency = (typeof FREQUENCY_VALUES)[number]\n\nconst fieldValidators = {\n customName: z.string(),\n frequency: z.enum(FREQUENCY_VALUES),\n customTwicePerMonth: z.string(),\n anchorPayDate: z.preprocess(coerceToISODate, z.iso.date().nullable()),\n anchorEndOfPayPeriod: z.preprocess(coerceToISODate, z.iso.date().nullable()),\n day1: z.preprocess(coerceNaN(0), z.number()),\n day2: z.preprocess(coerceNaN(0), z.number()),\n}\n\n/**\n * Union of field names managed by the pay schedule form.\n *\n * @public\n */\nexport type PayScheduleField = keyof typeof fieldValidators\n\n/**\n * Shape of the values managed by the pay schedule form.\n *\n * @public\n * @interface\n */\nexport type PayScheduleFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n/** @internal */\nexport type PayScheduleFormOutputs = PayScheduleFormData\n\n// ── Required fields config ─────────────────────────────────────────────\n\nfunction needsCustomTwicePerMonth(data: PayScheduleFormData): boolean {\n return data.frequency === 'Twice per month'\n}\n\nfunction needsDay1(data: PayScheduleFormData): boolean {\n const freq = data.frequency\n const custom = data.customTwicePerMonth\n return freq === 'Monthly' || (freq === 'Twice per month' && custom === 'custom')\n}\n\nfunction needsDay2(data: PayScheduleFormData): boolean {\n const freq = data.frequency\n const custom = data.customTwicePerMonth\n return freq === 'Twice per month' && custom === 'custom'\n}\n\nconst requiredFieldsConfig = {\n customTwicePerMonth: needsCustomTwicePerMonth,\n day1: needsDay1,\n day2: needsDay2,\n} satisfies RequiredFieldConfig<typeof fieldValidators>\n\n/**\n * coerceNaN(0) maps empty inputs to 0, which `isEmpty` does not catch\n * (it only recognizes undefined/null/blank-string). This superRefine\n * enforces the 1–31 range when the field is applicable, which also\n * rejects the 0 sentinel from empty inputs.\n */\nfunction validateDayRanges(data: PayScheduleFormData, ctx: z.RefinementCtx) {\n if (needsDay1(data) && (data.day1 < 1 || data.day1 > 31)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['day1'],\n message: data.day1 < 1 ? PayScheduleErrorCodes.REQUIRED : PayScheduleErrorCodes.DAY_RANGE,\n })\n }\n if (needsDay2(data) && (data.day2 < 1 || data.day2 > 31)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['day2'],\n message: data.day2 < 1 ? PayScheduleErrorCodes.REQUIRED : PayScheduleErrorCodes.DAY_RANGE,\n })\n }\n}\n\n// ── Schema factory ─────────────────────────────────────────────────────\n\n/**\n * Configuration for promoting optional pay schedule fields to required in a given mode.\n *\n * @remarks\n * Only fields that are optional by default can be promoted. Currently\n * `customTwicePerMonth` is the only configurable field.\n *\n * @public\n */\nexport type PayScheduleOptionalFieldsToRequire = OptionalFieldsToRequire<\n typeof requiredFieldsConfig\n>\n\n/** @internal */\ninterface PayScheduleSchemaOptions {\n mode?: 'create' | 'update'\n optionalFieldsToRequire?: PayScheduleOptionalFieldsToRequire\n}\n\n/** @internal */\nexport function createPayScheduleSchema(options: PayScheduleSchemaOptions = {}) {\n const { mode = 'create', optionalFieldsToRequire } = options\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: PayScheduleErrorCodes.REQUIRED,\n mode,\n optionalFieldsToRequire,\n superRefine: validateDayRanges,\n })\n}\n"],"names":["PayScheduleErrorCodes","FREQUENCY_VALUES","fieldValidators","z","coerceToISODate","coerceNaN","needsCustomTwicePerMonth","data","needsDay1","freq","custom","needsDay2","requiredFieldsConfig","validateDayRanges","ctx","createPayScheduleSchema","options","mode","optionalFieldsToRequire","buildFormSchema"],"mappings":";;;AAkBO,MAAMA,IAAwB;AAAA,EACnC,UAAU;AAAA,EACV,WAAW;AACb,GAYMC,IAAmB,CAAC,cAAc,oBAA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WA,EAAsB;AAAA,EAAA,CACjF;AAEL;AAwBO,SAASe,EAAwBC,IAAoC,IAAI;AAC9E,QAAM,EAAE,MAAAC,IAAO,UAAU,yBAAAC,EAAA,IAA4BF;AAErD,SAAOG,EAAgBjB,GAAiB;AAAA,IACtC,sBAAAU;AAAA,IACA,mBAAmBZ,EAAsB;AAAA,IACzC,MAAAiB;AAAA,IACA,yBAAAC;AAAA,IACA,aAAaL;AAAA,EAAA,CACd;AACH;"}
@@ -29,8 +29,8 @@ const C = [
29
29
  function q(e) {
30
30
  return e instanceof Date ? Ne(e) || "" : typeof e == "string" && e ? e : "";
31
31
  }
32
- function ge(e, c, d) {
33
- return e !== "Twice per month" ? "" : c === 15 && d === 31 ? "1st15th" : "custom";
32
+ function ge(e, r, d) {
33
+ return e !== "Twice per month" ? "" : r === 15 && d === 31 ? "1st15th" : r != null && d != null ? "custom" : "";
34
34
  }
35
35
  function qe(e) {
36
36
  return {
@@ -53,15 +53,15 @@ function qe(e) {
53
53
  }
54
54
  function Xe({
55
55
  companyId: e,
56
- payScheduleId: c,
56
+ payScheduleId: r,
57
57
  optionalFieldsToRequire: d,
58
58
  defaultValues: n,
59
59
  validationMode: A = "onSubmit",
60
60
  shouldFocusError: R = !0
61
61
  }) {
62
62
  const y = ce(
63
- { companyId: e, payScheduleId: c ?? "" },
64
- { enabled: !!c }
63
+ { companyId: e, payScheduleId: r ?? "" },
64
+ { enabled: !!r }
65
65
  ), u = ue({ companyUuid: e }), o = y.data?.payScheduleShow ?? null, L = u.data?.paymentConfigs?.paymentSpeed, k = Te(L), h = !o, w = h ? "create" : "update", [p, V] = te(
66
66
  () => me({ mode: w, optionalFieldsToRequire: d }),
67
67
  [w, d]
@@ -84,7 +84,7 @@ function Xe({
84
84
  defaultValues: S,
85
85
  values: S,
86
86
  resetOptions: { keepDirtyValues: !0 }
87
- }), r = i({ control: t.control, name: "frequency" }), m = i({
87
+ }), c = i({ control: t.control, name: "frequency" }), m = i({
88
88
  control: t.control,
89
89
  name: "customTwicePerMonth"
90
90
  }), _ = i({ control: t.control, name: "anchorPayDate" }), H = i({
@@ -92,12 +92,12 @@ function Xe({
92
92
  name: "anchorEndOfPayPeriod"
93
93
  }), Q = i({ control: t.control, name: "day1" }), U = i({ control: t.control, name: "day2" });
94
94
  ae(() => {
95
- r === "Twice per month" && m === "1st15th" && (t.setValue("day1", 15), t.setValue("day2", 31));
96
- }, [r, m, t.setValue]);
95
+ c === "Twice per month" && m === "1st15th" && (t.setValue("day1", 15), t.setValue("day2", 31));
96
+ }, [c, m, t.setValue]);
97
97
  const l = q(_), P = q(H), E = !!(l && P), v = ie(
98
98
  {
99
99
  companyId: e,
100
- frequency: r,
100
+ frequency: c,
101
101
  ...l && { anchorPayDate: new s(l) },
102
102
  ...P && {
103
103
  anchorEndOfPayPeriod: new s(P)
@@ -110,7 +110,7 @@ function Xe({
110
110
  baseSubmitHandler: B,
111
111
  error: Y,
112
112
  setError: x
113
- } = Me("PayScheduleForm"), T = De(c ? [y, u] : [u], { submitError: Y, setSubmitError: x }), z = r === "Twice per month", j = r === "Monthly" || r === "Twice per month" && m === "custom", J = r === "Twice per month" && m === "custom", K = Se(V, t.control), X = qe(K), Z = async () => {
113
+ } = Me("PayScheduleForm"), T = De(r ? [y, u] : [u], { submitError: Y, setSubmitError: x }), z = c === "Twice per month", j = c === "Monthly" || c === "Twice per month" && m === "custom", J = c === "Twice per month" && m === "custom", K = Se(V, t.control), X = qe(K), Z = async () => {
114
114
  let f;
115
115
  return await new Promise((N) => {
116
116
  t.handleSubmit(
@@ -152,7 +152,7 @@ function Xe({
152
152
  )();
153
153
  }), f;
154
154
  }, $ = Ee(t);
155
- return u.isLoading || (c ? y.isLoading : !1) ? { isLoading: !0, errorHandling: T } : {
155
+ return u.isLoading || (r ? y.isLoading : !1) ? { isLoading: !0, errorHandling: T } : {
156
156
  isLoading: !1,
157
157
  data: {
158
158
  paySchedule: o,
@@ -1 +1 @@
1
- {"version":3,"file":"usePayScheduleForm.js","sources":["../../../../../../src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.tsx"],"sourcesContent":["import { useEffect, useMemo } from 'react'\nimport type { ComponentType } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { PaySchedulePreviewPayPeriod } from '@gusto/embedded-api/models/components/payschedulepreviewpayperiod'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaymentConfigsGet } from '@gusto/embedded-api/react-query/paymentConfigsGet'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport {\n createPayScheduleSchema,\n type PayScheduleOptionalFieldsToRequire,\n type PayScheduleFormData,\n type PayScheduleFormOutputs,\n type PayScheduleFrequency,\n} from './payScheduleSchema'\nimport {\n CustomNameField,\n FrequencyField,\n CustomTwicePerMonthField,\n AnchorPayDateField,\n AnchorEndOfPayPeriodField,\n Day1Field,\n Day2Field,\n} from './fields'\nimport type {\n CustomNameFieldProps,\n FrequencyFieldProps,\n CustomTwicePerMonthFieldProps,\n AnchorPayDateFieldProps,\n AnchorEndOfPayPeriodFieldProps,\n Day1FieldProps,\n Day2FieldProps,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { parsePaymentSpeedDays } from '@/hooks/useCompanyPaymentSpeed'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\n\nexport type { PayScheduleOptionalFieldsToRequire } from './payScheduleSchema'\n\n/**\n * Configuration options for {@link usePayScheduleForm}.\n *\n * @remarks\n * Presence or absence of `payScheduleId` selects between update and create mode.\n *\n * @public\n */\nexport interface UsePayScheduleFormProps {\n /** UUID of the company that owns the pay schedule. */\n companyId: string\n /**\n * When set, loads that pay schedule and updates it on submit. When omitted,\n * the form is in create mode and creates a new schedule on submit.\n */\n payScheduleId?: string\n /** Override fields that are optional on a given mode to be required. See `PayScheduleOptionalFieldsToRequire`. */\n optionalFieldsToRequire?: PayScheduleOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update. */\n defaultValues?: Partial<PayScheduleFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `usePayScheduleForm().form.Fields`.\n *\n * @remarks\n * `CustomTwicePerMonth`, `Day1`, and `Day2` are conditionally `undefined` based\n * on the selected frequency and twice-per-month strategy — always null-check them\n * before rendering.\n *\n * @public\n */\nexport interface PayScheduleFormFields {\n /** Bound to `customName`. Display name text input. Always available. */\n CustomName: ComponentType<CustomNameFieldProps>\n /** Bound to `frequency`. Frequency selector. Always available. */\n Frequency: ComponentType<FrequencyFieldProps>\n /** Bound to `customTwicePerMonth`. Twice-per-month strategy radio group. Only available when frequency is `'Twice per month'`. */\n CustomTwicePerMonth: ComponentType<CustomTwicePerMonthFieldProps> | undefined\n /** Bound to `anchorPayDate`. First pay date picker. Always available. */\n AnchorPayDate: ComponentType<AnchorPayDateFieldProps>\n /** Bound to `anchorEndOfPayPeriod`. First pay period end date picker. Always available. */\n AnchorEndOfPayPeriod: ComponentType<AnchorEndOfPayPeriodFieldProps>\n /** Bound to `day1`. First-pay-day-of-month number input. Available when frequency is `'Monthly'`, or `'Twice per month'` with `'custom'` strategy. */\n Day1: ComponentType<Day1FieldProps> | undefined\n /** Bound to `day2`. Last-pay-day-of-month number input. Available when frequency is `'Twice per month'` with `'custom'` strategy. */\n Day2: ComponentType<Day2FieldProps> | undefined\n}\n\n/**\n * Ready-state shape returned by {@link usePayScheduleForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with the\n * pay-schedule-specific `data`, `status`, `actions`, and `form.Fields` shape.\n *\n * @public\n */\nexport interface UsePayScheduleFormReady extends BaseFormHookReady<\n PayScheduleFieldsMetadata,\n PayScheduleFormData,\n PayScheduleFormFields\n> {\n /** Static entity data resolved from the API. */\n data: {\n /** The pay schedule loaded for update; `null` in create mode. */\n paySchedule: PayScheduleShow | null\n /** Upcoming pay periods previewed from current form values; `null` until the anchor date fields are complete. */\n payPeriodPreview: PaySchedulePreviewPayPeriod[] | null\n /** `true` while the pay period preview request is in flight. */\n payPreviewLoading: boolean\n /** Business days the company needs to process payroll, derived from payment configs; `null` if unavailable. */\n paymentSpeedDays: number | null\n }\n /** Reactive status flags. */\n status: {\n /** `true` while the create or update mutation is in flight. */\n isPending: boolean\n /** Whether the form is creating a new schedule or updating an existing one. */\n mode: 'create' | 'update'\n }\n /** Available actions. */\n actions: {\n /** Validates the form and dispatches the create or update mutation. Returns the saved schedule, or `undefined` if validation failed. */\n onSubmit: () => Promise<HookSubmitResult<PayScheduleShow> | undefined>\n }\n}\n\nconst FREQUENCY_OPTIONS: Array<{ value: PayScheduleFrequency; label: string }> = [\n { value: 'Every week', label: 'Every week' },\n { value: 'Every other week', label: 'Every other week' },\n { value: 'Twice per month', label: 'Twice per month' },\n { value: 'Monthly', label: 'Monthly' },\n]\n\nconst FREQUENCY_ENTRIES: PayScheduleFrequency[] = FREQUENCY_OPTIONS.map(o => o.value)\n\nconst TWICE_PER_MONTH_OPTIONS = [\n { value: '1st15th', label: '15th and Last day of the month' },\n { value: 'custom', label: 'Custom' },\n]\n\nconst TWICE_PER_MONTH_ENTRIES = TWICE_PER_MONTH_OPTIONS.map(o => o.value)\n\nfunction formatWatchedDate(value: unknown): string {\n if (value instanceof Date) return formatDateToStringDate(value) || ''\n if (typeof value === 'string' && value) return value\n return ''\n}\n\nfunction deriveCustomTwicePerMonth(\n frequency: string | undefined,\n day1: number | undefined,\n day2: number | undefined,\n): string {\n if (frequency !== 'Twice per month') return ''\n if (day1 === 15 && day2 === 31) return '1st15th'\n return 'custom'\n}\n\n/** @internal */\nfunction buildPayScheduleFieldsMetadata(base: Record<keyof PayScheduleFormData, FieldMetadata>) {\n return {\n customName: base.customName,\n frequency: withOptions<PayScheduleFrequency>(\n base.frequency,\n FREQUENCY_OPTIONS,\n FREQUENCY_ENTRIES,\n ),\n customTwicePerMonth: withOptions<string>(\n base.customTwicePerMonth,\n TWICE_PER_MONTH_OPTIONS,\n TWICE_PER_MONTH_ENTRIES,\n ),\n anchorPayDate: base.anchorPayDate,\n anchorEndOfPayPeriod: base.anchorEndOfPayPeriod,\n day1: base.day1,\n day2: base.day2,\n } satisfies FieldsMetadata\n}\n\n/**\n * Form hook for creating or updating a company pay schedule.\n *\n * @remarks\n * When `payScheduleId` is supplied the hook loads that schedule and issues an\n * update on submit; when omitted it operates in create mode. While both anchor\n * date fields are filled in, the hook fetches a live pay period calendar\n * preview exposed on `data.payPeriodPreview`. `data.paymentSpeedDays` reflects\n * the company's payment configuration and is useful for surfacing UI hints\n * about how far ahead the first pay date must be.\n *\n * @param props - See {@link UsePayScheduleFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UsePayScheduleFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * usePayScheduleForm,\n * SDKFormProvider,\n * type UsePayScheduleFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function PaySchedulePage({ companyId }: { companyId: string }) {\n * const paySchedule = usePayScheduleForm({ companyId })\n *\n * if (paySchedule.isLoading) return <div>Loading...</div>\n *\n * return <PayScheduleFormReady paySchedule={paySchedule} />\n * }\n *\n * function PayScheduleFormReady({ paySchedule }: { paySchedule: UsePayScheduleFormReady }) {\n * const { Fields } = paySchedule.form\n *\n * return (\n * <SDKFormProvider formHookResult={paySchedule}>\n * <form\n * onSubmit={e => {\n * e.preventDefault()\n * void paySchedule.actions.onSubmit()\n * }}\n * >\n * <Fields.CustomName label=\"Name\" validationMessages={{ REQUIRED: 'Name is required' }} />\n * <Fields.Frequency label=\"Frequency\" validationMessages={{ REQUIRED: 'Frequency is required' }} />\n * {Fields.CustomTwicePerMonth && <Fields.CustomTwicePerMonth label=\"Frequency Options\" />}\n * <Fields.AnchorPayDate label=\"First pay date\" validationMessages={{ REQUIRED: 'Required' }} />\n * <Fields.AnchorEndOfPayPeriod label=\"First pay period end\" validationMessages={{ REQUIRED: 'Required' }} />\n * {Fields.Day1 && (\n * <Fields.Day1\n * label=\"First pay day of the month\"\n * validationMessages={{ REQUIRED: 'Required', DAY_RANGE: 'Must be 1–31' }}\n * />\n * )}\n * {Fields.Day2 && (\n * <Fields.Day2\n * label=\"Last pay day of the month\"\n * validationMessages={{ REQUIRED: 'Required', DAY_RANGE: 'Must be 1–31' }}\n * />\n * )}\n * <button type=\"submit\" disabled={paySchedule.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function usePayScheduleForm({\n companyId,\n payScheduleId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UsePayScheduleFormProps): HookLoadingResult | UsePayScheduleFormReady {\n const payScheduleQuery = usePaySchedulesGet(\n { companyId, payScheduleId: payScheduleId ?? '' },\n { enabled: !!payScheduleId },\n )\n\n const paymentConfigsQuery = usePaymentConfigsGet({ companyUuid: companyId })\n\n const currentPaySchedule = payScheduleQuery.data?.payScheduleShow ?? null\n const paymentSpeed = paymentConfigsQuery.data?.paymentConfigs?.paymentSpeed\n const paymentSpeedDays = parsePaymentSpeedDays(paymentSpeed)\n\n const isCreateMode = !currentPaySchedule\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createPayScheduleSchema({ mode, optionalFieldsToRequire }),\n [mode, optionalFieldsToRequire],\n )\n\n const resolvedDefaults: PayScheduleFormData = {\n customName: currentPaySchedule?.customName ?? partnerDefaults?.customName ?? '',\n frequency: (currentPaySchedule?.frequency ??\n partnerDefaults?.frequency ??\n 'Every week') as PayScheduleFrequency,\n customTwicePerMonth: deriveCustomTwicePerMonth(\n currentPaySchedule?.frequency ?? partnerDefaults?.frequency,\n currentPaySchedule?.day1 ?? partnerDefaults?.day1 ?? undefined,\n currentPaySchedule?.day2 ?? partnerDefaults?.day2 ?? undefined,\n ),\n anchorPayDate:\n currentPaySchedule?.anchorPayDate?.toString() ?? partnerDefaults?.anchorPayDate ?? null,\n anchorEndOfPayPeriod:\n currentPaySchedule?.anchorEndOfPayPeriod?.toString() ??\n partnerDefaults?.anchorEndOfPayPeriod ??\n null,\n day1: currentPaySchedule?.day1 ?? partnerDefaults?.day1 ?? NaN,\n day2: currentPaySchedule?.day2 ?? partnerDefaults?.day2 ?? NaN,\n }\n\n const formMethods = useForm<PayScheduleFormData, unknown, PayScheduleFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const watchedFrequency = useWatch({ control: formMethods.control, name: 'frequency' })\n const watchedCustomTwicePerMonth = useWatch({\n control: formMethods.control,\n name: 'customTwicePerMonth',\n })\n const watchedAnchorPayDate = useWatch({ control: formMethods.control, name: 'anchorPayDate' })\n const watchedAnchorEndOfPayPeriod = useWatch({\n control: formMethods.control,\n name: 'anchorEndOfPayPeriod',\n })\n const watchedDay1 = useWatch({ control: formMethods.control, name: 'day1' })\n const watchedDay2 = useWatch({ control: formMethods.control, name: 'day2' })\n\n useEffect(() => {\n if (watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === '1st15th') {\n formMethods.setValue('day1', 15)\n formMethods.setValue('day2', 31)\n }\n }, [watchedFrequency, watchedCustomTwicePerMonth, formMethods.setValue])\n\n const formattedAnchorPayDate = formatWatchedDate(watchedAnchorPayDate)\n const formattedAnchorEndOfPayPeriod = formatWatchedDate(watchedAnchorEndOfPayPeriod)\n\n const previewEnabled = Boolean(formattedAnchorPayDate && formattedAnchorEndOfPayPeriod)\n\n const previewQuery = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: watchedFrequency,\n ...(formattedAnchorPayDate && { anchorPayDate: new RFCDate(formattedAnchorPayDate) }),\n ...(formattedAnchorEndOfPayPeriod && {\n anchorEndOfPayPeriod: new RFCDate(formattedAnchorEndOfPayPeriod),\n }),\n day1: watchedDay1 || undefined,\n day2: watchedDay2 || undefined,\n } as Parameters<typeof usePaySchedulesGetPreview>[0],\n { enabled: previewEnabled },\n )\n\n const payPeriodPreview: PaySchedulePreviewPayPeriod[] | undefined =\n previewQuery.data?.paySchedulePreview?.payPeriods\n const payPreviewLoading = previewQuery.isLoading && previewEnabled\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const isPending = createPayScheduleMutation.isPending || updatePayScheduleMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('PayScheduleForm')\n\n const queries = payScheduleId ? [payScheduleQuery, paymentConfigsQuery] : [paymentConfigsQuery]\n const errorHandling = composeErrorHandler(queries, { submitError, setSubmitError })\n\n const showCustomTwicePerMonth = watchedFrequency === 'Twice per month'\n const showDay1 =\n watchedFrequency === 'Monthly' ||\n (watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === 'custom')\n const showDay2 = watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === 'custom'\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildPayScheduleFieldsMetadata(baseMetadata)\n\n const onSubmit = async (): Promise<HookSubmitResult<PayScheduleShow> | undefined> => {\n let submitResult: HookSubmitResult<PayScheduleShow> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: PayScheduleFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const anchorPayDate = payload.anchorPayDate ?? ''\n const anchorEndOfPayPeriod = payload.anchorEndOfPayPeriod ?? ''\n\n if (isCreateMode) {\n const result = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId,\n payScheduleCreateRequest: {\n frequency: payload.frequency,\n anchorPayDate: new RFCDate(anchorPayDate),\n anchorEndOfPayPeriod: new RFCDate(anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1 || undefined,\n day2: payload.day2 || undefined,\n },\n },\n })\n\n submitResult = { mode: 'create', data: result.payScheduleShow! }\n } else {\n const result = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule.uuid,\n companyId,\n payScheduleUpdateRequest: {\n frequency: payload.frequency,\n anchorPayDate: new RFCDate(anchorPayDate),\n anchorEndOfPayPeriod: new RFCDate(anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1 || undefined,\n day2: payload.day2 || undefined,\n version: currentPaySchedule.version!,\n },\n },\n })\n\n submitResult = { mode: 'update', data: result.payScheduleShow! }\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const isDataLoading =\n paymentConfigsQuery.isLoading || (payScheduleId ? payScheduleQuery.isLoading : false)\n\n if (isDataLoading) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n paySchedule: currentPaySchedule,\n payPeriodPreview: payPeriodPreview ?? null,\n payPreviewLoading,\n paymentSpeedDays,\n },\n status: {\n isPending,\n mode: isCreateMode ? ('create' as const) : ('update' as const),\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n CustomName: CustomNameField,\n Frequency: FrequencyField,\n CustomTwicePerMonth: showCustomTwicePerMonth ? CustomTwicePerMonthField : undefined,\n AnchorPayDate: AnchorPayDateField,\n AnchorEndOfPayPeriod: AnchorEndOfPayPeriodField,\n Day1: showDay1 ? Day1Field : undefined,\n Day2: showDay2 ? Day2Field : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type UsePayScheduleFormResult = HookLoadingResult | UsePayScheduleFormReady\n/**\n * Type of `form.fieldsMetadata` returned by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type PayScheduleFieldsMetadata = ReturnType<typeof buildPayScheduleFieldsMetadata>\n"],"names":["FREQUENCY_OPTIONS","FREQUENCY_ENTRIES","o","TWICE_PER_MONTH_OPTIONS","TWICE_PER_MONTH_ENTRIES","formatWatchedDate","value","formatDateToStringDate","deriveCustomTwicePerMonth","frequency","day1","day2","buildPayScheduleFieldsMetadata","base","withOptions","usePayScheduleForm","companyId","payScheduleId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","payScheduleQuery","usePaySchedulesGet","paymentConfigsQuery","usePaymentConfigsGet","currentPaySchedule","paymentSpeed","paymentSpeedDays","parsePaymentSpeedDays","isCreateMode","mode","schema","metadataConfig","useMemo","createPayScheduleSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedFrequency","useWatch","watchedCustomTwicePerMonth","watchedAnchorPayDate","watchedAnchorEndOfPayPeriod","watchedDay1","watchedDay2","useEffect","formattedAnchorPayDate","formattedAnchorEndOfPayPeriod","previewEnabled","previewQuery","usePaySchedulesGetPreview","RFCDate","payPeriodPreview","payPreviewLoading","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","showCustomTwicePerMonth","showDay1","showDay2","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","submitResult","resolve","data","payload","anchorPayDate","anchorEndOfPayPeriod","hookFormInternals","useHookFormInternals","CustomNameField","FrequencyField","CustomTwicePerMonthField","AnchorPayDateField","AnchorEndOfPayPeriodField","Day1Field","Day2Field","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;AAoJA,MAAMA,IAA2E;AAAA,EAC/E,EAAE,OAAO,cAAc,OAAO,aAAA;AAAA,EAC9B,EAAE,OAAO,oBAAoB,OAAO,mBAAA;AAAA,EACpC,EAAE,OAAO,mBAAmB,OAAO,kBAAA;AAAA,EACnC,EAAE,OAAO,WAAW,OAAO,UAAA;AAC7B,GAEMC,KAA4CD,EAAkB,IAAI,CAAAE,MAAKA,EAAE,KAAK,GAE9EC,IAA0B;AAAA,EAC9B,EAAE,OAAO,WAAW,OAAO,iCAAA;AAAA,EAC3B,EAAE,OAAO,UAAU,OAAO,SAAA;AAC5B,GAEMC,KAA0BD,EAAwB,IAAI,CAAAD,MAAKA,EAAE,KAAK;AAExE,SAASG,EAAkBC,GAAwB;AACjD,SAAIA,aAAiB,OAAaC,GAAuBD,CAAK,KAAK,KAC/D,OAAOA,KAAU,YAAYA,IAAcA,IACxC;AACT;AAEA,SAASE,GACPC,GACAC,GACAC,GACQ;AACR,SAAIF,MAAc,oBAA0B,KACxCC,MAAS,MAAMC,MAAS,KAAW,YAChC;AACT;AAGA,SAASC,GAA+BC,GAAwD;AAC9F,SAAO;AAAA,IACL,YAAYA,EAAK;AAAA,IACjB,WAAWC;AAAA,MACTD,EAAK;AAAA,MACLb;A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tB,MAAMlB,IAAWmB,KAAY;AAAA,QAC7B,MAAMlB,IAAWmB,KAAY;AAAA,MAAA;AAAA,MAE/B,gBAAAhB;AAAA,MACA,mBAAAQ;AAAA,MACA,yBAAyBS,GAA8BpD,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
1
+ {"version":3,"file":"usePayScheduleForm.js","sources":["../../../../../../src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.tsx"],"sourcesContent":["import { useEffect, useMemo } from 'react'\nimport type { ComponentType } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { PaySchedulePreviewPayPeriod } from '@gusto/embedded-api/models/components/payschedulepreviewpayperiod'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaymentConfigsGet } from '@gusto/embedded-api/react-query/paymentConfigsGet'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport {\n createPayScheduleSchema,\n type PayScheduleOptionalFieldsToRequire,\n type PayScheduleFormData,\n type PayScheduleFormOutputs,\n type PayScheduleFrequency,\n} from './payScheduleSchema'\nimport {\n CustomNameField,\n FrequencyField,\n CustomTwicePerMonthField,\n AnchorPayDateField,\n AnchorEndOfPayPeriodField,\n Day1Field,\n Day2Field,\n} from './fields'\nimport type {\n CustomNameFieldProps,\n FrequencyFieldProps,\n CustomTwicePerMonthFieldProps,\n AnchorPayDateFieldProps,\n AnchorEndOfPayPeriodFieldProps,\n Day1FieldProps,\n Day2FieldProps,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { parsePaymentSpeedDays } from '@/hooks/useCompanyPaymentSpeed'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\n\nexport type { PayScheduleOptionalFieldsToRequire } from './payScheduleSchema'\n\n/**\n * Configuration options for {@link usePayScheduleForm}.\n *\n * @remarks\n * Presence or absence of `payScheduleId` selects between update and create mode.\n *\n * @public\n */\nexport interface UsePayScheduleFormProps {\n /** UUID of the company that owns the pay schedule. */\n companyId: string\n /**\n * When set, loads that pay schedule and updates it on submit. When omitted,\n * the form is in create mode and creates a new schedule on submit.\n */\n payScheduleId?: string\n /** Override fields that are optional on a given mode to be required. See `PayScheduleOptionalFieldsToRequire`. */\n optionalFieldsToRequire?: PayScheduleOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update. */\n defaultValues?: Partial<PayScheduleFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `usePayScheduleForm().form.Fields`.\n *\n * @remarks\n * `CustomTwicePerMonth`, `Day1`, and `Day2` are conditionally `undefined` based\n * on the selected frequency and twice-per-month strategy — always null-check them\n * before rendering.\n *\n * @public\n */\nexport interface PayScheduleFormFields {\n /** Bound to `customName`. Display name text input. Always available. */\n CustomName: ComponentType<CustomNameFieldProps>\n /** Bound to `frequency`. Frequency selector. Always available. */\n Frequency: ComponentType<FrequencyFieldProps>\n /** Bound to `customTwicePerMonth`. Twice-per-month strategy radio group. Only available when frequency is `'Twice per month'`. */\n CustomTwicePerMonth: ComponentType<CustomTwicePerMonthFieldProps> | undefined\n /** Bound to `anchorPayDate`. First pay date picker. Always available. */\n AnchorPayDate: ComponentType<AnchorPayDateFieldProps>\n /** Bound to `anchorEndOfPayPeriod`. First pay period end date picker. Always available. */\n AnchorEndOfPayPeriod: ComponentType<AnchorEndOfPayPeriodFieldProps>\n /** Bound to `day1`. First-pay-day-of-month number input. Available when frequency is `'Monthly'`, or `'Twice per month'` with `'custom'` strategy. */\n Day1: ComponentType<Day1FieldProps> | undefined\n /** Bound to `day2`. Last-pay-day-of-month number input. Available when frequency is `'Twice per month'` with `'custom'` strategy. */\n Day2: ComponentType<Day2FieldProps> | undefined\n}\n\n/**\n * Ready-state shape returned by {@link usePayScheduleForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with the\n * pay-schedule-specific `data`, `status`, `actions`, and `form.Fields` shape.\n *\n * @public\n */\nexport interface UsePayScheduleFormReady extends BaseFormHookReady<\n PayScheduleFieldsMetadata,\n PayScheduleFormData,\n PayScheduleFormFields\n> {\n /** Static entity data resolved from the API. */\n data: {\n /** The pay schedule loaded for update; `null` in create mode. */\n paySchedule: PayScheduleShow | null\n /** Upcoming pay periods previewed from current form values; `null` until the anchor date fields are complete. */\n payPeriodPreview: PaySchedulePreviewPayPeriod[] | null\n /** `true` while the pay period preview request is in flight. */\n payPreviewLoading: boolean\n /** Business days the company needs to process payroll, derived from payment configs; `null` if unavailable. */\n paymentSpeedDays: number | null\n }\n /** Reactive status flags. */\n status: {\n /** `true` while the create or update mutation is in flight. */\n isPending: boolean\n /** Whether the form is creating a new schedule or updating an existing one. */\n mode: 'create' | 'update'\n }\n /** Available actions. */\n actions: {\n /** Validates the form and dispatches the create or update mutation. Returns the saved schedule, or `undefined` if validation failed. */\n onSubmit: () => Promise<HookSubmitResult<PayScheduleShow> | undefined>\n }\n}\n\nconst FREQUENCY_OPTIONS: Array<{ value: PayScheduleFrequency; label: string }> = [\n { value: 'Every week', label: 'Every week' },\n { value: 'Every other week', label: 'Every other week' },\n { value: 'Twice per month', label: 'Twice per month' },\n { value: 'Monthly', label: 'Monthly' },\n]\n\nconst FREQUENCY_ENTRIES: PayScheduleFrequency[] = FREQUENCY_OPTIONS.map(o => o.value)\n\nconst TWICE_PER_MONTH_OPTIONS = [\n { value: '1st15th', label: '15th and Last day of the month' },\n { value: 'custom', label: 'Custom' },\n]\n\nconst TWICE_PER_MONTH_ENTRIES = TWICE_PER_MONTH_OPTIONS.map(o => o.value)\n\nfunction formatWatchedDate(value: unknown): string {\n if (value instanceof Date) return formatDateToStringDate(value) || ''\n if (typeof value === 'string' && value) return value\n return ''\n}\n\nfunction deriveCustomTwicePerMonth(\n frequency: string | undefined,\n day1: number | undefined,\n day2: number | undefined,\n): string {\n if (frequency !== 'Twice per month') return ''\n if (day1 === 15 && day2 === 31) return '1st15th'\n // Only pre-select 'custom' when there are real day values to represent (e.g.\n // editing an existing custom schedule). With no day basis, leave the radio\n // unselected so its required validation prompts an explicit choice rather\n // than silently forcing empty day1/day2 fields into a required state.\n if (day1 != null && day2 != null) return 'custom'\n return ''\n}\n\n/** @internal */\nfunction buildPayScheduleFieldsMetadata(base: Record<keyof PayScheduleFormData, FieldMetadata>) {\n return {\n customName: base.customName,\n frequency: withOptions<PayScheduleFrequency>(\n base.frequency,\n FREQUENCY_OPTIONS,\n FREQUENCY_ENTRIES,\n ),\n customTwicePerMonth: withOptions<string>(\n base.customTwicePerMonth,\n TWICE_PER_MONTH_OPTIONS,\n TWICE_PER_MONTH_ENTRIES,\n ),\n anchorPayDate: base.anchorPayDate,\n anchorEndOfPayPeriod: base.anchorEndOfPayPeriod,\n day1: base.day1,\n day2: base.day2,\n } satisfies FieldsMetadata\n}\n\n/**\n * Form hook for creating or updating a company pay schedule.\n *\n * @remarks\n * When `payScheduleId` is supplied the hook loads that schedule and issues an\n * update on submit; when omitted it operates in create mode. While both anchor\n * date fields are filled in, the hook fetches a live pay period calendar\n * preview exposed on `data.payPeriodPreview`. `data.paymentSpeedDays` reflects\n * the company's payment configuration and is useful for surfacing UI hints\n * about how far ahead the first pay date must be.\n *\n * @param props - See {@link UsePayScheduleFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UsePayScheduleFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * usePayScheduleForm,\n * SDKFormProvider,\n * type UsePayScheduleFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function PaySchedulePage({ companyId }: { companyId: string }) {\n * const paySchedule = usePayScheduleForm({ companyId })\n *\n * if (paySchedule.isLoading) return <div>Loading...</div>\n *\n * return <PayScheduleFormReady paySchedule={paySchedule} />\n * }\n *\n * function PayScheduleFormReady({ paySchedule }: { paySchedule: UsePayScheduleFormReady }) {\n * const { Fields } = paySchedule.form\n *\n * return (\n * <SDKFormProvider formHookResult={paySchedule}>\n * <form\n * onSubmit={e => {\n * e.preventDefault()\n * void paySchedule.actions.onSubmit()\n * }}\n * >\n * <Fields.CustomName label=\"Name\" validationMessages={{ REQUIRED: 'Name is required' }} />\n * <Fields.Frequency label=\"Frequency\" validationMessages={{ REQUIRED: 'Frequency is required' }} />\n * {Fields.CustomTwicePerMonth && <Fields.CustomTwicePerMonth label=\"Frequency Options\" />}\n * <Fields.AnchorPayDate label=\"First pay date\" validationMessages={{ REQUIRED: 'Required' }} />\n * <Fields.AnchorEndOfPayPeriod label=\"First pay period end\" validationMessages={{ REQUIRED: 'Required' }} />\n * {Fields.Day1 && (\n * <Fields.Day1\n * label=\"First pay day of the month\"\n * validationMessages={{ REQUIRED: 'Required', DAY_RANGE: 'Must be 1–31' }}\n * />\n * )}\n * {Fields.Day2 && (\n * <Fields.Day2\n * label=\"Last pay day of the month\"\n * validationMessages={{ REQUIRED: 'Required', DAY_RANGE: 'Must be 1–31' }}\n * />\n * )}\n * <button type=\"submit\" disabled={paySchedule.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function usePayScheduleForm({\n companyId,\n payScheduleId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UsePayScheduleFormProps): HookLoadingResult | UsePayScheduleFormReady {\n const payScheduleQuery = usePaySchedulesGet(\n { companyId, payScheduleId: payScheduleId ?? '' },\n { enabled: !!payScheduleId },\n )\n\n const paymentConfigsQuery = usePaymentConfigsGet({ companyUuid: companyId })\n\n const currentPaySchedule = payScheduleQuery.data?.payScheduleShow ?? null\n const paymentSpeed = paymentConfigsQuery.data?.paymentConfigs?.paymentSpeed\n const paymentSpeedDays = parsePaymentSpeedDays(paymentSpeed)\n\n const isCreateMode = !currentPaySchedule\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createPayScheduleSchema({ mode, optionalFieldsToRequire }),\n [mode, optionalFieldsToRequire],\n )\n\n const resolvedDefaults: PayScheduleFormData = {\n customName: currentPaySchedule?.customName ?? partnerDefaults?.customName ?? '',\n frequency: (currentPaySchedule?.frequency ??\n partnerDefaults?.frequency ??\n 'Every week') as PayScheduleFrequency,\n customTwicePerMonth: deriveCustomTwicePerMonth(\n currentPaySchedule?.frequency ?? partnerDefaults?.frequency,\n currentPaySchedule?.day1 ?? partnerDefaults?.day1 ?? undefined,\n currentPaySchedule?.day2 ?? partnerDefaults?.day2 ?? undefined,\n ),\n anchorPayDate:\n currentPaySchedule?.anchorPayDate?.toString() ?? partnerDefaults?.anchorPayDate ?? null,\n anchorEndOfPayPeriod:\n currentPaySchedule?.anchorEndOfPayPeriod?.toString() ??\n partnerDefaults?.anchorEndOfPayPeriod ??\n null,\n day1: currentPaySchedule?.day1 ?? partnerDefaults?.day1 ?? NaN,\n day2: currentPaySchedule?.day2 ?? partnerDefaults?.day2 ?? NaN,\n }\n\n const formMethods = useForm<PayScheduleFormData, unknown, PayScheduleFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const watchedFrequency = useWatch({ control: formMethods.control, name: 'frequency' })\n const watchedCustomTwicePerMonth = useWatch({\n control: formMethods.control,\n name: 'customTwicePerMonth',\n })\n const watchedAnchorPayDate = useWatch({ control: formMethods.control, name: 'anchorPayDate' })\n const watchedAnchorEndOfPayPeriod = useWatch({\n control: formMethods.control,\n name: 'anchorEndOfPayPeriod',\n })\n const watchedDay1 = useWatch({ control: formMethods.control, name: 'day1' })\n const watchedDay2 = useWatch({ control: formMethods.control, name: 'day2' })\n\n useEffect(() => {\n if (watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === '1st15th') {\n formMethods.setValue('day1', 15)\n formMethods.setValue('day2', 31)\n }\n }, [watchedFrequency, watchedCustomTwicePerMonth, formMethods.setValue])\n\n const formattedAnchorPayDate = formatWatchedDate(watchedAnchorPayDate)\n const formattedAnchorEndOfPayPeriod = formatWatchedDate(watchedAnchorEndOfPayPeriod)\n\n const previewEnabled = Boolean(formattedAnchorPayDate && formattedAnchorEndOfPayPeriod)\n\n const previewQuery = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: watchedFrequency,\n ...(formattedAnchorPayDate && { anchorPayDate: new RFCDate(formattedAnchorPayDate) }),\n ...(formattedAnchorEndOfPayPeriod && {\n anchorEndOfPayPeriod: new RFCDate(formattedAnchorEndOfPayPeriod),\n }),\n day1: watchedDay1 || undefined,\n day2: watchedDay2 || undefined,\n } as Parameters<typeof usePaySchedulesGetPreview>[0],\n { enabled: previewEnabled },\n )\n\n const payPeriodPreview: PaySchedulePreviewPayPeriod[] | undefined =\n previewQuery.data?.paySchedulePreview?.payPeriods\n const payPreviewLoading = previewQuery.isLoading && previewEnabled\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const isPending = createPayScheduleMutation.isPending || updatePayScheduleMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('PayScheduleForm')\n\n const queries = payScheduleId ? [payScheduleQuery, paymentConfigsQuery] : [paymentConfigsQuery]\n const errorHandling = composeErrorHandler(queries, { submitError, setSubmitError })\n\n const showCustomTwicePerMonth = watchedFrequency === 'Twice per month'\n const showDay1 =\n watchedFrequency === 'Monthly' ||\n (watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === 'custom')\n const showDay2 = watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === 'custom'\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildPayScheduleFieldsMetadata(baseMetadata)\n\n const onSubmit = async (): Promise<HookSubmitResult<PayScheduleShow> | undefined> => {\n let submitResult: HookSubmitResult<PayScheduleShow> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: PayScheduleFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const anchorPayDate = payload.anchorPayDate ?? ''\n const anchorEndOfPayPeriod = payload.anchorEndOfPayPeriod ?? ''\n\n if (isCreateMode) {\n const result = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId,\n payScheduleCreateRequest: {\n frequency: payload.frequency,\n anchorPayDate: new RFCDate(anchorPayDate),\n anchorEndOfPayPeriod: new RFCDate(anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1 || undefined,\n day2: payload.day2 || undefined,\n },\n },\n })\n\n submitResult = { mode: 'create', data: result.payScheduleShow! }\n } else {\n const result = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule.uuid,\n companyId,\n payScheduleUpdateRequest: {\n frequency: payload.frequency,\n anchorPayDate: new RFCDate(anchorPayDate),\n anchorEndOfPayPeriod: new RFCDate(anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1 || undefined,\n day2: payload.day2 || undefined,\n version: currentPaySchedule.version!,\n },\n },\n })\n\n submitResult = { mode: 'update', data: result.payScheduleShow! }\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const isDataLoading =\n paymentConfigsQuery.isLoading || (payScheduleId ? payScheduleQuery.isLoading : false)\n\n if (isDataLoading) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n paySchedule: currentPaySchedule,\n payPeriodPreview: payPeriodPreview ?? null,\n payPreviewLoading,\n paymentSpeedDays,\n },\n status: {\n isPending,\n mode: isCreateMode ? ('create' as const) : ('update' as const),\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n CustomName: CustomNameField,\n Frequency: FrequencyField,\n CustomTwicePerMonth: showCustomTwicePerMonth ? CustomTwicePerMonthField : undefined,\n AnchorPayDate: AnchorPayDateField,\n AnchorEndOfPayPeriod: AnchorEndOfPayPeriodField,\n Day1: showDay1 ? Day1Field : undefined,\n Day2: showDay2 ? Day2Field : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type UsePayScheduleFormResult = HookLoadingResult | UsePayScheduleFormReady\n/**\n * Type of `form.fieldsMetadata` returned by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type PayScheduleFieldsMetadata = ReturnType<typeof buildPayScheduleFieldsMetadata>\n"],"names":["FREQUENCY_OPTIONS","FREQUENCY_ENTRIES","o","TWICE_PER_MONTH_OPTIONS","TWICE_PER_MONTH_ENTRIES","formatWatchedDate","value","formatDateToStringDate","deriveCustomTwicePerMonth","frequency","day1","day2","buildPayScheduleFieldsMetadata","base","withOptions","usePayScheduleForm","companyId","payScheduleId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","payScheduleQuery","usePaySchedulesGet","paymentConfigsQuery","usePaymentConfigsGet","currentPaySchedule","paymentSpeed","paymentSpeedDays","parsePaymentSpeedDays","isCreateMode","mode","schema","metadataConfig","useMemo","createPayScheduleSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedFrequency","useWatch","watchedCustomTwicePerMonth","watchedAnchorPayDate","watchedAnchorEndOfPayPeriod","watchedDay1","watchedDay2","useEffect","formattedAnchorPayDate","formattedAnchorEndOfPayPeriod","previewEnabled","previewQuery","usePaySchedulesGetPreview","RFCDate","payPeriodPreview","payPreviewLoading","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","showCustomTwicePerMonth","showDay1","showDay2","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","submitResult","resolve","data","payload","anchorPayDate","anchorEndOfPayPeriod","hookFormInternals","useHookFormInternals","CustomNameField","FrequencyField","CustomTwicePerMonthField","AnchorPayDateField","AnchorEndOfPayPeriodField","Day1Field","Day2Field","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;AAoJA,MAAMA,IAA2E;AAAA,EAC/E,EAAE,OAAO,cAAc,OAAO,aAAA;AAAA,EAC9B,EAAE,OAAO,oBAAoB,OAAO,mBAAA;AAAA,EACpC,EAAE,OAAO,mBAAmB,OAAO,kBAAA;AAAA,EACnC,EAAE,OAAO,WAAW,OAAO,UAAA;AAC7B,GAEMC,KAA4CD,EAAkB,IAAI,CAAAE,MAAKA,EAAE,KAAK,GAE9EC,IAA0B;AAAA,EAC9B,EAAE,OAAO,WAAW,OAAO,iCAAA;AAAA,EAC3B,EAAE,OAAO,UAAU,OAAO,SAAA;AAC5B,GAEMC,KAA0BD,EAAwB,IAA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M;AAAA,MACJ,aAAavC;AAAA,MACb,kBAAkB4B,KAAoB;AAAA,MACtC,mBAAAC;AAAA,MACA,kBAAA3B;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAAgC;AAAA,MACA,MAAM9B,IAAgB,WAAsB;AAAA,IAAA;AAAA,IAE9C,SAAS,EAAE,UAAA2C,EAAA;AAAA,IACX,eAAAR;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,YAAYiB;AAAA,QACZ,WAAWC;AAAA,QACX,qBAAqBhB,IAA0BiB,KAA2B;AAAA,QAC1E,eAAeC;AAAA,QACf,sBAAsBC;AAAA,QACtB,MAAMlB,IAAWmB,KAAY;AAAA,QAC7B,MAAMlB,IAAWmB,KAAY;AAAA,MAAA;AAAA,MAE/B,gBAAAhB;AAAA,MACA,mBAAAQ;AAAA,MACA,yBAAyBS,GAA8BpD,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
@@ -9,15 +9,13 @@ import "@gusto/embedded-api/models/errors/gustoembeddederror";
9
9
  import "@gusto/embedded-api/models/errors/sdkvalidationerror";
10
10
  import "@gusto/embedded-api/models/errors/unprocessableentityerror";
11
11
  import "@gusto/embedded-api/models/errors/httpclienterrors";
12
- import "dompurify";
13
- import "../../../../contexts/LocaleProvider/useLocale.js";
14
12
  import "../../../../shared/constants.js";
15
13
  import "../../../../contexts/ComponentAdapter/useComponentContext.js";
16
14
  import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
17
15
  import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
18
- const [f, v] = t("StateTaxesFormContext");
16
+ const [d, u] = t("StateTaxesFormContext");
19
17
  export {
20
- v as StateTaxesFormProvider,
21
- f as useStateTaxesForm
18
+ u as StateTaxesFormProvider,
19
+ d as useStateTaxesForm
22
20
  };
23
21
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/context.ts"],"sourcesContent":["import type { TaxRequirementsState } from '@gusto/embedded-api/models/components/taxrequirementsstate'\nimport { createCompoundContext } from '@/components/Base'\n\ninterface StateTaxFormContext {\n isPending: boolean\n state: string\n stateTaxRequirements: TaxRequirementsState\n handleCancel: () => void\n}\n\nconst [useStateTaxesForm, StateTaxesFormProvider] =\n createCompoundContext<StateTaxFormContext>('StateTaxesFormContext')\n\nexport { useStateTaxesForm, StateTaxesFormProvider }\n"],"names":["useStateTaxesForm","StateTaxesFormProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAmBC,CAAsB,IAC9CC,EAA2C,uBAAuB;"}
1
+ {"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/context.ts"],"sourcesContent":["import type { TaxRequirementsState } from '@gusto/embedded-api/models/components/taxrequirementsstate'\nimport { createCompoundContext } from '@/components/Base'\n\ninterface StateTaxFormContext {\n isPending: boolean\n state: string\n stateTaxRequirements: TaxRequirementsState\n handleCancel: () => void\n}\n\nconst [useStateTaxesForm, StateTaxesFormProvider] =\n createCompoundContext<StateTaxFormContext>('StateTaxesFormContext')\n\nexport { useStateTaxesForm, StateTaxesFormProvider }\n"],"names":["useStateTaxesForm","StateTaxesFormProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAmBC,CAAsB,IAC9CC,EAA2C,uBAAuB;"}
@@ -9,15 +9,13 @@ import "@gusto/embedded-api/models/errors/gustoembeddederror";
9
9
  import "@gusto/embedded-api/models/errors/sdkvalidationerror";
10
10
  import "@gusto/embedded-api/models/errors/unprocessableentityerror";
11
11
  import "@gusto/embedded-api/models/errors/httpclienterrors";
12
- import "dompurify";
13
- import "../../../../contexts/LocaleProvider/useLocale.js";
14
12
  import "../../../../shared/constants.js";
15
13
  import "../../../../contexts/ComponentAdapter/useComponentContext.js";
16
14
  import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
17
15
  import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
18
- const [f, v] = t("StateTaxesListContext");
16
+ const [d, u] = t("StateTaxesListContext");
19
17
  export {
20
- v as StateTaxesListProvider,
21
- f as useStateTaxesList
18
+ u as StateTaxesListProvider,
19
+ d as useStateTaxesList
22
20
  };
23
21
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/context.ts"],"sourcesContent":["import type { TaxRequirementStatesList } from '@gusto/embedded-api/models/components/taxrequirementstateslist'\nimport { createCompoundContext } from '@/components/Base'\n\ntype StateTaxesListContextType = {\n isPending: boolean\n stateTaxRequirements: TaxRequirementStatesList[]\n handleContinue: () => void\n handleChange: (state: string) => void\n handleManageRates: (state: string) => void\n}\n\nconst [useStateTaxesList, StateTaxesListProvider] =\n createCompoundContext<StateTaxesListContextType>('StateTaxesListContext')\n\nexport { useStateTaxesList, StateTaxesListProvider }\n"],"names":["useStateTaxesList","StateTaxesListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;AAWA,MAAM,CAACA,GAAmBC,CAAsB,IAC9CC,EAAiD,uBAAuB;"}
1
+ {"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/context.ts"],"sourcesContent":["import type { TaxRequirementStatesList } from '@gusto/embedded-api/models/components/taxrequirementstateslist'\nimport { createCompoundContext } from '@/components/Base'\n\ntype StateTaxesListContextType = {\n isPending: boolean\n stateTaxRequirements: TaxRequirementStatesList[]\n handleContinue: () => void\n handleChange: (state: string) => void\n handleManageRates: (state: string) => void\n}\n\nconst [useStateTaxesList, StateTaxesListProvider] =\n createCompoundContext<StateTaxesListContextType>('StateTaxesListContext')\n\nexport { useStateTaxesList, StateTaxesListProvider }\n"],"names":["useStateTaxesList","StateTaxesListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;AAWA,MAAM,CAACA,GAAmBC,CAAsB,IAC9CC,EAAiD,uBAAuB;"}
@@ -2,25 +2,26 @@ import { jsx as s, jsxs as i } from "react/jsx-runtime";
2
2
  import { useMemo as n } from "react";
3
3
  import { useTranslation as h } from "react-i18next";
4
4
  import { useTaxRateManagement as x } from "./context.js";
5
- import { toHistoryRows as b, extractRequirementColumns as g } from "./toHistoryRows.js";
6
- import { AddRateAction as k } from "./AddRateAction.js";
5
+ import { toHistoryRows as b, extractRequirementColumns as C } from "./toHistoryRows.js";
6
+ import { AddRateAction as g } from "./AddRateAction.js";
7
7
  import { Flex as m } from "../../../Common/Flex/Flex.js";
8
- import { EmptyData as C } from "../../../Common/EmptyData/EmptyData.js";
8
+ import { EmptyData as k } from "../../../Common/EmptyData/EmptyData.js";
9
9
  import { useComponentContext as D } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
10
10
  import { useDateFormatter as w } from "../../../../hooks/useDateFormatter.js";
11
+ import { VisuallyHidden as H } from "../../../Common/VisuallyHidden/VisuallyHidden.js";
11
12
  import { useDataView as R } from "../../../Common/DataView/useDataView.js";
12
13
  import { DataView as B } from "../../../Common/DataView/DataView.js";
13
14
  const F = {
14
15
  current: "success",
15
16
  scheduled: "info",
16
17
  historical: "warning"
17
- }, H = {
18
+ }, L = {
18
19
  current: "currentBadge",
19
20
  scheduled: "scheduledBadge",
20
21
  historical: "historicalBadge"
21
22
  };
22
- function K({ group: t, showHeader: c = !0 }) {
23
- const { t: a } = h("Company.StateTaxes", { keyPrefix: "manageRates" }), o = D(), l = w(), { state: d } = x(), f = n(() => b(t.sets), [t.sets]), p = n(() => g(t.sets), [t.sets]), r = t.label ?? t.key, { ...u } = R({
23
+ function Y({ group: t, showHeader: c = !0 }) {
24
+ const { t: a } = h("Company.StateTaxes", { keyPrefix: "manageRates" }), o = D(), l = w(), { state: d } = x(), f = n(() => b(t.sets), [t.sets]), u = n(() => C(t.sets), [t.sets]), r = t.label ?? t.key, { ...p } = R({
24
25
  data: f,
25
26
  columns: [
26
27
  {
@@ -30,26 +31,26 @@ function K({ group: t, showHeader: c = !0 }) {
30
31
  },
31
32
  {
32
33
  key: "status",
33
- title: "",
34
- render: (e) => /* @__PURE__ */ s(o.Badge, { status: F[e.status], children: a(H[e.status]) })
34
+ title: /* @__PURE__ */ s(H, { children: a("statusColumnLabel") }),
35
+ render: (e) => /* @__PURE__ */ s(o.Badge, { status: F[e.status], children: a(L[e.status]) })
35
36
  },
36
- ...p.map((e) => ({
37
+ ...u.map((e) => ({
37
38
  key: e.key,
38
39
  title: e.label ?? e.key,
39
40
  render: (y) => y.values[e.key] ?? ""
40
41
  }))
41
42
  ],
42
- emptyState: () => /* @__PURE__ */ s(C, { title: a("emptyHistoryTitle"), description: a("emptyHistoryDescription") })
43
+ emptyState: () => /* @__PURE__ */ s(k, { title: a("emptyHistoryTitle"), description: a("emptyHistoryDescription") })
43
44
  });
44
45
  return /* @__PURE__ */ s("section", { "aria-label": r, children: /* @__PURE__ */ i(m, { flexDirection: "column", gap: 16, alignItems: "stretch", children: [
45
46
  c && /* @__PURE__ */ i(m, { justifyContent: "space-between", alignItems: "center", gap: 16, children: [
46
47
  /* @__PURE__ */ s(o.Heading, { as: "h3", children: r }),
47
- /* @__PURE__ */ s(k, { state: d, group: t })
48
+ /* @__PURE__ */ s(g, { state: d, group: t })
48
49
  ] }),
49
- /* @__PURE__ */ s(B, { label: r, ...u })
50
+ /* @__PURE__ */ s(B, { label: r, ...p })
50
51
  ] }) });
51
52
  }
52
53
  export {
53
- K as TaxRateHistorySection
54
+ Y as TaxRateHistorySection
54
55
  };
55
56
  //# sourceMappingURL=TaxRateHistorySection.js.map