@gusto/embedded-react-sdk 0.56.2 → 0.56.3

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 (183) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/components/Common/FieldCaption/FieldCaption.js +18 -24
  3. package/dist/components/Common/FieldCaption/FieldCaption.js.map +1 -1
  4. package/dist/components/Common/FieldCaption/FieldCaption.module.scss.js +3 -5
  5. package/dist/components/Common/FieldCaption/FieldCaption.module.scss.js.map +1 -1
  6. package/dist/components/Common/PaginationControl/PaginationControl.js +66 -62
  7. package/dist/components/Common/PaginationControl/PaginationControl.js.map +1 -1
  8. package/dist/components/Common/UI/Breadcrumbs/Breadcrumbs.js +1 -1
  9. package/dist/components/Common/UI/FileInput/FileInput.js +1 -1
  10. package/dist/components/Common/UI/ProgressBar/ProgressBar.js +4 -4
  11. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +6 -3
  12. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  13. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +6 -3
  14. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  15. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +8 -5
  16. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  17. package/dist/components/Company/BankAccount/BankAccountForm/context.js +6 -3
  18. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  19. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +6 -3
  20. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  21. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +11 -8
  22. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  23. package/dist/components/Company/Industry/Context.js +9 -6
  24. package/dist/components/Company/Industry/Context.js.map +1 -1
  25. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +6 -3
  26. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  27. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +6 -3
  28. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  29. package/dist/components/Company/OnboardingOverview/context.js +6 -3
  30. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  31. package/dist/components/Company/PaySchedule/management/PaySchedule.js +60 -0
  32. package/dist/components/Company/PaySchedule/management/PaySchedule.js.map +1 -0
  33. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.js +67 -0
  34. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.js.map +1 -0
  35. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +59 -0
  36. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -0
  37. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +57 -0
  38. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -0
  39. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +46 -0
  40. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -0
  41. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +101 -0
  42. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -0
  43. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +81 -0
  44. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -0
  45. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.js +18 -0
  46. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.js.map +1 -0
  47. package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js +56 -0
  48. package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -0
  49. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +34 -0
  50. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -0
  51. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js +77 -0
  52. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map +1 -0
  53. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.module.scss.js +10 -0
  54. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.module.scss.js.map +1 -0
  55. package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js +66 -0
  56. package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -0
  57. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +75 -57
  58. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
  59. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +6 -3
  60. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  61. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +6 -3
  62. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  63. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +6 -3
  64. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
  65. package/dist/components/Company/StateTaxes/shared/requirementSetError.js +15 -0
  66. package/dist/components/Company/StateTaxes/shared/requirementSetError.js.map +1 -0
  67. package/dist/components/Company/exports/companyManagement.js +7 -0
  68. package/dist/components/Company/exports/companyManagement.js.map +1 -0
  69. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +6 -3
  70. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  71. package/dist/components/Employee/FederalTaxes/shared/FederalTaxesView.js +1 -1
  72. package/dist/components/Employee/PaymentMethod/management/PaymentMethodBankForm.js +4 -4
  73. package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js +4 -4
  74. package/dist/components/Flow/Flow.js +1 -1
  75. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +28 -27
  76. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  77. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js +51 -58
  78. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js.map +1 -1
  79. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js +12 -7
  80. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js.map +1 -1
  81. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +87 -85
  82. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
  83. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +1 -1
  84. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
  85. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +55 -54
  86. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
  87. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +66 -62
  88. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
  89. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +129 -125
  90. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  91. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +30 -27
  92. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js.map +1 -1
  93. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js +41 -30
  94. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js.map +1 -1
  95. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.js.map +1 -1
  96. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +159 -152
  97. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
  98. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +61 -59
  99. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
  100. package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js +32 -31
  101. package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js.map +1 -1
  102. package/dist/components/Payroll/PayrollList/PayrollList.js +16 -16
  103. package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
  104. package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
  105. package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +61 -61
  106. package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
  107. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +192 -193
  108. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
  109. package/dist/components/Payroll/Transition/TransitionFlow.js +27 -22
  110. package/dist/components/Payroll/Transition/TransitionFlow.js.map +1 -1
  111. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js +55 -53
  112. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js.map +1 -1
  113. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js +44 -41
  114. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js.map +1 -1
  115. package/dist/components/Payroll/helpers.js +72 -67
  116. package/dist/components/Payroll/helpers.js.map +1 -1
  117. package/dist/components/Payroll/usePreparedPayrollData.js +37 -25
  118. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  119. package/dist/contexts/ApiProvider/ApiProvider.js +23 -22
  120. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
  121. package/dist/contexts/ApiProvider/informationRequestEnumHook.js +30 -0
  122. package/dist/contexts/ApiProvider/informationRequestEnumHook.js.map +1 -0
  123. package/dist/contexts/UnstableFeaturesProvider/useUnstableFeature.js.map +1 -1
  124. package/dist/helpers/dateFormatting.js.map +1 -1
  125. package/dist/helpers/formattedStrings.js +9 -8
  126. package/dist/helpers/formattedStrings.js.map +1 -1
  127. package/dist/i18n/I18n.js +2 -0
  128. package/dist/i18n/I18n.js.map +1 -1
  129. package/dist/i18n/en/Company.Management.PaySchedule.json.js +24 -0
  130. package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -0
  131. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +18 -0
  132. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -0
  133. package/dist/i18n/en/Company.StateTaxes.json.js +1 -1
  134. package/dist/i18n/en/Payroll.GrossUpModal.json.js +12 -14
  135. package/dist/i18n/en/Payroll.GrossUpModal.json.js.map +1 -1
  136. package/dist/i18n/en/Payroll.PayrollOverview.json.js +1 -1
  137. package/dist/i18n/en/common.json.js +36 -38
  138. package/dist/i18n/en/common.json.js.map +1 -1
  139. package/dist/index.js +137 -135
  140. package/dist/index.js.map +1 -1
  141. package/dist/package.json.js +1 -1
  142. package/dist/shared/constants.js +39 -31
  143. package/dist/shared/constants.js.map +1 -1
  144. package/dist/src/components/Company/PaySchedule/management/PaySchedule.d.ts +24 -0
  145. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.d.ts +10 -0
  146. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.d.ts +11 -0
  147. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +9 -0
  148. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +35 -0
  149. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +29 -0
  150. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/index.d.ts +1 -0
  151. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.d.ts +7 -0
  152. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.d.ts +12 -0
  153. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +9 -0
  154. package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +20 -0
  155. package/dist/src/components/Company/PaySchedule/management/PayScheduleOverview.d.ts +11 -0
  156. package/dist/src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.d.ts +18 -0
  157. package/dist/src/components/Company/PaySchedule/management/index.d.ts +1 -0
  158. package/dist/src/components/Company/PaySchedule/management/payScheduleManagementStateMachine.d.ts +12 -0
  159. package/dist/src/components/Company/StateTaxes/shared/requirementSetError.d.ts +18 -0
  160. package/dist/src/components/Company/StateTaxes/shared/requirementSetError.test.d.ts +1 -0
  161. package/dist/src/components/Company/exports/companyManagement.d.ts +2 -0
  162. package/dist/src/components/Payroll/PayrollBlocker/payrollHelpers.d.ts +12 -0
  163. package/dist/src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +6 -1
  164. package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.d.ts +2 -2
  165. package/dist/src/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.d.ts +6 -1
  166. package/dist/src/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.d.ts +7 -1
  167. package/dist/src/components/Payroll/helpers.d.ts +34 -0
  168. package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +6 -1
  169. package/dist/src/components/index.d.ts +12 -0
  170. package/dist/src/contexts/ApiProvider/informationRequestEnumHook.d.ts +14 -0
  171. package/dist/src/contexts/ApiProvider/informationRequestEnumHook.test.d.ts +1 -0
  172. package/dist/src/contexts/UnstableFeaturesProvider/useUnstableFeature.d.ts +2 -0
  173. package/dist/src/helpers/dateFormatting.d.ts +2 -2
  174. package/dist/src/helpers/formattedStrings.d.ts +15 -0
  175. package/dist/src/i18n/en/common.json.d.ts +0 -1
  176. package/dist/src/i18n/types.d.ts +96 -6
  177. package/dist/src/models/external.d.ts +12 -0
  178. package/dist/src/shared/constants.d.ts +16 -0
  179. package/dist/style.css +1 -1
  180. package/dist/types/sdkError.js +32 -21
  181. package/dist/types/sdkError.js.map +1 -1
  182. package/docs/guides/endpoint-inventory.json +59 -10
  183. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"PayrollConfigurationPresentation.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useRef } from 'react'\nimport classNames from 'classnames'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow as PayScheduleObject } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { Trans, useTranslation } from 'react-i18next'\nimport {\n useFormatEmployeePayRate,\n getRegularHours,\n getOvertimeHours,\n getTotalPtoHours,\n getAdditionalEarnings,\n getReimbursements,\n formatHoursDisplay,\n calculateGrossPay,\n} from '../helpers'\nimport { PayrollCategory } from '../payrollTypes'\nimport type { ApiPayrollBlocker } from '../PayrollBlocker/payrollHelpers'\nimport { PayrollBlockerAlerts } from '../PayrollBlocker/components/PayrollBlockerAlerts'\nimport styles from './PayrollConfigurationPresentation.module.scss'\nimport { useI18n } from '@/i18n'\nimport { DataView, Flex, FlexItem, Grid, PayrollLoading } from '@/components/Common'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport XCircle from '@/assets/icons/x-circle.svg?react'\nimport PlusCircle from '@/assets/icons/plus-circle.svg?react'\nimport CoinsHandSvg from '@/assets/icons/coins-hand.svg?react'\nimport { firstLastName, formatNumberAsCurrency } from '@/helpers/formattedStrings'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport useContainerBreakpoints from '@/hooks/useContainerBreakpoints/useContainerBreakpoints'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\ninterface PayrollConfigurationPresentationProps {\n /** CSS class name applied to the root element. */\n className?: string\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod?: PayrollPayPeriodType\n paySchedule?: PayScheduleObject\n onCalculatePayroll: () => void\n onEdit: (employee: Employee) => void\n onToggleExclude: (employeeCompensation: PayrollEmployeeCompensationsType) => void\n onViewBlockers: () => void\n payrollCategory?: PayrollCategory\n alerts?: ReactNode\n payrollAlert?: {\n label: string\n content?: ReactNode\n variant: 'info' | 'warning'\n }\n isPending?: boolean\n isCalculating?: boolean\n payrollBlockers?: ApiPayrollBlocker[]\n pagination?: PaginationControlProps\n withReimbursements?: boolean\n isCalculateDisabled?: boolean\n grossUpEnabled?: boolean\n onGrossUpSelect?: (employeeUuid: string) => void\n}\n\nconst getPayrollConfigurationTitle = (\n payPeriod: PayrollPayPeriodType | undefined,\n dateFormatter: ReturnType<typeof useDateFormatter>,\n) => {\n if (payPeriod?.startDate && payPeriod.endDate) {\n return dateFormatter.formatPayPeriod(payPeriod.startDate, payPeriod.endDate)\n }\n return { startDate: '', endDate: '' }\n}\n\n/** @internal */\nexport const PayrollConfigurationPresentation = ({\n className,\n employeeCompensations,\n employeeDetails,\n payPeriod,\n paySchedule,\n onEdit,\n onToggleExclude,\n onCalculatePayroll,\n onViewBlockers,\n payrollCategory = PayrollCategory.Regular,\n alerts,\n payrollAlert,\n isPending,\n isCalculating,\n payrollBlockers = [],\n pagination,\n withReimbursements = true,\n isCalculateDisabled = false,\n grossUpEnabled = false,\n onGrossUpSelect,\n}: PayrollConfigurationPresentationProps) => {\n const { Button, Heading, Text, Badge, Alert } = useComponentContext()\n useI18n('Payroll.PayrollConfiguration')\n const { t } = useTranslation('Payroll.PayrollConfiguration')\n const dateFormatter = useDateFormatter()\n const formatEmployeePayRate = useFormatEmployeePayRate()\n const isRegularRateOfPayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n const containerRef = useRef<HTMLDivElement>(null)\n const breakpoints = useContainerBreakpoints({ ref: containerRef })\n const isDesktop = breakpoints.includes('small')\n\n const employeeMap = new Map(employeeDetails.map(employee => [employee.uuid, employee]))\n\n const getEmployeeName = (employeeUuid: string) => {\n const employee = employeeMap.get(employeeUuid)\n const name = employee\n ? firstLastName({ first_name: employee.firstName, last_name: employee.lastName })\n : ''\n return name || t('unknownEmployeeFallback')\n }\n\n return (\n <div ref={containerRef} className={classNames(styles.container, className)}>\n <Flex flexDirection=\"column\" gap={32}>\n <Flex\n flexDirection={isDesktop ? 'row' : 'column'}\n justifyContent={isDesktop ? 'space-between' : 'normal'}\n alignItems={isDesktop ? 'center' : 'stretch'}\n gap={isDesktop ? 0 : 16}\n >\n <FlexItem>\n <Heading as=\"h1\">{t('pageTitle')}</Heading>\n {payPeriod && (\n <Text variant=\"supporting\">\n <Trans\n i18nKey={\n payrollCategory === PayrollCategory.Dismissal\n ? 'descriptionDismissal'\n : 'description'\n }\n t={t}\n components={{ dateWrapper: <Text weight=\"bold\" as=\"span\" /> }}\n values={{\n ...getPayrollConfigurationTitle(payPeriod, dateFormatter),\n payrollType: payrollCategory,\n }}\n />\n </Text>\n )}\n </FlexItem>\n <FlexItem flexGrow={isDesktop ? 0 : 0}>\n {isDesktop ? (\n <Button\n title={t('calculatePayrollTitle')}\n onClick={onCalculatePayroll}\n isDisabled={isCalculateDisabled || isPending || isCalculating}\n >\n {isCalculating ? t('calculatingPayroll') : t('calculatePayroll')}\n </Button>\n ) : (\n <Flex flexDirection=\"column\" justifyContent=\"normal\" alignItems=\"stretch\" gap={12}>\n <Button\n title={t('calculatePayrollTitle')}\n onClick={onCalculatePayroll}\n isDisabled={isCalculateDisabled || isPending || isCalculating}\n >\n {isCalculating ? t('calculatingPayroll') : t('calculatePayroll')}\n </Button>\n </Flex>\n )}\n </FlexItem>\n </Flex>\n\n {(alerts || payrollAlert) && (\n <Grid gap={16} gridTemplateColumns=\"1fr\">\n {payrollAlert && (\n <Alert label={payrollAlert.label} status={payrollAlert.variant}>\n {payrollAlert.content}\n </Alert>\n )}\n {alerts}\n </Grid>\n )}\n\n {isPending ? (\n <PayrollLoading\n title={isCalculating ? t('calculatingTitle') : t('loadingTitle')}\n description={isCalculating ? t('calculatingDescription') : t('loadingDescription')}\n />\n ) : (\n <>\n {payrollBlockers.length > 0 && (\n <PayrollBlockerAlerts\n blockers={payrollBlockers}\n onViewBlockersClick={onViewBlockers}\n />\n )}\n <Flex flexDirection=\"column\" gap={20}>\n <FlexItem>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('hoursAndEarningsTitle')}\n </Heading>\n <Text variant=\"supporting\">{t('hoursAndEarningsDescription')}</Text>\n </FlexItem>\n\n <DataView\n label={t('employeeCompensationsTitle')}\n columns={[\n {\n title: t('tableColumns.employees'),\n render: (item: PayrollEmployeeCompensationsType) => {\n const employee = employeeMap.get(item.employeeUuid || '')\n const payRateDisplay = formatEmployeePayRate(employee)\n return (\n <Flex flexDirection=\"column\" gap={0}>\n {getEmployeeName(item.employeeUuid || '')}\n {payRateDisplay && (\n <Text size=\"xs\" variant=\"supporting\">\n {payRateDisplay}\n </Text>\n )}\n {item.excluded && <Badge status=\"warning\">{t('skippedBadge')}</Badge>}\n </Flex>\n )\n },\n },\n {\n title: t('tableColumns.hours'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const hours = getRegularHours(item)\n const overtimeHours = getOvertimeHours(item)\n return formatHoursDisplay(hours + overtimeHours)\n },\n },\n {\n title: t('tableColumns.timeOff'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const ptoHours = getTotalPtoHours(item)\n return formatHoursDisplay(ptoHours)\n },\n },\n {\n title: t('tableColumns.additionalEarnings'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const earnings = getAdditionalEarnings(item)\n return formatNumberAsCurrency(earnings)\n },\n },\n ...(withReimbursements\n ? [\n {\n title: t('tableColumns.reimbursements'),\n justify: 'end' as const,\n render: (item: PayrollEmployeeCompensationsType) => {\n const reimbursements = getReimbursements(item)\n return formatNumberAsCurrency(reimbursements)\n },\n },\n ]\n : []),\n {\n title: t('tableColumns.totalPay'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n if (isRegularRateOfPayEnabled) {\n return formatNumberAsCurrency(Number(item.grossPay ?? 0))\n }\n const employee = employeeMap.get(item.employeeUuid || '')\n const calculatedGrossPay = employee\n ? calculateGrossPay(\n item,\n employee,\n payPeriod?.startDate,\n paySchedule,\n payrollCategory,\n )\n : 0\n return formatNumberAsCurrency(calculatedGrossPay)\n },\n },\n ]}\n data={employeeCompensations}\n itemMenu={(item: PayrollEmployeeCompensationsType) => (\n <HamburgerMenu\n items={[\n {\n label: t('editMenu.edit'),\n icon: <PencilSvg aria-hidden />,\n onClick: () => {\n const employee = employeeMap.get(item.employeeUuid || '')\n if (employee) {\n onEdit(employee)\n }\n },\n },\n {\n label: t(item.excluded ? 'editMenu.unskip' : 'editMenu.skip'),\n icon: item.excluded ? <PlusCircle aria-hidden /> : <XCircle aria-hidden />,\n onClick: () => {\n const employee = employeeMap.get(item.employeeUuid || '')\n if (employee) {\n onToggleExclude(item)\n }\n },\n },\n ...(grossUpEnabled\n ? [\n {\n label: t('editMenu.setNetEarnings'),\n icon: <CoinsHandSvg aria-hidden />,\n onClick: () => {\n if (item.employeeUuid) {\n onGrossUpSelect?.(item.employeeUuid)\n }\n },\n },\n ]\n : []),\n ]}\n triggerLabel={t('editMenu.edit')}\n />\n )}\n pagination={pagination}\n />\n </Flex>\n </>\n )}\n </Flex>\n </div>\n )\n}\n"],"names":["getPayrollConfigurationTitle","payPeriod","dateFormatter","PayrollConfigurationPresentation","className","employeeCompensations","employeeDetails","paySchedule","onEdit","onToggleExclude","onCalculatePayroll","onViewBlockers","payrollCategory","PayrollCategory","alerts","payrollAlert","isPending","isCalculating","payrollBlockers","pagination","withReimbursements","isCalculateDisabled","grossUpEnabled","onGrossUpSelect","Button","Heading","Text","Badge","Alert","useComponentContext","useI18n","useTranslation","useDateFormatter","formatEmployeePayRate","useFormatEmployeePayRate","isRegularRateOfPayEnabled","useUnstableFeature","containerRef","useRef","isDesktop","useContainerBreakpoints","employeeMap","employee","getEmployeeName","employeeUuid","firstLastName","jsx","classNames","styles","jsxs","Flex","FlexItem","Trans","Grid","PayrollLoading","Fragment","PayrollBlockerAlerts","DataView","item","payRateDisplay","hours","getRegularHours","overtimeHours","getOvertimeHours","formatHoursDisplay","ptoHours","getTotalPtoHours","earnings","getAdditionalEarnings","formatNumberAsCurrency","reimbursements","getReimbursements","calculatedGrossPay","calculateGrossPay","HamburgerMenu","PencilSvg","PlusCircle","XCircle","CoinsHandSvg"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgEA,MAAMA,KAA+B,CACnCC,GACAC,MAEID,GAAW,aAAaA,EAAU,UAC7BC,EAAc,gBAAgBD,EAAU,WAAWA,EAAU,OAAO,IAEtE,EAAE,WAAW,IAAI,SAAS,GAAA,GAItBE,KAAmC,CAAC;AAAA,EAC/C,WAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,WAAAL;AAAA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e;AAAA,cAAA;AAAA,YAAA;AAAA,YAGnC,YAAAvC;AAAA,UAAA;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,EAAA,CAEJ,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"PayrollConfigurationPresentation.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useRef } from 'react'\nimport classNames from 'classnames'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow as PayScheduleObject } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { Trans, useTranslation } from 'react-i18next'\nimport {\n useFormatEmployeePayRate,\n getRegularHours,\n getOvertimeHours,\n getTotalPtoHours,\n getAdditionalEarnings,\n getReimbursements,\n formatHoursDisplay,\n calculateGrossPay,\n} from '../helpers'\nimport { PayrollCategory } from '../payrollTypes'\nimport type { ApiPayrollBlocker } from '../PayrollBlocker/payrollHelpers'\nimport { PayrollBlockerAlerts } from '../PayrollBlocker/components/PayrollBlockerAlerts'\nimport styles from './PayrollConfigurationPresentation.module.scss'\nimport { useI18n } from '@/i18n'\nimport { DataView, Flex, FlexItem, Grid, PayrollLoading } from '@/components/Common'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport XCircle from '@/assets/icons/x-circle.svg?react'\nimport PlusCircle from '@/assets/icons/plus-circle.svg?react'\nimport CoinsHandSvg from '@/assets/icons/coins-hand.svg?react'\nimport { firstLastName, formatNumberAsCurrency } from '@/helpers/formattedStrings'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport useContainerBreakpoints from '@/hooks/useContainerBreakpoints/useContainerBreakpoints'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\ninterface PayrollConfigurationPresentationProps {\n /** CSS class name applied to the root element. */\n className?: string\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod?: PayrollPayPeriodType\n paySchedule?: PayScheduleObject\n onCalculatePayroll: () => void\n onEdit: (employee: Employee) => void\n onToggleExclude: (employeeCompensation: PayrollEmployeeCompensationsType) => void\n onViewBlockers: () => void\n payrollCategory?: PayrollCategory\n alerts?: ReactNode\n payrollAlert?: {\n label: string\n content?: ReactNode\n variant: 'info' | 'warning'\n }\n isPending?: boolean\n isCalculating?: boolean\n payrollBlockers?: ApiPayrollBlocker[]\n pagination?: PaginationControlProps\n withReimbursements?: boolean\n isCalculateDisabled?: boolean\n grossUpEnabled?: boolean\n onGrossUpSelect?: (employeeUuid: string) => void\n}\n\nconst getPayrollConfigurationTitle = (\n payPeriod: PayrollPayPeriodType | undefined,\n dateFormatter: ReturnType<typeof useDateFormatter>,\n) => {\n if (payPeriod?.startDate && payPeriod.endDate) {\n return dateFormatter.formatPayPeriod(payPeriod.startDate, payPeriod.endDate)\n }\n return { startDate: '', endDate: '' }\n}\n\n/** @internal */\nexport const PayrollConfigurationPresentation = ({\n className,\n employeeCompensations,\n employeeDetails,\n payPeriod,\n paySchedule,\n onEdit,\n onToggleExclude,\n onCalculatePayroll,\n onViewBlockers,\n payrollCategory = PayrollCategory.Regular,\n alerts,\n payrollAlert,\n isPending,\n isCalculating,\n payrollBlockers = [],\n pagination,\n withReimbursements = true,\n isCalculateDisabled = false,\n grossUpEnabled = false,\n onGrossUpSelect,\n}: PayrollConfigurationPresentationProps) => {\n const { Button, Heading, Text, Badge, Alert } = useComponentContext()\n useI18n('Payroll.PayrollConfiguration')\n const { t } = useTranslation('Payroll.PayrollConfiguration')\n const dateFormatter = useDateFormatter()\n const formatEmployeePayRate = useFormatEmployeePayRate()\n const isRegularRateOfPayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n const containerRef = useRef<HTMLDivElement>(null)\n const breakpoints = useContainerBreakpoints({ ref: containerRef })\n const isDesktop = breakpoints.includes('small')\n\n const employeeMap = new Map(employeeDetails.map(employee => [employee.uuid, employee]))\n\n const getEmployeeName = (employeeUuid: string) => {\n const employee = employeeMap.get(employeeUuid)\n const name = employee\n ? firstLastName({ first_name: employee.firstName, last_name: employee.lastName })\n : ''\n return name || t('unknownEmployeeFallback')\n }\n\n return (\n <div ref={containerRef} className={classNames(styles.container, className)}>\n <Flex flexDirection=\"column\" gap={32}>\n <Flex\n flexDirection={isDesktop ? 'row' : 'column'}\n justifyContent={isDesktop ? 'space-between' : 'normal'}\n alignItems={isDesktop ? 'center' : 'stretch'}\n gap={isDesktop ? 0 : 16}\n >\n <FlexItem>\n <Heading as=\"h1\">{t('pageTitle')}</Heading>\n {payPeriod && (\n <Text variant=\"supporting\">\n <Trans\n i18nKey={\n payrollCategory === PayrollCategory.Dismissal\n ? 'descriptionDismissal'\n : 'description'\n }\n t={t}\n components={{ dateWrapper: <Text weight=\"bold\" as=\"span\" /> }}\n values={{\n ...getPayrollConfigurationTitle(payPeriod, dateFormatter),\n payrollType: payrollCategory,\n }}\n />\n </Text>\n )}\n </FlexItem>\n <FlexItem flexGrow={isDesktop ? 0 : 0}>\n {isDesktop ? (\n <Button\n title={t('calculatePayrollTitle')}\n onClick={onCalculatePayroll}\n isDisabled={isCalculateDisabled || isPending || isCalculating}\n >\n {isCalculating ? t('calculatingPayroll') : t('calculatePayroll')}\n </Button>\n ) : (\n <Flex flexDirection=\"column\" justifyContent=\"normal\" alignItems=\"stretch\" gap={12}>\n <Button\n title={t('calculatePayrollTitle')}\n onClick={onCalculatePayroll}\n isDisabled={isCalculateDisabled || isPending || isCalculating}\n >\n {isCalculating ? t('calculatingPayroll') : t('calculatePayroll')}\n </Button>\n </Flex>\n )}\n </FlexItem>\n </Flex>\n\n {(alerts || payrollAlert) && (\n <Grid gap={16} gridTemplateColumns=\"1fr\">\n {payrollAlert && (\n <Alert label={payrollAlert.label} status={payrollAlert.variant}>\n {payrollAlert.content}\n </Alert>\n )}\n {alerts}\n </Grid>\n )}\n\n {isPending ? (\n <PayrollLoading\n title={isCalculating ? t('calculatingTitle') : t('loadingTitle')}\n description={isCalculating ? t('calculatingDescription') : t('loadingDescription')}\n />\n ) : (\n <>\n {payrollBlockers.length > 0 && (\n <PayrollBlockerAlerts\n blockers={payrollBlockers}\n onViewBlockersClick={onViewBlockers}\n />\n )}\n <Flex flexDirection=\"column\" gap={20}>\n <FlexItem>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('hoursAndEarningsTitle')}\n </Heading>\n <Text variant=\"supporting\">{t('hoursAndEarningsDescription')}</Text>\n </FlexItem>\n\n <DataView\n label={t('employeeCompensationsTitle')}\n columns={[\n {\n title: t('tableColumns.employees'),\n render: (item: PayrollEmployeeCompensationsType) => {\n const employee = employeeMap.get(item.employeeUuid || '')\n const payRateDisplay = formatEmployeePayRate(employee)\n return (\n <Flex flexDirection=\"column\" gap={0}>\n {getEmployeeName(item.employeeUuid || '')}\n {payRateDisplay && (\n <Text size=\"xs\" variant=\"supporting\">\n {payRateDisplay}\n </Text>\n )}\n {item.excluded && <Badge status=\"warning\">{t('skippedBadge')}</Badge>}\n </Flex>\n )\n },\n },\n {\n title: t('tableColumns.hours'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const hours = getRegularHours(item)\n const overtimeHours = getOvertimeHours(item)\n return formatHoursDisplay(hours + overtimeHours)\n },\n },\n {\n title: t('tableColumns.timeOff'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const ptoHours = getTotalPtoHours(item)\n return formatHoursDisplay(ptoHours)\n },\n },\n {\n title: t('tableColumns.additionalEarnings'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const earnings = getAdditionalEarnings(item)\n return formatNumberAsCurrency(earnings)\n },\n },\n ...(withReimbursements\n ? [\n {\n title: t('tableColumns.reimbursements'),\n justify: 'end' as const,\n render: (item: PayrollEmployeeCompensationsType) => {\n const reimbursements = getReimbursements(item)\n return formatNumberAsCurrency(reimbursements)\n },\n },\n ]\n : []),\n {\n title: t('tableColumns.totalPay'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n if (isRegularRateOfPayEnabled) {\n return formatNumberAsCurrency(Number(item.grossPay ?? 0))\n }\n const employee = employeeMap.get(item.employeeUuid || '')\n const calculatedGrossPay = employee\n ? calculateGrossPay(\n item,\n employee,\n payPeriod?.startDate ?? undefined,\n paySchedule,\n payrollCategory,\n )\n : 0\n return formatNumberAsCurrency(calculatedGrossPay)\n },\n },\n ]}\n data={employeeCompensations}\n itemMenu={(item: PayrollEmployeeCompensationsType) => (\n <HamburgerMenu\n items={[\n {\n label: t('editMenu.edit'),\n icon: <PencilSvg aria-hidden />,\n onClick: () => {\n const employee = employeeMap.get(item.employeeUuid || '')\n if (employee) {\n onEdit(employee)\n }\n },\n },\n {\n label: t(item.excluded ? 'editMenu.unskip' : 'editMenu.skip'),\n icon: item.excluded ? <PlusCircle aria-hidden /> : <XCircle aria-hidden />,\n onClick: () => {\n const employee = employeeMap.get(item.employeeUuid || '')\n if (employee) {\n onToggleExclude(item)\n }\n },\n },\n ...(grossUpEnabled\n ? [\n {\n label: t('editMenu.setNetEarnings'),\n icon: <CoinsHandSvg aria-hidden />,\n onClick: () => {\n if (item.employeeUuid) {\n onGrossUpSelect?.(item.employeeUuid)\n }\n },\n },\n ]\n : []),\n ]}\n triggerLabel={t('editMenu.edit')}\n />\n )}\n pagination={pagination}\n />\n </Flex>\n </>\n )}\n </Flex>\n </div>\n )\n}\n"],"names":["getPayrollConfigurationTitle","payPeriod","dateFormatter","PayrollConfigurationPresentation","className","employeeCompensations","employeeDetails","paySchedule","onEdit","onToggleExclude","onCalculatePayroll","onViewBlockers","payrollCategory","PayrollCategory","alerts","payrollAlert","isPending","isCalculating","payrollBlockers","pagination","withReimbursements","isCalculateDisabled","grossUpEnabled","onGrossUpSelect","Button","Heading","Text","Badge","Alert","useComponentContext","useI18n","useTranslation","useDateFormatter","formatEmployeePayRate","useFormatEmployeePayRate","isRegularRateOfPayEnabled","useUnstableFeature","containerRef","useRef","isDesktop","useContainerBreakpoints","employeeMap","employee","getEmployeeName","employeeUuid","firstLastName","jsx","classNames","styles","jsxs","Flex","FlexItem","Trans","Grid","PayrollLoading","Fragment","PayrollBlockerAlerts","DataView","item","payRateDisplay","hours","getRegularHours","overtimeHours","getOvertimeHours","formatHoursDisplay","ptoHours","getTotalPtoHours","earnings","getAdditionalEarnings","formatNumberAsCurrency","reimbursements","getReimbursements","calculatedGrossPay","calculateGrossPay","HamburgerMenu","PencilSvg","PlusCircle","XCircle","CoinsHandSvg"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgEA,MAAMA,KAA+B,CACnCC,GACAC,MAEID,GAAW,aAAaA,EAAU,UAC7BC,EAAc,gBAAgBD,EAAU,WAAWA,EAAU,OAAO,IAEtE,EAAE,WAAW,IAAI,SAAS,GAAA,GAItBE,KAAmC,CAAC;AAAA,EAC/C,WAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,WAAAL;AAAA,EACA,aAAAM;AAAA,EACA,QAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,iBAAAC,IAAkBC,EAAgB;AAAA,EAClC,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC,IAAkB,CAAA;AAAA,EAClB,YAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,qBAAAC,IAAsB;AAAA,EACtB,gBAAAC,IAAiB;AAAA,EACjB,iBAAAC;AACF,MAA6C;AAC3C,QAAM,EAAE,QAA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AAA,oBACxB,MAAM,gBAAA5B,EAAC6B,IAAA,EAAU,eAAW,GAAA,CAAC;AAAA,oBAC7B,SAAS,MAAM;AACb,4BAAMjC,IAAWD,EAAY,IAAIiB,EAAK,gBAAgB,EAAE;AACxD,sBAAIhB,KACFlC,EAAOkC,CAAQ;AAAA,oBAEnB;AAAA,kBAAA;AAAA,kBAEF;AAAA,oBACE,OAAO,EAAEgB,EAAK,WAAW,oBAAoB,eAAe;AAAA,oBAC5D,MAAMA,EAAK,WAAW,gBAAAZ,EAAC8B,IAAA,EAAW,eAAW,GAAA,CAAC,IAAK,gBAAA9B,EAAC+B,IAAA,EAAQ,eAAW,GAAA,CAAC;AAAA,oBACxE,SAAS,MAAM;AAEb,sBADiBpC,EAAY,IAAIiB,EAAK,gBAAgB,EAAE,KAEtDjD,EAAgBiD,CAAI;AAAA,oBAExB;AAAA,kBAAA;AAAA,kBAEF,GAAIpC,IACA;AAAA,oBACE;AAAA,sBACE,OAAO,EAAE,yBAAyB;AAAA,sBAClC,MAAM,gBAAAwB,EAACgC,IAAA,EAAa,eAAW,GAAA,CAAC;AAAA,sBAChC,SAAS,MAAM;AACb,wBAAIpB,EAAK,gBACPnC,IAAkBmC,EAAK,YAAY;AAAA,sBAEvC;AAAA,oBAAA;AAAA,kBACF,IAEF,CAAA;AAAA,gBAAC;AAAA,gBAEP,cAAc,EAAE,eAAe;AAAA,cAAA;AAAA,YAAA;AAAA,YAGnC,YAAAvC;AAAA,UAAA;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,EAAA,CAEJ,EAAA,CACF;AAEJ;"}
@@ -1,52 +1,53 @@
1
- import { useState as q, useRef as v, useMemo as y, useEffect as P, useCallback as L } from "react";
2
- import { useEmployeesList as ee } from "@gusto/embedded-api/react-query/employeesList";
3
- import { useQueryClient as te, keepPreviousData as F, useQuery as K } from "@tanstack/react-query";
4
- import { usePaySchedulesGet as se } from "@gusto/embedded-api/react-query/paySchedulesGet";
5
- import { useGustoEmbeddedContext as oe } from "@gusto/embedded-api/react-query/_context";
6
- import { payrollsPrepare as re } from "@gusto/embedded-api/funcs/payrollsPrepare";
7
- import { employeesGet as ae } from "@gusto/embedded-api/funcs/employeesGet";
8
- import { UnprocessableEntityError as ne } from "@gusto/embedded-api/models/errors/unprocessableentityerror";
9
- import { derivePayrollCategory as ie } from "../payrollTypes.js";
10
- import { usePagination as le } from "../../../hooks/usePagination/usePagination.js";
11
- const f = "payroll-prepare", _ = 300 * 1e3, ue = 3, A = (n) => n instanceof ne ? n.errors.some((s) => s.category === "invalid_operation") : !1;
12
- function De({
1
+ import { useState as R, useRef as q, useMemo as y, useEffect as P, useCallback as L } from "react";
2
+ import { useEmployeesList as te } from "@gusto/embedded-api/react-query/employeesList";
3
+ import { useQueryClient as se, keepPreviousData as F, useQuery as K } from "@tanstack/react-query";
4
+ import { usePaySchedulesGet as oe } from "@gusto/embedded-api/react-query/paySchedulesGet";
5
+ import { useGustoEmbeddedContext as re } from "@gusto/embedded-api/react-query/_context";
6
+ import { payrollsPrepare as ae } from "@gusto/embedded-api/funcs/payrollsPrepare";
7
+ import { employeesGet as ne } from "@gusto/embedded-api/funcs/employeesGet";
8
+ import { UnprocessableEntityError as ie } from "@gusto/embedded-api/models/errors/unprocessableentityerror";
9
+ import { derivePayrollCategory as le } from "../payrollTypes.js";
10
+ import { usePagination as ue } from "../../../hooks/usePagination/usePagination.js";
11
+ const f = "payroll-prepare", _ = 300 * 1e3, ce = 3, A = (n) => n instanceof ie ? n.errors.some((s) => s.category === "invalid_operation") : !1;
12
+ function we({
13
13
  companyId: n,
14
14
  payrollId: s,
15
- disablePrepare: m = !1,
16
- excludedEmployeeUuids: S = []
15
+ disablePrepare: d = !1,
16
+ excludedEmployeeUuids: S = [],
17
+ isTransitionPayroll: Q = !1
17
18
  }) {
18
- const D = oe(), i = te(), { currentPage: c, itemsPerPage: Q, getPaginationProps: T } = le({
19
+ const D = re(), i = se(), { currentPage: c, itemsPerPage: T, getPaginationProps: k } = ue({
19
20
  defaultItemsPerPage: 25
20
- }), [k, x] = q([]), [M, h] = q(!1), g = v(!1), { data: l, isFetching: w } = ee(
21
+ }), [x, M] = R([]), [b, h] = R(!1), g = q(!1), { data: l, isFetching: w } = te(
21
22
  {
22
23
  companyId: n,
23
24
  payrollUuid: s,
24
- per: Q,
25
+ per: T,
25
26
  page: c,
26
27
  sortBy: "name"
27
28
  },
28
29
  { placeholderData: F }
29
- ), C = v(l);
30
- C.current = l;
30
+ ), U = q(l);
31
+ U.current = l;
31
32
  const p = y(() => l?.showEmployees?.map((e) => e.uuid) || [], [l?.showEmployees]), u = y(() => {
32
33
  const e = new Set(p);
33
34
  return S.filter((t) => !e.has(t));
34
- }, [S, p]), d = y(() => c === 1 ? [...p, ...u] : p, [p, u, c]), b = y(() => d.join(","), [d]), {
35
+ }, [S, p]), m = y(() => c === 1 ? [...p, ...u] : p, [p, u, c]), B = y(() => m.join(","), [m]), {
35
36
  data: r,
36
- error: B,
37
- isLoading: G,
38
- isFetching: j
37
+ error: G,
38
+ isLoading: j,
39
+ isFetching: I
39
40
  } = K({
40
- queryKey: [f, s, b],
41
+ queryKey: [f, s, B],
41
42
  queryFn: async ({ signal: e }) => {
42
- const t = await re(
43
+ const t = await ae(
43
44
  D,
44
45
  {
45
46
  companyId: n,
46
47
  payrollId: s,
47
48
  sortBy: "last_name",
48
49
  requestBody: {
49
- employeeUuids: d
50
+ employeeUuids: Q ? void 0 : m
50
51
  }
51
52
  },
52
53
  { signal: e }
@@ -55,36 +56,36 @@ function De({
55
56
  throw t.error;
56
57
  return t.value.payrollPrepared;
57
58
  },
58
- enabled: d.length > 0 && !m,
59
+ enabled: m.length > 0 && !d,
59
60
  staleTime: _,
60
61
  placeholderData: F,
61
62
  // An "already processed" prepare failure is terminal — retrying it wastes time. Other
62
63
  // errors (network blips, etc.) still get the standard retry treatment.
63
- retry: (e, t) => !A(t) && e < ue
64
- }), I = A(B);
64
+ retry: (e, t) => !A(t) && e < ce
65
+ }), Y = A(G);
65
66
  P(() => () => {
66
67
  i.cancelQueries({
67
68
  queryKey: [f, s]
68
69
  });
69
70
  }, [i, s]), P(() => {
70
- m && i.cancelQueries({
71
+ d && i.cancelQueries({
71
72
  queryKey: [f, s]
72
73
  });
73
- }, [m, i, s]);
74
- const Y = y(() => u.join(","), [u]), { data: E } = K({
75
- queryKey: ["excluded-employee-details", Y],
74
+ }, [d, i, s]);
75
+ const H = y(() => u.join(","), [u]), { data: E } = K({
76
+ queryKey: ["excluded-employee-details", H],
76
77
  queryFn: async () => {
77
78
  const e = await Promise.all(
78
- u.map((o) => ae(D, { employeeId: o }))
79
+ u.map((o) => ne(D, { employeeId: o }))
79
80
  ), t = e.find((o) => !o.ok);
80
81
  if (t)
81
82
  throw t.error;
82
83
  return e.filter((o) => o.ok).map((o) => o.value.employee).filter((o) => o != null);
83
84
  },
84
- enabled: u.length > 0 && !m,
85
+ enabled: u.length > 0 && !d,
85
86
  staleTime: _
86
- }), U = L(() => {
87
- const e = C.current;
87
+ }), C = L(() => {
88
+ const e = U.current;
88
89
  if (!e?.showEmployees || !r?.employeeCompensations) {
89
90
  h(!1);
90
91
  return;
@@ -93,18 +94,18 @@ function De({
93
94
  if (t.length > 0 && t.every((a) => o.has(a))) {
94
95
  const a = [...e.showEmployees];
95
96
  if (c === 1 && E?.length) {
96
- const $ = new Set(t);
97
- for (const R of E)
98
- $.has(R.uuid) || a.push(R);
97
+ const ee = new Set(t);
98
+ for (const v of E)
99
+ ee.has(v.uuid) || a.push(v);
99
100
  }
100
- x(a), h(!0), g.current = !0;
101
+ M(a), h(!0), g.current = !0;
101
102
  } else
102
103
  h(!1);
103
104
  }, [r?.employeeCompensations, E, c]);
104
105
  P(() => {
105
- U();
106
- }, [U]);
107
- const { data: H, isLoading: N } = se(
106
+ C();
107
+ }, [C]);
108
+ const { data: N, isLoading: V } = oe(
108
109
  {
109
110
  companyId: n,
110
111
  payScheduleId: r?.payPeriod?.payScheduleUuid || ""
@@ -112,25 +113,25 @@ function De({
112
113
  {
113
114
  enabled: !!r?.payPeriod?.payScheduleUuid
114
115
  }
115
- ), V = L(async () => {
116
+ ), X = L(async () => {
116
117
  await i.invalidateQueries({
117
118
  queryKey: [f, s]
118
119
  });
119
- }, [i, s]), X = G && !g.current, z = j && g.current, J = w || z || !M, O = X || N || !l && w, W = l?.httpMeta.response.headers ?? new Headers(), Z = T(W, J);
120
+ }, [i, s]), z = j && !g.current, J = I && g.current, O = w || J || !b, W = z || V || !l && w, Z = l?.httpMeta.response.headers ?? new Headers(), $ = k(Z, O);
120
121
  return {
121
122
  employeeCompensations: r?.employeeCompensations ?? [],
122
- employeeDetails: k,
123
+ employeeDetails: x,
123
124
  payPeriod: r?.payPeriod,
124
- paySchedule: H?.payScheduleShow,
125
- payrollCategory: ie(r ?? {}),
126
- pagination: Z,
127
- isLoading: O,
128
- isAlreadyProcessed: I,
129
- refetch: V
125
+ paySchedule: N?.payScheduleShow,
126
+ payrollCategory: le(r ?? {}),
127
+ pagination: $,
128
+ isLoading: W,
129
+ isAlreadyProcessed: Y,
130
+ refetch: X
130
131
  };
131
132
  }
132
133
  export {
133
134
  f as PREPARE_QUERY_KEY,
134
- De as usePayrollConfigurationData
135
+ we as usePayrollConfigurationData
135
136
  };
136
137
  //# sourceMappingURL=usePayrollConfigurationData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePayrollConfigurationData.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useEmployeesList } from '@gusto/embedded-api/react-query/employeesList'\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport { payrollsPrepare } from '@gusto/embedded-api/funcs/payrollsPrepare'\nimport { employeesGet } from '@gusto/embedded-api/funcs/employeesGet'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { PayrollCategory } from '../payrollTypes'\nimport { derivePayrollCategory } from '../payrollTypes'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\ninterface UsePayrollConfigurationDataParams {\n companyId: string\n payrollId: string\n /** When true, don't call prepare and cancel any prepare already running. */\n disablePrepare?: boolean\n excludedEmployeeUuids?: string[]\n}\n\ninterface UsePayrollConfigurationDataReturn {\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod: PayrollPayPeriodType | undefined\n paySchedule: PayScheduleShow | undefined\n payrollCategory: PayrollCategory\n pagination: PaginationControlProps\n isLoading: boolean\n isAlreadyProcessed: boolean\n refetch: () => Promise<void>\n}\n\n/** @internal */\nexport const PREPARE_QUERY_KEY = 'payroll-prepare'\nconst FIVE_MINUTES = 5 * 60 * 1000\nconst PREPARE_MAX_ATTEMPTS = 3\n\nconst isAlreadyProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/** @internal */\nexport function usePayrollConfigurationData({\n companyId,\n payrollId,\n disablePrepare = false,\n excludedEmployeeUuids = [],\n}: UsePayrollConfigurationDataParams): UsePayrollConfigurationDataReturn {\n const gustoClient = useGustoEmbeddedContext()\n const queryClient = useQueryClient()\n\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination({\n defaultItemsPerPage: 25,\n })\n const [displayedEmployees, setDisplayedEmployees] = useState<Employee[]>([])\n const [isDataInSync, setIsDataInSync] = useState(false)\n const hasInitialDataRef = useRef(false)\n\n const { data: employeeData, isFetching: isFetchingEmployeeData } = useEmployeesList(\n {\n companyId,\n payrollUuid: payrollId,\n per: itemsPerPage,\n page: currentPage,\n sortBy: 'name',\n },\n { placeholderData: keepPreviousData },\n )\n\n const employeeDataRef = useRef(employeeData)\n employeeDataRef.current = employeeData\n\n const listedEmployeeUuids = useMemo(() => {\n return employeeData?.showEmployees?.map(e => e.uuid) || []\n }, [employeeData?.showEmployees])\n\n const missingExcludedUuids = useMemo(() => {\n const listedSet = new Set(listedEmployeeUuids)\n return excludedEmployeeUuids.filter(uuid => !listedSet.has(uuid))\n }, [excludedEmployeeUuids, listedEmployeeUuids])\n\n const employeeUuids = useMemo(() => {\n if (currentPage === 1) {\n return [...listedEmployeeUuids, ...missingExcludedUuids]\n }\n return listedEmployeeUuids\n }, [listedEmployeeUuids, missingExcludedUuids, currentPage])\n\n const employeeUuidsKey = useMemo(() => employeeUuids.join(','), [employeeUuids])\n\n const {\n data: prepareData,\n error: prepareError,\n isLoading: isPrepareLoading,\n isFetching: isPrepareFetching,\n } = useQuery({\n queryKey: [PREPARE_QUERY_KEY, payrollId, employeeUuidsKey],\n queryFn: async ({ signal }) => {\n const result = await payrollsPrepare(\n gustoClient,\n {\n companyId,\n payrollId,\n sortBy: 'last_name',\n requestBody: {\n employeeUuids,\n },\n },\n { signal },\n )\n\n if (!result.ok) {\n throw result.error\n }\n\n return result.value.payrollPrepared\n },\n enabled: employeeUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n placeholderData: keepPreviousData,\n // An \"already processed\" prepare failure is terminal — retrying it wastes time. Other\n // errors (network blips, etc.) still get the standard retry treatment.\n retry: (failureCount, error) =>\n !isAlreadyProcessedError(error) && failureCount < PREPARE_MAX_ATTEMPTS,\n })\n\n const isAlreadyProcessed = isAlreadyProcessedError(prepareError)\n\n useEffect(() => {\n return () => {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [queryClient, payrollId])\n\n useEffect(() => {\n if (disablePrepare) {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [disablePrepare, queryClient, payrollId])\n\n const excludedUuidsKey = useMemo(() => missingExcludedUuids.join(','), [missingExcludedUuids])\n\n const { data: excludedEmployeeDetails } = useQuery({\n queryKey: ['excluded-employee-details', excludedUuidsKey],\n queryFn: async () => {\n const results = await Promise.all(\n missingExcludedUuids.map(uuid => employeesGet(gustoClient, { employeeId: uuid })),\n )\n const failedResult = results.find(result => !result.ok)\n if (failedResult) {\n throw failedResult.error\n }\n\n return results\n .filter(result => result.ok)\n .map(result => result.value.employee)\n .filter((e): e is Employee => e != null)\n },\n enabled: missingExcludedUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n })\n\n const syncData = useCallback(() => {\n const currentEmployeeData = employeeDataRef.current\n if (!currentEmployeeData?.showEmployees || !prepareData?.employeeCompensations) {\n setIsDataInSync(false)\n return\n }\n\n const currentUuids = currentEmployeeData.showEmployees.map(e => e.uuid)\n const preparedUuids = new Set(prepareData.employeeCompensations.map(c => c.employeeUuid))\n const allListedInSync =\n currentUuids.length > 0 && currentUuids.every(uuid => preparedUuids.has(uuid))\n\n if (allListedInSync) {\n const mergedEmployees = [...currentEmployeeData.showEmployees]\n if (currentPage === 1 && excludedEmployeeDetails?.length) {\n const listedSet = new Set(currentUuids)\n for (const employee of excludedEmployeeDetails) {\n if (!listedSet.has(employee.uuid)) {\n mergedEmployees.push(employee)\n }\n }\n }\n setDisplayedEmployees(mergedEmployees)\n setIsDataInSync(true)\n hasInitialDataRef.current = true\n } else {\n setIsDataInSync(false)\n }\n }, [prepareData?.employeeCompensations, excludedEmployeeDetails, currentPage])\n\n useEffect(() => {\n syncData()\n }, [syncData])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: prepareData?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!prepareData?.payPeriod?.payScheduleUuid,\n },\n )\n\n const handleRefetch = useCallback(async () => {\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }, [queryClient, payrollId])\n\n const isInitialLoading = isPrepareLoading && !hasInitialDataRef.current\n const isPaginating = isPrepareFetching && hasInitialDataRef.current\n const isPaginationFetching = isFetchingEmployeeData || isPaginating || !isDataInSync\n const isLoading =\n isInitialLoading || isPayScheduleLoading || (!employeeData && isFetchingEmployeeData)\n\n const headers = employeeData?.httpMeta.response.headers ?? new Headers()\n const pagination: PaginationControlProps = getPaginationProps(headers, isPaginationFetching)\n\n return {\n employeeCompensations: prepareData?.employeeCompensations ?? [],\n employeeDetails: displayedEmployees,\n payPeriod: prepareData?.payPeriod,\n paySchedule: payScheduleData?.payScheduleShow,\n payrollCategory: derivePayrollCategory(prepareData ?? {}),\n pagination,\n isLoading,\n isAlreadyProcessed,\n refetch: handleRefetch,\n }\n}\n"],"names":["PREPARE_QUERY_KEY","FIVE_MINUTES","PREPARE_MAX_ATTEMPTS","isAlreadyProcessedError","error","UnprocessableEntityError","e","usePayrollConfigurationData","companyId","payrollId","disablePrepare","excludedEmployeeUuids","gustoClient","useGustoEmbeddedContext","queryClient","useQueryClient","currentPage","itemsPerPage","getPaginationProps","usePagination","displayedEmployees","setDisplayedEmployees","useState","isDataInSync","setIsDataInSync","hasInitialDataRef","useRef","employeeData","isFetchingEmployeeData","useEmployeesList","keepPreviousData","employeeDataRef","listedEmployeeUuids","useMemo","missingExcludedUuids","listedSet","uuid","employeeUuids","employeeUuidsKey","prepareData","prepareError","isPrepareLoading","isPrepareFetching","useQuery","signal","result","payrollsPrepare","failureCount","isAlreadyProcessed","useEffect","excludedUuidsKey","excludedEmployeeDetails","results","employeesGet","failedResult","syncData","useCallback","currentEmployeeData","currentUuids","preparedUuids","c","mergedEmployees","employee","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","handleRefetch","isInitialLoading","isPaginating","isPaginationFetching","isLoading","headers","pagination","derivePayrollCategory"],"mappings":";;;;;;;;;;AAsCO,MAAMA,IAAoB,mBAC3BC,IAAe,MAAS,KACxBC,KAAuB,GAEvBC,IAA0B,CAACC,MACzBA,aAAiBC,KAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP;AAKpD,SAASC,GAA4B;AAAA,EAC1C,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,uBAAAC,IAAwB,CAAA;AAC1B,GAAyE;AACvE,QAAMC,IAAcC,GAAA,GACdC,IAAcC,GAAA,GAEd,EAAE,aAAAC,GAAa,cAAAC,GAAc,oBAAAC,EAAA,IAAuBC,GAAc;AAAA,IACtE,qBAAqB;AAAA,EAAA,CACtB,GACK,CAACC,GAAoBC,CAAqB,IAAIC,EAAqB,CAAA,CAAE,GACrE,CAACC,GAAcC,CAAe,IAAIF,EAAS,EAAK,GAChDG,IAAoBC,EAAO,EAAK,GAEhC,EAAE,MAAMC,GAAc,YAAYC,MAA2BC;AAAA,IACjE;AAAA,MACE,WAAArB;AAAA,MACA,aAAaC;AAAA,MACb,KAAKQ;AAAA,MACL,MAAMD;AAAA,MACN,QAAQ;AAAA,IAAA;AAAA,IAEV,EAAE,iBAAiBc,EAAA;AAAA,EAAiB,GAGhCC,IAAkBL,EAAOC,CAAY;AAC3C,EAAAI,EAAgB,UAAUJ;AAE1B,QAAMK,IAAsBC,EAAQ,MAC3BN,GAAc,eAAe,IAAI,OAAK,EAAE,IAAI,KAAK,CAAA,GACvD,CAACA,GAAc,aAAa,CAAC,GAE1BO,IAAuBD,EAAQ,MAAM;AACzC,UAAME,IAAY,IAAI,IAAIH,CAAmB;AAC7C,WAAOrB,EAAsB,OAAO,CAAAyB,MAAQ,CAACD,EAAU,IAAIC,CAAI,CAAC;AAAA,EAClE,GAAG,CAACzB,GAAuBqB,CAAmB,CAAC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{"version":3,"file":"usePayrollConfigurationData.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useEmployeesList } from '@gusto/embedded-api/react-query/employeesList'\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport { payrollsPrepare } from '@gusto/embedded-api/funcs/payrollsPrepare'\nimport { employeesGet } from '@gusto/embedded-api/funcs/employeesGet'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { PayrollCategory } from '../payrollTypes'\nimport { derivePayrollCategory } from '../payrollTypes'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\ninterface UsePayrollConfigurationDataParams {\n companyId: string\n payrollId: string\n /** When true, don't call prepare and cancel any prepare already running. */\n disablePrepare?: boolean\n excludedEmployeeUuids?: string[]\n /**\n * When true, prepare is called without a roster. A transition payroll's roster is fixed by the\n * pay-schedule transition, so the API rejects any `employeeUuids` sent to prepare.\n */\n isTransitionPayroll?: boolean\n}\n\ninterface UsePayrollConfigurationDataReturn {\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod: PayrollPayPeriodType | undefined\n paySchedule: PayScheduleShow | undefined\n payrollCategory: PayrollCategory\n pagination: PaginationControlProps\n isLoading: boolean\n isAlreadyProcessed: boolean\n refetch: () => Promise<void>\n}\n\n/** @internal */\nexport const PREPARE_QUERY_KEY = 'payroll-prepare'\nconst FIVE_MINUTES = 5 * 60 * 1000\nconst PREPARE_MAX_ATTEMPTS = 3\n\nconst isAlreadyProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/** @internal */\nexport function usePayrollConfigurationData({\n companyId,\n payrollId,\n disablePrepare = false,\n excludedEmployeeUuids = [],\n isTransitionPayroll = false,\n}: UsePayrollConfigurationDataParams): UsePayrollConfigurationDataReturn {\n const gustoClient = useGustoEmbeddedContext()\n const queryClient = useQueryClient()\n\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination({\n defaultItemsPerPage: 25,\n })\n const [displayedEmployees, setDisplayedEmployees] = useState<Employee[]>([])\n const [isDataInSync, setIsDataInSync] = useState(false)\n const hasInitialDataRef = useRef(false)\n\n const { data: employeeData, isFetching: isFetchingEmployeeData } = useEmployeesList(\n {\n companyId,\n payrollUuid: payrollId,\n per: itemsPerPage,\n page: currentPage,\n sortBy: 'name',\n },\n { placeholderData: keepPreviousData },\n )\n\n const employeeDataRef = useRef(employeeData)\n employeeDataRef.current = employeeData\n\n const listedEmployeeUuids = useMemo(() => {\n return employeeData?.showEmployees?.map(e => e.uuid) || []\n }, [employeeData?.showEmployees])\n\n const missingExcludedUuids = useMemo(() => {\n const listedSet = new Set(listedEmployeeUuids)\n return excludedEmployeeUuids.filter(uuid => !listedSet.has(uuid))\n }, [excludedEmployeeUuids, listedEmployeeUuids])\n\n const employeeUuids = useMemo(() => {\n if (currentPage === 1) {\n return [...listedEmployeeUuids, ...missingExcludedUuids]\n }\n return listedEmployeeUuids\n }, [listedEmployeeUuids, missingExcludedUuids, currentPage])\n\n const employeeUuidsKey = useMemo(() => employeeUuids.join(','), [employeeUuids])\n\n const {\n data: prepareData,\n error: prepareError,\n isLoading: isPrepareLoading,\n isFetching: isPrepareFetching,\n } = useQuery({\n queryKey: [PREPARE_QUERY_KEY, payrollId, employeeUuidsKey],\n queryFn: async ({ signal }) => {\n const result = await payrollsPrepare(\n gustoClient,\n {\n companyId,\n payrollId,\n sortBy: 'last_name',\n requestBody: {\n employeeUuids: isTransitionPayroll ? undefined : employeeUuids,\n },\n },\n { signal },\n )\n\n if (!result.ok) {\n throw result.error\n }\n\n return result.value.payrollPrepared\n },\n enabled: employeeUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n placeholderData: keepPreviousData,\n // An \"already processed\" prepare failure is terminal — retrying it wastes time. Other\n // errors (network blips, etc.) still get the standard retry treatment.\n retry: (failureCount, error) =>\n !isAlreadyProcessedError(error) && failureCount < PREPARE_MAX_ATTEMPTS,\n })\n\n const isAlreadyProcessed = isAlreadyProcessedError(prepareError)\n\n useEffect(() => {\n return () => {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [queryClient, payrollId])\n\n useEffect(() => {\n if (disablePrepare) {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [disablePrepare, queryClient, payrollId])\n\n const excludedUuidsKey = useMemo(() => missingExcludedUuids.join(','), [missingExcludedUuids])\n\n const { data: excludedEmployeeDetails } = useQuery({\n queryKey: ['excluded-employee-details', excludedUuidsKey],\n queryFn: async () => {\n const results = await Promise.all(\n missingExcludedUuids.map(uuid => employeesGet(gustoClient, { employeeId: uuid })),\n )\n const failedResult = results.find(result => !result.ok)\n if (failedResult) {\n throw failedResult.error\n }\n\n return results\n .filter(result => result.ok)\n .map(result => result.value.employee)\n .filter((e): e is Employee => e != null)\n },\n enabled: missingExcludedUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n })\n\n const syncData = useCallback(() => {\n const currentEmployeeData = employeeDataRef.current\n if (!currentEmployeeData?.showEmployees || !prepareData?.employeeCompensations) {\n setIsDataInSync(false)\n return\n }\n\n const currentUuids = currentEmployeeData.showEmployees.map(e => e.uuid)\n const preparedUuids = new Set(prepareData.employeeCompensations.map(c => c.employeeUuid))\n const allListedInSync =\n currentUuids.length > 0 && currentUuids.every(uuid => preparedUuids.has(uuid))\n\n if (allListedInSync) {\n const mergedEmployees = [...currentEmployeeData.showEmployees]\n if (currentPage === 1 && excludedEmployeeDetails?.length) {\n const listedSet = new Set(currentUuids)\n for (const employee of excludedEmployeeDetails) {\n if (!listedSet.has(employee.uuid)) {\n mergedEmployees.push(employee)\n }\n }\n }\n setDisplayedEmployees(mergedEmployees)\n setIsDataInSync(true)\n hasInitialDataRef.current = true\n } else {\n setIsDataInSync(false)\n }\n }, [prepareData?.employeeCompensations, excludedEmployeeDetails, currentPage])\n\n useEffect(() => {\n syncData()\n }, [syncData])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: prepareData?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!prepareData?.payPeriod?.payScheduleUuid,\n },\n )\n\n const handleRefetch = useCallback(async () => {\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }, [queryClient, payrollId])\n\n const isInitialLoading = isPrepareLoading && !hasInitialDataRef.current\n const isPaginating = isPrepareFetching && hasInitialDataRef.current\n const isPaginationFetching = isFetchingEmployeeData || isPaginating || !isDataInSync\n const isLoading =\n isInitialLoading || isPayScheduleLoading || (!employeeData && isFetchingEmployeeData)\n\n const headers = employeeData?.httpMeta.response.headers ?? new Headers()\n const pagination: PaginationControlProps = getPaginationProps(headers, isPaginationFetching)\n\n return {\n employeeCompensations: prepareData?.employeeCompensations ?? [],\n employeeDetails: displayedEmployees,\n payPeriod: prepareData?.payPeriod,\n paySchedule: payScheduleData?.payScheduleShow,\n payrollCategory: derivePayrollCategory(prepareData ?? {}),\n pagination,\n isLoading,\n isAlreadyProcessed,\n refetch: handleRefetch,\n }\n}\n"],"names":["PREPARE_QUERY_KEY","FIVE_MINUTES","PREPARE_MAX_ATTEMPTS","isAlreadyProcessedError","error","UnprocessableEntityError","e","usePayrollConfigurationData","companyId","payrollId","disablePrepare","excludedEmployeeUuids","isTransitionPayroll","gustoClient","useGustoEmbeddedContext","queryClient","useQueryClient","currentPage","itemsPerPage","getPaginationProps","usePagination","displayedEmployees","setDisplayedEmployees","useState","isDataInSync","setIsDataInSync","hasInitialDataRef","useRef","employeeData","isFetchingEmployeeData","useEmployeesList","keepPreviousData","employeeDataRef","listedEmployeeUuids","useMemo","missingExcludedUuids","listedSet","uuid","employeeUuids","employeeUuidsKey","prepareData","prepareError","isPrepareLoading","isPrepareFetching","useQuery","signal","result","payrollsPrepare","failureCount","isAlreadyProcessed","useEffect","excludedUuidsKey","excludedEmployeeDetails","results","employeesGet","failedResult","syncData","useCallback","currentEmployeeData","currentUuids","preparedUuids","c","mergedEmployees","employee","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","handleRefetch","isInitialLoading","isPaginating","isPaginationFetching","isLoading","headers","pagination","derivePayrollCategory"],"mappings":";;;;;;;;;;AA2CO,MAAMA,IAAoB,mBAC3BC,IAAe,MAAS,KACxBC,KAAuB,GAEvBC,IAA0B,CAACC,MACzBA,aAAiBC,KAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP;AAKpD,SAASC,GAA4B;AAAA,EAC1C,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,uBAAAC,IAAwB,CAAA;AAAA,EACxB,qBAAAC,IAAsB;AACxB,GAAyE;AACvE,QAAMC,IAAcC,GAAA,GACdC,IAAcC,GAAA,GAEd,EAAE,aAAAC,GAAa,cAAAC,GAAc,oBAAAC,EAAA,IAAuBC,GAAc;AAAA,IACtE,qBAAqB;AAAA,EAAA,CACtB,GACK,CAACC,GAAoBC,CAAqB,IAAIC,EAAqB,CAAA,CAAE,GACrE,CAACC,GAAcC,CAAe,IAAIF,EAAS,EAAK,GAChDG,IAAoBC,EAAO,EAAK,GAEhC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AAA,EACH,GAAG,CAACM,GAAaN,CAAS,CAAC,GAErB2D,IAAmB1B,KAAoB,CAAChB,EAAkB,SAC1D2C,IAAe1B,KAAqBjB,EAAkB,SACtD4C,IAAuBzC,KAA0BwC,KAAgB,CAAC7C,GAClE+C,IACJH,KAAoBH,KAAyB,CAACrC,KAAgBC,GAE1D2C,IAAU5C,GAAc,SAAS,SAAS,WAAW,IAAI,QAAA,GACzD6C,IAAqCtD,EAAmBqD,GAASF,CAAoB;AAE3F,SAAO;AAAA,IACL,uBAAuB9B,GAAa,yBAAyB,CAAA;AAAA,IAC7D,iBAAiBnB;AAAA,IACjB,WAAWmB,GAAa;AAAA,IACxB,aAAawB,GAAiB;AAAA,IAC9B,iBAAiBU,GAAsBlC,KAAe,EAAE;AAAA,IACxD,YAAAiC;AAAA,IACA,WAAAF;AAAA,IACA,oBAAAtB;AAAA,IACA,SAASkB;AAAA,EAAA;AAEb;"}
@@ -1,104 +1,108 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { useEmployeesGetSuspense as v } from "@gusto/embedded-api/react-query/employeesGet";
3
- import { useEmployeePaymentMethodsGetBankAccountsSuspense as N } from "@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts";
4
- import { usePayrollsUpdateMutation as q } from "@gusto/embedded-api/react-query/payrollsUpdate";
5
- import { useMemo as M } from "react";
6
- import { useQueryClient as Q } from "@tanstack/react-query";
7
- import { usePreparedPayrollData as T } from "../usePreparedPayrollData.js";
8
- import { PREPARE_QUERY_KEY as W } from "../PayrollConfiguration/usePayrollConfigurationData.js";
9
- import { derivePayrollCategory as z, isOffCyclePayroll as G } from "../payrollTypes.js";
10
- import { cleanupReimbursements as H } from "../helpers.js";
11
- import { UNSTABLE_PayrollEditEmployee as K } from "../UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.js";
12
- import { PayrollEditEmployeePresentation as j } from "./PayrollEditEmployeePresentation.js";
13
- import { useUnstableFeature as F } from "../../../contexts/UnstableFeaturesProvider/useUnstableFeature.js";
14
- import { componentEvents as d } from "../../../shared/constants.js";
15
- import { BaseComponent as V } from "../../Base/Base.js";
16
- import { useComponentDictionary as J } from "../../../i18n/I18n.js";
17
- import { useBase as X } from "../../Base/useBase.js";
18
- function Ee(e) {
19
- return F("payrollRegularRateOfPay") ? /* @__PURE__ */ t(K, { ...e }) : /* @__PURE__ */ t(V, { ...e, children: /* @__PURE__ */ t(Z, { ...e, children: e.children }) });
2
+ import { useEmployeesGetSuspense as q } from "@gusto/embedded-api/react-query/employeesGet";
3
+ import { useEmployeePaymentMethodsGetBankAccountsSuspense as G } from "@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts";
4
+ import { usePayrollsUpdateMutation as M } from "@gusto/embedded-api/react-query/payrollsUpdate";
5
+ import { useMemo as Q } from "react";
6
+ import { useQueryClient as W } from "@tanstack/react-query";
7
+ import { usePayrollsGetSuspense as z } from "@gusto/embedded-api/react-query/payrollsGet";
8
+ import { usePreparedPayrollData as H } from "../usePreparedPayrollData.js";
9
+ import { PREPARE_QUERY_KEY as K } from "../PayrollConfiguration/usePayrollConfigurationData.js";
10
+ import { derivePayrollCategory as d, PayrollCategory as j, isOffCyclePayroll as F } from "../payrollTypes.js";
11
+ import { cleanupReimbursements as V } from "../helpers.js";
12
+ import { UNSTABLE_PayrollEditEmployee as J } from "../UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.js";
13
+ import { PayrollEditEmployeePresentation as X } from "./PayrollEditEmployeePresentation.js";
14
+ import { useUnstableFeature as Z } from "../../../contexts/UnstableFeaturesProvider/useUnstableFeature.js";
15
+ import { componentEvents as f } from "../../../shared/constants.js";
16
+ import { BaseComponent as $ } from "../../Base/Base.js";
17
+ import { useComponentDictionary as I } from "../../../i18n/I18n.js";
18
+ import { useBase as ee } from "../../Base/useBase.js";
19
+ function be(e) {
20
+ return Z("payrollRegularRateOfPay") ? /* @__PURE__ */ t(J, { ...e }) : /* @__PURE__ */ t($, { ...e, children: /* @__PURE__ */ t(oe, { ...e, children: e.children }) });
20
21
  }
21
- const Z = ({
22
+ const oe = ({
22
23
  employeeId: e,
23
- companyId: s,
24
- payrollId: i,
24
+ companyId: r,
25
+ payrollId: n,
25
26
  onEvent: p,
26
- dictionary: f,
27
+ dictionary: P,
27
28
  withReimbursements: E = !0,
28
- className: P
29
+ className: C
29
30
  }) => {
30
- J("Payroll.PayrollEditEmployee", f);
31
- const C = Q(), { LoadingIndicator: R, baseSubmitHandler: b } = X(), { data: h } = v({ employeeId: e }), { data: A } = N({
31
+ I("Payroll.PayrollEditEmployee", P);
32
+ const R = W(), { LoadingIndicator: h, baseSubmitHandler: b } = ee(), { data: A } = q({ employeeId: e }), { data: L } = G({
32
33
  employeeId: e
33
- }), L = M(() => [e], [e]), { preparedPayroll: r, paySchedule: g, isLoading: k } = T({
34
- companyId: s,
35
- payrollId: i,
36
- employeeUuids: L
37
- }), { mutateAsync: D, isPending: S } = q(), u = h.employee, _ = r?.employeeCompensations?.at(0), O = (A.employeeBankAccounts || []).length > 0, y = z(r ?? {}), U = !G(y), w = ({
34
+ }), g = Q(() => [e], [e]), { data: S } = z({ companyId: r, payrollId: n }), D = d(S.payrollShow ?? {}) === j.Transition, { preparedPayroll: a, paySchedule: k, isLoading: U } = H({
35
+ companyId: r,
36
+ payrollId: n,
37
+ employeeUuids: g,
38
+ isTransitionPayroll: D
39
+ }), { mutateAsync: _, isPending: w } = M(), u = A.employee, O = a?.employeeCompensations?.find(
40
+ (o) => o.employeeUuid === e
41
+ ), x = (L.employeeBankAccounts || []).length > 0, y = d(a ?? {}), B = !F(y), Y = ({
38
42
  paymentMethod: o,
39
- reimbursements: n,
43
+ reimbursements: s,
40
44
  customWithholdings: c,
41
- ...a
45
+ ...i
42
46
  }) => ({
43
- ...a,
47
+ ...i,
44
48
  // The legacy editor edits hours, not per-workweek breakdowns, so omit
45
49
  // breakdowns and let the API use the hours we send.
46
- hourlyCompensations: a.hourlyCompensations?.map((m) => {
47
- const { breakdowns: Y, ...l } = m;
50
+ hourlyCompensations: i.hourlyCompensations?.map((m) => {
51
+ const { breakdowns: N, ...l } = m;
48
52
  return l;
49
53
  }),
50
- fixedCompensations: a.fixedCompensations?.map((m) => {
51
- const { breakdowns: Y, ...l } = m;
54
+ fixedCompensations: i.fixedCompensations?.map((m) => {
55
+ const { breakdowns: N, ...l } = m;
52
56
  return l;
53
57
  }),
54
58
  ...o && o !== "Historical" ? { paymentMethod: o } : {},
55
- memo: a.memo || void 0,
59
+ memo: i.memo || void 0,
56
60
  // Off-cycle payrolls write reimbursements via the legacy fixed_compensations field; the
57
61
  // itemized array gets rejected by the `emb_off_cycle_disable_named_reimbursements` backend
58
62
  // flag (default-on globally, expected removal 2026-09-01).
59
63
  // TODO(post-2026-09-01): drop the branch once the flag is gone.
60
- ...U && n ? { reimbursements: H(n) } : {}
61
- }), x = async (o) => {
62
- const n = w(o);
64
+ ...B && s ? { reimbursements: V(s) } : {}
65
+ }), v = async (o) => {
66
+ const s = Y(o);
63
67
  await b(null, async () => {
64
- const c = await D({
68
+ const c = await _({
65
69
  request: {
66
- companyId: s,
67
- payrollId: i,
70
+ companyId: r,
71
+ payrollId: n,
68
72
  payrollUpdate: {
69
- employeeCompensations: [n]
73
+ employeeCompensations: [s]
70
74
  }
71
75
  }
72
76
  });
73
- await C.invalidateQueries({
74
- queryKey: [W, i]
75
- }), p(d.RUN_PAYROLL_EMPLOYEE_SAVED, {
77
+ await R.invalidateQueries({
78
+ queryKey: [K, n]
79
+ }), p(f.RUN_PAYROLL_EMPLOYEE_SAVED, {
76
80
  payrollPrepared: c.payrollPrepared,
77
81
  employee: u
78
82
  });
79
83
  });
80
- }, B = () => {
81
- p(d.RUN_PAYROLL_EMPLOYEE_CANCELLED);
84
+ }, T = () => {
85
+ p(f.RUN_PAYROLL_EMPLOYEE_CANCELLED);
82
86
  };
83
- return k ? /* @__PURE__ */ t(R, {}) : /* @__PURE__ */ t(
84
- j,
87
+ return U ? /* @__PURE__ */ t(h, {}) : /* @__PURE__ */ t(
88
+ X,
85
89
  {
86
- className: P,
87
- onSave: x,
88
- onCancel: B,
90
+ className: C,
91
+ onSave: v,
92
+ onCancel: T,
89
93
  employee: u,
90
- isPending: S,
91
- employeeCompensation: _,
92
- fixedCompensationTypes: r?.fixedCompensationTypes || [],
93
- payPeriodStartDate: r?.payPeriod?.startDate,
94
- paySchedule: g,
94
+ isPending: w,
95
+ employeeCompensation: O,
96
+ fixedCompensationTypes: a?.fixedCompensationTypes || [],
97
+ payPeriodStartDate: a?.payPeriod?.startDate ?? void 0,
98
+ paySchedule: k,
95
99
  payrollCategory: y,
96
100
  withReimbursements: E,
97
- hasDirectDepositSetup: O
101
+ hasDirectDepositSetup: x
98
102
  }
99
103
  );
100
104
  };
101
105
  export {
102
- Ee as PayrollEditEmployee
106
+ be as PayrollEditEmployee
103
107
  };
104
108
  //# sourceMappingURL=PayrollEditEmployee.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PayrollEditEmployee.js","sources":["../../../../src/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx"],"sourcesContent":["import { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdateEmployeeCompensations } from '@gusto/embedded-api/models/components/payrollupdate'\nimport { useMemo } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { usePreparedPayrollData } from '../usePreparedPayrollData'\nimport { PREPARE_QUERY_KEY } from '../PayrollConfiguration/usePayrollConfigurationData'\nimport { derivePayrollCategory, isOffCyclePayroll } from '../payrollTypes'\nimport { cleanupReimbursements } from '../helpers'\nimport { UNSTABLE_PayrollEditEmployee } from '../UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee'\nimport { PayrollEditEmployeePresentation } from './PayrollEditEmployeePresentation'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\nimport { componentEvents } from '@/shared/constants'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useComponentDictionary } from '@/i18n'\nimport { useBase } from '@/components/Base/useBase'\n\n/**\n * Props for {@link PayrollEditEmployee}.\n *\n * @public\n */\nexport interface PayrollEditEmployeeProps extends BaseComponentInterface<'Payroll.PayrollEditEmployee'> {\n /** The associated employee identifier. */\n employeeId: string\n /** The associated company identifier. */\n companyId: string\n /** The associated payroll identifier. */\n payrollId: string\n /** Whether to show reimbursement fields. Defaults to `true`. */\n withReimbursements?: boolean\n}\n\n/**\n * Editor for an individual employee's compensation within a payroll run.\n *\n * Allows modification of pay rates, hours, time off, additional earnings,\n * reimbursements, and payment method for a single employee on the specified payroll.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/employee/saved` | Fired when employee payroll compensation changes are saved | `{ payrollPrepared, employee }` |\n * | `runPayroll/employee/cancelled` | Fired when the user cancels editing employee payroll compensation | — |\n *\n * @param props - {@link PayrollEditEmployeeProps} plus base component props.\n * @returns The employee compensation editor.\n * @public\n *\n * @example\n * ```tsx\n * import { Payroll } from '@gusto/embedded-react-sdk'\n *\n * function MyComponent() {\n * return (\n * <Payroll.PayrollEditEmployee\n * employeeId=\"your-employee-id\"\n * companyId=\"your-company-id\"\n * payrollId=\"your-payroll-id\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport function PayrollEditEmployee(props: PayrollEditEmployeeProps) {\n const isRegularRateOfPayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n\n if (isRegularRateOfPayEnabled) {\n return <UNSTABLE_PayrollEditEmployee {...props} />\n }\n\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({\n employeeId,\n companyId,\n payrollId,\n onEvent,\n dictionary,\n withReimbursements = true,\n className,\n}: PayrollEditEmployeeProps) => {\n useComponentDictionary('Payroll.PayrollEditEmployee', dictionary)\n\n const queryClient = useQueryClient()\n const { LoadingIndicator, baseSubmitHandler } = useBase()\n\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const memoizedEmployeeId = useMemo(() => [employeeId], [employeeId])\n const { preparedPayroll, paySchedule, isLoading } = usePreparedPayrollData({\n companyId,\n payrollId,\n employeeUuids: memoizedEmployeeId,\n })\n\n const { mutateAsync: updatePayroll, isPending } = usePayrollsUpdateMutation()\n\n const employee = employeeData.employee!\n const employeeCompensation = preparedPayroll?.employeeCompensations?.at(0)\n const bankAccounts = bankAccountsList.employeeBankAccounts || []\n const hasDirectDepositSetup = bankAccounts.length > 0\n const payrollCategory = derivePayrollCategory(preparedPayroll ?? {})\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n\n const transformEmployeeCompensation = ({\n paymentMethod,\n reimbursements,\n customWithholdings,\n ...compensation\n }: PayrollEmployeeCompensationsType): PayrollUpdateEmployeeCompensations => {\n return {\n ...compensation,\n // The legacy editor edits hours, not per-workweek breakdowns, so omit\n // breakdowns and let the API use the hours we send.\n hourlyCompensations: compensation.hourlyCompensations?.map(hourlyCompensation => {\n const { breakdowns, ...hourlyCompensationWithoutBreakdowns } = hourlyCompensation\n return hourlyCompensationWithoutBreakdowns\n }),\n fixedCompensations: compensation.fixedCompensations?.map(fixedCompensation => {\n const { breakdowns, ...fixedCompensationWithoutBreakdowns } = fixedCompensation\n return fixedCompensationWithoutBreakdowns\n }),\n ...(paymentMethod && paymentMethod !== 'Historical' ? { paymentMethod } : {}),\n memo: compensation.memo || undefined,\n // Off-cycle payrolls write reimbursements via the legacy fixed_compensations field; the\n // itemized array gets rejected by the `emb_off_cycle_disable_named_reimbursements` backend\n // flag (default-on globally, expected removal 2026-09-01).\n // TODO(post-2026-09-01): drop the branch once the flag is gone.\n ...(usesItemizedReimbursements && reimbursements\n ? { reimbursements: cleanupReimbursements(reimbursements) }\n : {}),\n }\n }\n\n const onSave = async (updatedCompensation: PayrollEmployeeCompensationsType) => {\n const transformedCompensation = transformEmployeeCompensation(updatedCompensation)\n await baseSubmitHandler(null, async () => {\n const result = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: {\n employeeCompensations: [transformedCompensation],\n },\n },\n })\n\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED, {\n payrollPrepared: result.payrollPrepared,\n employee,\n })\n })\n }\n\n const onCancel = () => {\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_CANCELLED)\n }\n\n if (isLoading) {\n return <LoadingIndicator />\n }\n\n return (\n <PayrollEditEmployeePresentation\n className={className}\n onSave={onSave}\n onCancel={onCancel}\n employee={employee}\n isPending={isPending}\n employeeCompensation={employeeCompensation}\n fixedCompensationTypes={preparedPayroll?.fixedCompensationTypes || []}\n payPeriodStartDate={preparedPayroll?.payPeriod?.startDate}\n paySchedule={paySchedule}\n payrollCategory={payrollCategory}\n withReimbursements={withReimbursements}\n hasDirectDepositSetup={hasDirectDepositSetup}\n />\n )\n}\n"],"names":["PayrollEditEmployee","props","useUnstableFeature","jsx","UNSTABLE_PayrollEditEmployee","BaseComponent","Root","employeeId","companyId","payrollId","onEvent","dictionary","withReimbursements","className","useComponentDictionary","queryClient","useQueryClient","LoadingIndicator","baseSubmitHandler","useBase","employeeData","useEmployeesGetSuspense","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","memoizedEmployeeId","useMemo","preparedPayroll","paySchedule","isLoading","usePreparedPayrollData","updatePayroll","isPending","usePayrollsUpdateMutation","employee","employeeCompensation","hasDirectDepositSetup","payrollCategory","derivePayrollCategory","usesItemizedReimbursements","isOffCyclePayroll","transformEmployeeCompensation","paymentMethod","reimbursements","customWithholdings","compensation","hourlyCompensation","breakdowns","hourlyCompensationWithoutBreakdowns","fixedCompensation","fixedCompensationWithoutBreakdowns","cleanupReimbursements","onSave","updatedCompensation","transformedCompensation","result","PREPARE_QUERY_KEY","componentEvents","onCancel","PayrollEditEmployeePresentation"],"mappings":";;;;;;;;;;;;;;;;;AAoEO,SAASA,GAAoBC,GAAiC;AAGnE,SAFkCC,EAAmB,yBAAyB,IAGrE,gBAAAC,EAACC,GAAA,EAA8B,GAAGH,EAAA,CAAO,IAIhD,gBAAAE,EAACE,GAAA,EAAe,GAAGJ,GACjB,UAAA,gBAAAE,EAACG,KAAM,GAAGL,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMK,IAAO,CAAC;AAAA,EACZ,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,WAAAC;AACF,MAAgC;AAC9B,EAAAC,EAAuB,+BAA+BH,CAAU;AAEhE,QAAMI,IAAcC,EAAA,GACd,EAAE,kBAAAC,GAAkB,mBAAAC,EAAA,IAAsBC,EAAA,GAE1C,EAAE,MAAMC,EAAA,IAAiBC,EAAwB,EAAE,YAAAd,GAAY,GAC/D,EAAE,MAAMe,EAAA,IAAqBC,EAAiD;AAAA,IAClF,YAAAhB;AAAA,EAAA,CACD,GACKiB,IAAqBC,EAAQ,MAAM,CAAClB,CAAU,GAAG,CAACA,CAAU,CAAC,GAC7D,EAAE,iBAAAmB,GAAiB,aAAAC,GAAa,WAAAC,EAAA,IAAcC,EAAuB;AAAA,IACzE,WAAArB;AAAA,IACA,WAAAC;AAAA,IACA,eAAee;AAAA,EAAA,CAChB,GAEK,EAAE,aAAaM,GAAe,WAAAC,EAAA,IAAcC,EAAA,GAE5CC,I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AA,QAClD,iBAAiBF,EAAO;AAAA,QACxB,UAAArB;AAAA,MAAA,CACD;AAAA,IACH,CAAC;AAAA,EACH,GAEMwB,IAAW,MAAM;AACrB,IAAA/C,EAAQ8C,EAAgB,8BAA8B;AAAA,EACxD;AAEA,SAAI5B,sBACMX,GAAA,EAAiB,IAIzB,gBAAAd;AAAA,IAACuD;AAAA,IAAA;AAAA,MACC,WAAA7C;AAAA,MACA,QAAAsC;AAAA,MACA,UAAAM;AAAA,MACA,UAAAxB;AAAA,MACA,WAAAF;AAAA,MACA,sBAAAG;AAAA,MACA,wBAAwBR,GAAiB,0BAA0B,CAAA;AAAA,MACnE,oBAAoBA,GAAiB,WAAW;AAAA,MAChD,aAAAC;AAAA,MACA,iBAAAS;AAAA,MACA,oBAAAxB;AAAA,MACA,uBAAAuB;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"PayrollEditEmployee.js","sources":["../../../../src/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx"],"sourcesContent":["import { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdateEmployeeCompensations } from '@gusto/embedded-api/models/components/payrollupdate'\nimport { useMemo } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport { usePreparedPayrollData } from '../usePreparedPayrollData'\nimport { PREPARE_QUERY_KEY } from '../PayrollConfiguration/usePayrollConfigurationData'\nimport { derivePayrollCategory, isOffCyclePayroll, PayrollCategory } from '../payrollTypes'\nimport { cleanupReimbursements } from '../helpers'\nimport { UNSTABLE_PayrollEditEmployee } from '../UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee'\nimport { PayrollEditEmployeePresentation } from './PayrollEditEmployeePresentation'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\nimport { componentEvents } from '@/shared/constants'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useComponentDictionary } from '@/i18n'\nimport { useBase } from '@/components/Base/useBase'\n\n/**\n * Props for {@link PayrollEditEmployee}.\n *\n * @public\n */\nexport interface PayrollEditEmployeeProps extends BaseComponentInterface<'Payroll.PayrollEditEmployee'> {\n /** The associated employee identifier. */\n employeeId: string\n /** The associated company identifier. */\n companyId: string\n /** The associated payroll identifier. */\n payrollId: string\n /** Whether to show reimbursement fields. Defaults to `true`. */\n withReimbursements?: boolean\n}\n\n/**\n * Editor for an individual employee's compensation within a payroll run.\n *\n * Allows modification of pay rates, hours, time off, additional earnings,\n * reimbursements, and payment method for a single employee on the specified payroll.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/employee/saved` | Fired when employee payroll compensation changes are saved | `{ payrollPrepared, employee }` |\n * | `runPayroll/employee/cancelled` | Fired when the user cancels editing employee payroll compensation | — |\n *\n * @param props - {@link PayrollEditEmployeeProps} plus base component props.\n * @returns The employee compensation editor.\n * @public\n *\n * @example\n * ```tsx\n * import { Payroll } from '@gusto/embedded-react-sdk'\n *\n * function MyComponent() {\n * return (\n * <Payroll.PayrollEditEmployee\n * employeeId=\"your-employee-id\"\n * companyId=\"your-company-id\"\n * payrollId=\"your-payroll-id\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport function PayrollEditEmployee(props: PayrollEditEmployeeProps) {\n const isRegularRateOfPayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n\n if (isRegularRateOfPayEnabled) {\n return <UNSTABLE_PayrollEditEmployee {...props} />\n }\n\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({\n employeeId,\n companyId,\n payrollId,\n onEvent,\n dictionary,\n withReimbursements = true,\n className,\n}: PayrollEditEmployeeProps) => {\n useComponentDictionary('Payroll.PayrollEditEmployee', dictionary)\n\n const queryClient = useQueryClient()\n const { LoadingIndicator, baseSubmitHandler } = useBase()\n\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const memoizedEmployeeId = useMemo(() => [employeeId], [employeeId])\n const { data: payrollData } = usePayrollsGetSuspense({ companyId, payrollId })\n const isTransitionPayroll =\n derivePayrollCategory(payrollData.payrollShow ?? {}) === PayrollCategory.Transition\n const { preparedPayroll, paySchedule, isLoading } = usePreparedPayrollData({\n companyId,\n payrollId,\n employeeUuids: memoizedEmployeeId,\n isTransitionPayroll,\n })\n\n const { mutateAsync: updatePayroll, isPending } = usePayrollsUpdateMutation()\n\n const employee = employeeData.employee!\n const employeeCompensation = preparedPayroll?.employeeCompensations?.find(\n comp => comp.employeeUuid === employeeId,\n )\n const bankAccounts = bankAccountsList.employeeBankAccounts || []\n const hasDirectDepositSetup = bankAccounts.length > 0\n const payrollCategory = derivePayrollCategory(preparedPayroll ?? {})\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n\n const transformEmployeeCompensation = ({\n paymentMethod,\n reimbursements,\n customWithholdings,\n ...compensation\n }: PayrollEmployeeCompensationsType): PayrollUpdateEmployeeCompensations => {\n return {\n ...compensation,\n // The legacy editor edits hours, not per-workweek breakdowns, so omit\n // breakdowns and let the API use the hours we send.\n hourlyCompensations: compensation.hourlyCompensations?.map(hourlyCompensation => {\n const { breakdowns, ...hourlyCompensationWithoutBreakdowns } = hourlyCompensation\n return hourlyCompensationWithoutBreakdowns\n }),\n fixedCompensations: compensation.fixedCompensations?.map(fixedCompensation => {\n const { breakdowns, ...fixedCompensationWithoutBreakdowns } = fixedCompensation\n return fixedCompensationWithoutBreakdowns\n }),\n ...(paymentMethod && paymentMethod !== 'Historical' ? { paymentMethod } : {}),\n memo: compensation.memo || undefined,\n // Off-cycle payrolls write reimbursements via the legacy fixed_compensations field; the\n // itemized array gets rejected by the `emb_off_cycle_disable_named_reimbursements` backend\n // flag (default-on globally, expected removal 2026-09-01).\n // TODO(post-2026-09-01): drop the branch once the flag is gone.\n ...(usesItemizedReimbursements && reimbursements\n ? { reimbursements: cleanupReimbursements(reimbursements) }\n : {}),\n }\n }\n\n const onSave = async (updatedCompensation: PayrollEmployeeCompensationsType) => {\n const transformedCompensation = transformEmployeeCompensation(updatedCompensation)\n await baseSubmitHandler(null, async () => {\n const result = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: {\n employeeCompensations: [transformedCompensation],\n },\n },\n })\n\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED, {\n payrollPrepared: result.payrollPrepared,\n employee,\n })\n })\n }\n\n const onCancel = () => {\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_CANCELLED)\n }\n\n if (isLoading) {\n return <LoadingIndicator />\n }\n\n return (\n <PayrollEditEmployeePresentation\n className={className}\n onSave={onSave}\n onCancel={onCancel}\n employee={employee}\n isPending={isPending}\n employeeCompensation={employeeCompensation}\n fixedCompensationTypes={preparedPayroll?.fixedCompensationTypes || []}\n payPeriodStartDate={preparedPayroll?.payPeriod?.startDate ?? undefined}\n paySchedule={paySchedule}\n payrollCategory={payrollCategory}\n withReimbursements={withReimbursements}\n hasDirectDepositSetup={hasDirectDepositSetup}\n />\n )\n}\n"],"names":["PayrollEditEmployee","props","useUnstableFeature","jsx","UNSTABLE_PayrollEditEmployee","BaseComponent","Root","employeeId","companyId","payrollId","onEvent","dictionary","withReimbursements","className","useComponentDictionary","queryClient","useQueryClient","LoadingIndicator","baseSubmitHandler","useBase","employeeData","useEmployeesGetSuspense","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","memoizedEmployeeId","useMemo","payrollData","usePayrollsGetSuspense","isTransitionPayroll","derivePayrollCategory","PayrollCategory","preparedPayroll","paySchedule","isLoading","usePreparedPayrollData","updatePayroll","isPending","usePayrollsUpdateMutation","employee","employeeCompensation","comp","hasDirectDepositSetup","payrollCategory","usesItemizedReimbursements","isOffCyclePayroll","transformEmployeeCompensation","paymentMethod","reimbursements","customWithholdings","compensation","hourlyCompensation","breakdowns","hourlyCompensationWithoutBreakdowns","fixedCompensation","fixedCompensationWithoutBreakdowns","cleanupReimbursements","onSave","updatedCompensation","transformedCompensation","result","PREPARE_QUERY_KEY","componentEvents","onCancel","PayrollEditEmployeePresentation"],"mappings":";;;;;;;;;;;;;;;;;;AAqEO,SAASA,GAAoBC,GAAiC;AAGnE,SAFkCC,EAAmB,yBAAyB,IAGrE,gBAAAC,EAACC,GAAA,EAA8B,GAAGH,EAAA,CAAO,IAIhD,gBAAAE,EAACE,GAAA,EAAe,GAAGJ,GACjB,UAAA,gBAAAE,EAACG,MAAM,GAAGL,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMK,KAAO,CAAC;AAAA,EACZ,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,WAAAC;AACF,MAAgC;AAC9B,EAAAC,EAAuB,+BAA+BH,CAAU;AAEhE,QAAMI,IAAcC,EAAA,GACd,EAAE,kBAAAC,GAAkB,mBAAAC,EAAA,IAAsBC,GAAA,GAE1C,EAAE,MAAMC,EAAA,IAAiBC,EAAwB,EAAE,YAAAd,GAAY,GAC/D,EAAE,MAAMe,EAAA,IAAqBC,EAAiD;AAAA,IAClF,YAAAhB;AAAA,EAAA,CACD,GACKiB,IAAqBC,EAAQ,MAAM,CAAClB,CAAU,GAAG,CAACA,C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