@gusto/embedded-react-sdk 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js +5 -3
  3. package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js.map +1 -1
  4. package/dist/components/Common/FadeIn/FadeIn.module.scss.js +4 -4
  5. package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.js +1 -1
  6. package/dist/components/Common/FieldCaption/FieldCaption.js.map +1 -0
  7. package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.js +1 -1
  8. package/dist/components/Common/FieldDescription/FieldDescription.js.map +1 -0
  9. package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.js +1 -1
  10. package/dist/components/Common/FieldErrorMessage/FieldErrorMessage.js.map +1 -0
  11. package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.js +1 -1
  12. package/dist/components/Common/FieldLayout/FieldLayout.js.map +1 -0
  13. package/dist/components/Common/FieldLayout/FieldLayoutTypes.d.ts +52 -0
  14. package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.js +1 -1
  15. package/dist/components/Common/Fieldset/Fieldset.js.map +1 -0
  16. package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.js +2 -2
  17. package/dist/components/Common/HorizontalFieldLayout/HorizontalFieldLayout.js.map +1 -0
  18. package/dist/components/Common/SignatureForm/SignatureForm.d.ts +12 -6
  19. package/dist/components/Common/SignatureForm/SignatureForm.js +10 -10
  20. package/dist/components/Common/SignatureForm/SignatureForm.js.map +1 -1
  21. package/dist/components/Common/UI/Alert/Alert.d.ts +1 -1
  22. package/dist/components/Common/UI/Alert/Alert.js +13 -12
  23. package/dist/components/Common/UI/Alert/Alert.js.map +1 -1
  24. package/dist/components/Common/UI/Alert/AlertTypes.d.ts +16 -4
  25. package/dist/components/Common/UI/Badge/BadgeTypes.d.ts +6 -0
  26. package/dist/components/Common/UI/Button/Button.js +28 -27
  27. package/dist/components/Common/UI/Button/Button.js.map +1 -1
  28. package/dist/components/Common/UI/Button/Button.module.scss.js +1 -1
  29. package/dist/components/Common/UI/Button/ButtonTypes.d.ts +29 -4
  30. package/dist/components/Common/UI/CalendarPreview/CalendarPreviewTypes.d.ts +24 -0
  31. package/dist/components/Common/UI/Card/Card.module.scss.js +1 -1
  32. package/dist/components/Common/UI/Card/CardTypes.d.ts +12 -4
  33. package/dist/components/Common/UI/Checkbox/Checkbox.js +4 -4
  34. package/dist/components/Common/UI/Checkbox/Checkbox.js.map +1 -1
  35. package/dist/components/Common/UI/Checkbox/CheckboxTypes.d.ts +16 -1
  36. package/dist/components/Common/UI/CheckboxGroup/CheckboxGroup.js +4 -4
  37. package/dist/components/Common/UI/CheckboxGroup/CheckboxGroup.js.map +1 -1
  38. package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.d.ts +33 -3
  39. package/dist/components/Common/UI/ComboBox/ComboBox.js +8 -8
  40. package/dist/components/Common/UI/ComboBox/ComboBox.js.map +1 -1
  41. package/dist/components/Common/UI/ComboBox/ComboBoxTypes.d.ts +31 -1
  42. package/dist/components/Common/UI/DatePicker/DatePicker.js +13 -13
  43. package/dist/components/Common/UI/DatePicker/DatePicker.js.map +1 -1
  44. package/dist/components/Common/UI/DatePicker/DatePickerTypes.d.ts +25 -1
  45. package/dist/components/Common/UI/Heading/HeadingTypes.d.ts +12 -0
  46. package/dist/components/Common/UI/Link/LinkTypes.d.ts +53 -1
  47. package/dist/components/Common/UI/List/ListTypes.d.ts +3 -5
  48. package/dist/components/Common/UI/Menu/MenuTypes.d.ts +30 -0
  49. package/dist/components/Common/UI/NumberInput/NumberInput.js +4 -4
  50. package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
  51. package/dist/components/Common/UI/NumberInput/NumberInputTypes.d.ts +34 -1
  52. package/dist/components/Common/UI/ProgressBar/ProgressBarTypes.d.ts +12 -0
  53. package/dist/components/Common/UI/Radio/Radio.js +1 -1
  54. package/dist/components/Common/UI/Radio/Radio.js.map +1 -1
  55. package/dist/components/Common/UI/Radio/RadioTypes.d.ts +16 -1
  56. package/dist/components/Common/UI/RadioGroup/RadioGroup.js +4 -4
  57. package/dist/components/Common/UI/RadioGroup/RadioGroup.js.map +1 -1
  58. package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.d.ts +33 -3
  59. package/dist/components/Common/UI/Select/Select.js +8 -8
  60. package/dist/components/Common/UI/Select/Select.js.map +1 -1
  61. package/dist/components/Common/UI/Select/SelectTypes.d.ts +34 -1
  62. package/dist/components/Common/UI/Switch/Switch.js +1 -1
  63. package/dist/components/Common/UI/Switch/Switch.js.map +1 -1
  64. package/dist/components/Common/UI/Switch/SwitchTypes.d.ts +25 -1
  65. package/dist/components/Common/UI/Table/TableTypes.d.ts +21 -0
  66. package/dist/components/Common/UI/Text/TextTypes.d.ts +18 -0
  67. package/dist/components/Common/UI/TextInput/TextInput.js +1 -1
  68. package/dist/components/Common/UI/TextInput/TextInput.js.map +1 -1
  69. package/dist/components/Common/UI/TextInput/TextInputTypes.d.ts +22 -1
  70. package/dist/components/Company/AssignSignatory/AssignSignatory.js +12 -12
  71. package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
  72. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js +7 -7
  73. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
  74. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.d.ts +2 -2
  75. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
  76. package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.d.ts +41 -15
  77. package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.js +17 -20
  78. package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.js.map +1 -1
  79. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js +10 -10
  80. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
  81. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.d.ts +17 -11
  82. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +42 -45
  83. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
  84. package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js +6 -6
  85. package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js.map +1 -1
  86. package/dist/components/Company/BankAccount/BankAccountForm/Form.d.ts +12 -6
  87. package/dist/components/Company/BankAccount/BankAccountForm/Form.js +2 -2
  88. package/dist/components/Company/BankAccount/BankAccountForm/Form.js.map +1 -1
  89. package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js +10 -10
  90. package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js.map +1 -1
  91. package/dist/components/Company/BankAccount/BankAccountVerify/Form.d.ts +12 -6
  92. package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +17 -17
  93. package/dist/components/Company/BankAccount/BankAccountVerify/Form.js.map +1 -1
  94. package/dist/components/Company/DocumentSignerFlow/SignatureForm/SignatureForm.js +1 -1
  95. package/dist/components/Company/DocumentSignerFlow/SignatureForm/SignatureForm.js.map +1 -1
  96. package/dist/components/Company/FederalTaxes/FederalTaxes.js +5 -5
  97. package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
  98. package/dist/components/Company/FederalTaxes/useFederalTaxes.d.ts +18 -8
  99. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +12 -16
  100. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  101. package/dist/components/Company/Industry/Industry.js +1 -1
  102. package/dist/components/Company/Industry/Industry.js.map +1 -1
  103. package/dist/components/Company/Locations/LocationForm/Form.d.ts +27 -11
  104. package/dist/components/Company/Locations/LocationForm/Form.js +24 -24
  105. package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
  106. package/dist/components/Company/Locations/LocationForm/LocationForm.js +24 -24
  107. package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
  108. package/dist/components/Company/PaySchedule/PaySchedule.js +7 -7
  109. package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
  110. package/dist/components/Company/PaySchedule/_parts/List.js +28 -31
  111. package/dist/components/Company/PaySchedule/_parts/List.js.map +1 -1
  112. package/dist/components/Company/PaySchedule/_parts/List.module.scss.js +8 -0
  113. package/dist/components/Company/PaySchedule/_parts/List.module.scss.js.map +1 -0
  114. package/dist/components/Company/PaySchedule/usePaySchedule.d.ts +31 -13
  115. package/dist/components/Company/PaySchedule/usePaySchedule.js +15 -20
  116. package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
  117. package/dist/components/Company/StateTaxes/StateTaxesForm/Form.d.ts +3 -3
  118. package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js +3 -3
  119. package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js.map +1 -1
  120. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +66 -77
  121. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
  122. package/dist/components/Employee/Compensation/Compensation.js +5 -5
  123. package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
  124. package/dist/components/Employee/Compensation/List.js +10 -10
  125. package/dist/components/Employee/Compensation/List.js.map +1 -1
  126. package/dist/components/Employee/Compensation/useCompensation.d.ts +90 -42
  127. package/dist/components/Employee/Compensation/useCompensation.js +45 -69
  128. package/dist/components/Employee/Compensation/useCompensation.js.map +1 -1
  129. package/dist/components/Employee/Deductions/Deductions.d.ts +9 -5
  130. package/dist/components/Employee/Deductions/Deductions.js +13 -13
  131. package/dist/components/Employee/Deductions/Deductions.js.map +1 -1
  132. package/dist/components/Employee/Deductions/useDeductions.d.ts +34 -14
  133. package/dist/components/Employee/Deductions/useDeductions.js +14 -32
  134. package/dist/components/Employee/Deductions/useDeductions.js.map +1 -1
  135. package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +1 -1
  136. package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
  137. package/dist/components/Employee/EmployeeList/EmployeeList.js +1 -1
  138. package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
  139. package/dist/components/Employee/PaymentMethod/BankAccount.d.ts +22 -10
  140. package/dist/components/Employee/PaymentMethod/BankAccount.js +9 -9
  141. package/dist/components/Employee/PaymentMethod/BankAccount.js.map +1 -1
  142. package/dist/components/Employee/PaymentMethod/PaymentMethod.js +13 -13
  143. package/dist/components/Employee/PaymentMethod/PaymentMethod.js.map +1 -1
  144. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.d.ts +10 -6
  145. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +8 -8
  146. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
  147. package/dist/components/Employee/PaymentMethod/usePaymentMethod.d.ts +92 -37
  148. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +35 -42
  149. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
  150. package/dist/components/Employee/Profile/AdminPersonalDetails.d.ts +68 -31
  151. package/dist/components/Employee/Profile/AdminPersonalDetails.js +33 -46
  152. package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
  153. package/dist/components/Employee/Profile/HomeAddress.d.ts +33 -13
  154. package/dist/components/Employee/Profile/HomeAddress.js +39 -38
  155. package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
  156. package/dist/components/Employee/Profile/PersonalDetailsInputs.d.ts +81 -32
  157. package/dist/components/Employee/Profile/PersonalDetailsInputs.js +60 -74
  158. package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
  159. package/dist/components/Employee/Profile/Profile.js +51 -55
  160. package/dist/components/Employee/Profile/Profile.js.map +1 -1
  161. package/dist/components/Employee/Profile/SelfPersonalDetails.d.ts +44 -15
  162. package/dist/components/Employee/Profile/SelfPersonalDetails.js +18 -21
  163. package/dist/components/Employee/Profile/SelfPersonalDetails.js.map +1 -1
  164. package/dist/components/Employee/Taxes/FederalForm.d.ts +28 -12
  165. package/dist/components/Employee/Taxes/FederalForm.js +28 -28
  166. package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
  167. package/dist/components/Employee/Taxes/StateForm.d.ts +9 -5
  168. package/dist/components/Employee/Taxes/StateForm.js +5 -5
  169. package/dist/components/Employee/Taxes/StateForm.js.map +1 -1
  170. package/dist/components/Employee/Taxes/Taxes.js +31 -34
  171. package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
  172. package/dist/contexts/ApiProvider/ApiProvider.d.ts +5 -0
  173. package/dist/contexts/ApiProvider/ApiProvider.js +34 -0
  174. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -0
  175. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +1 -1
  176. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +16 -16
  177. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
  178. package/dist/helpers/validations.d.ts +6 -5
  179. package/dist/helpers/validations.js +10 -17
  180. package/dist/helpers/validations.js.map +1 -1
  181. package/dist/style.css +1 -1
  182. package/package.json +7 -4
  183. package/dist/components/Common/UI/FieldCaption/FieldCaption.js.map +0 -1
  184. package/dist/components/Common/UI/FieldDescription/FieldDescription.js.map +0 -1
  185. package/dist/components/Common/UI/FieldErrorMessage/FieldErrorMessage.js.map +0 -1
  186. package/dist/components/Common/UI/FieldLayout/FieldLayout.js.map +0 -1
  187. package/dist/components/Common/UI/FieldLayout/FieldLayoutTypes.d.ts +0 -19
  188. package/dist/components/Common/UI/Fieldset/Fieldset.js.map +0 -1
  189. package/dist/components/Common/UI/HorizontalFieldLayout/HorizontalFieldLayout.js.map +0 -1
  190. /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.d.ts +0 -0
  191. /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.module.scss.js +0 -0
  192. /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.module.scss.js.map +0 -0
  193. /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/index.d.ts +0 -0
  194. /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.d.ts +0 -0
  195. /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.module.scss.js +0 -0
  196. /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.module.scss.js.map +0 -0
  197. /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/index.d.ts +0 -0
  198. /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.d.ts +0 -0
  199. /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.module.scss.js +0 -0
  200. /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.module.scss.js.map +0 -0
  201. /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/index.d.ts +0 -0
  202. /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.d.ts +0 -0
  203. /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.module.scss.js +0 -0
  204. /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.module.scss.js.map +0 -0
  205. /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/index.d.ts +0 -0
  206. /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.d.ts +0 -0
  207. /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.module.scss.js +0 -0
  208. /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.module.scss.js.map +0 -0
  209. /package/dist/components/Common/{UI/Fieldset → Fieldset}/index.d.ts +0 -0
  210. /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.d.ts +0 -0
  211. /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.module.scss.js +0 -0
  212. /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.module.scss.js.map +0 -0
  213. /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayoutTypes.d.ts +0 -0
  214. /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/index.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { jsx as n } from "react/jsx-runtime";
1
+ import { jsx as a } from "react/jsx-runtime";
2
2
  import { useTranslation as p } from "react-i18next";
3
3
  import { useCompensation as d } from "./useCompensation.js";
4
4
  import C from "../../../assets/icons/pencil.svg.js";
@@ -7,8 +7,8 @@ import { HamburgerMenu as f } from "../../Common/HamburgerMenu/HamburgerMenu.js"
7
7
  import { useDataView as y } from "../../Common/DataView/useDataView.js";
8
8
  import { DataView as g } from "../../Common/DataView/DataView.js";
9
9
  const D = () => {
10
- const { employeeJobs: o, mode: i, isPending: l, handleEdit: r, handleDelete: s } = d(), { t } = p("Employee.Compensation"), { ...m } = y({
11
- data: o,
10
+ const { employeeJobs: i, mode: o, isPending: l, handleEdit: r, handleDelete: s } = d(), { t } = p("Employee.Compensation"), { ...m } = y({
11
+ data: i,
12
12
  columns: [
13
13
  {
14
14
  key: "title",
@@ -19,10 +19,10 @@ const D = () => {
19
19
  key: "flsaStatus",
20
20
  title: t("allCompensations.typeColumn"),
21
21
  render: (e) => {
22
- const a = e.compensations?.find(
22
+ const n = e.compensations?.find(
23
23
  (u) => u.uuid === e.currentCompensationUuid
24
24
  )?.flsaStatus;
25
- return a !== void 0 ? t(`flsaStatusLabels.${a}`) : null;
25
+ return n !== void 0 ? t(`flsaStatusLabels.${n}`) : null;
26
26
  }
27
27
  },
28
28
  {
@@ -36,14 +36,14 @@ const D = () => {
36
36
  render: (e) => e.paymentUnit || ""
37
37
  }
38
38
  ],
39
- itemMenu: (e) => /* @__PURE__ */ n(
39
+ itemMenu: (e) => /* @__PURE__ */ a(
40
40
  f,
41
41
  {
42
42
  triggerLabel: t("hamburgerTitle"),
43
43
  items: [
44
44
  {
45
45
  label: t("allCompensations.editCta"),
46
- icon: /* @__PURE__ */ n(C, { "aria-hidden": !0 }),
46
+ icon: /* @__PURE__ */ a(C, { "aria-hidden": !0 }),
47
47
  onClick: () => {
48
48
  r(e.uuid);
49
49
  }
@@ -51,7 +51,7 @@ const D = () => {
51
51
  ...e.primary ? [] : [
52
52
  {
53
53
  label: t("allCompensations.deleteCta"),
54
- icon: /* @__PURE__ */ n(c, { "aria-hidden": !0 }),
54
+ icon: /* @__PURE__ */ a(c, { "aria-hidden": !0 }),
55
55
  onClick: () => {
56
56
  s(e.uuid);
57
57
  }
@@ -62,8 +62,8 @@ const D = () => {
62
62
  }
63
63
  )
64
64
  });
65
- if (i === "LIST")
66
- return /* @__PURE__ */ n(g, { label: t("allCompensations.tableLabel"), ...m });
65
+ if (o === "LIST")
66
+ return /* @__PURE__ */ a(g, { "data-testid": "data-view", label: t("allCompensations.tableLabel"), ...m });
67
67
  };
68
68
  export {
69
69
  D as List
@@ -1 +1 @@
1
- {"version":3,"file":"List.js","sources":["../../../../src/components/Employee/Compensation/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { type Job } from '@gusto/embedded-api/models/components/job'\nimport { useCompensation } from './useCompensation'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport { DataView, useDataView } from '@/components/Common'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\n\nexport const List = () => {\n const { employeeJobs, mode, isPending, handleEdit, handleDelete } = useCompensation()\n const { t } = useTranslation('Employee.Compensation')\n\n const { ...dataViewProps } = useDataView({\n data: employeeJobs,\n columns: [\n {\n key: 'title',\n title: t('allCompensations.jobColumn'),\n render: (job: Job) => job.title || '',\n },\n {\n key: 'flsaStatus',\n title: t('allCompensations.typeColumn'),\n render: (job: Job) => {\n const flsaStatus = job.compensations?.find(\n comp => comp.uuid === job.currentCompensationUuid,\n )?.flsaStatus\n return flsaStatus !== undefined ? t(`flsaStatusLabels.${flsaStatus}`) : null\n },\n },\n {\n key: 'rate',\n title: t('allCompensations.amountColumn'),\n render: (job: Job) => job.rate?.toString() || '',\n },\n {\n key: 'paymentUnit',\n title: t('allCompensations.perColumn'),\n render: (job: Job) => job.paymentUnit || '',\n },\n ],\n itemMenu: (job: Job) => (\n <HamburgerMenu\n triggerLabel={t('hamburgerTitle')}\n items={[\n {\n label: t('allCompensations.editCta'),\n icon: <PencilSvg aria-hidden />,\n onClick: () => {\n handleEdit(job.uuid)\n },\n },\n ...(!job.primary\n ? [\n {\n label: t('allCompensations.deleteCta'),\n icon: <TrashCanSvg aria-hidden />,\n onClick: () => {\n handleDelete(job.uuid)\n },\n },\n ]\n : []),\n ]}\n isLoading={isPending}\n />\n ),\n })\n\n if (mode !== 'LIST') {\n return\n }\n\n return <DataView label={t('allCompensations.tableLabel')} {...dataViewProps} />\n}\n"],"names":["List","employeeJobs","mode","isPending","handleEdit","handleDelete","useCompensation","useTranslation","dataViewProps","useDataView","job","flsaStatus","comp","jsx","HamburgerMenu","PencilSvg","TrashCanSvg","DataView"],"mappings":";;;;;;;;AAQO,MAAMA,IAAO,MAAM;AACxB,QAAM,EAAE,cAAAC,GAAc,MAAAC,GAAM,WAAAC,GAAW,YAAAC,GAAY,cAAAC,MAAiBC,EAAgB,GAC9E,EAAE,EAAA,IAAMC,EAAe,uBAAuB,GAE9C,EAAE,GAAGC,EAAc,IAAIC,EAAY;AAAA,IACvC,MAAMR;AAAA,IACN,SAAS;AAAA,MACP;AAAA,QACE,KAAK;AAAA,QACL,OAAO,E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EAAA,OAAO,EAAE,6BAA6B,GAAI,GAAGT,GAAe;AAC/E;"}
1
+ {"version":3,"file":"List.js","sources":["../../../../src/components/Employee/Compensation/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { type Job } from '@gusto/embedded-api/models/components/job'\nimport { useCompensation } from './useCompensation'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport { DataView, useDataView } from '@/components/Common'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\n\nexport const List = () => {\n const { employeeJobs, mode, isPending, handleEdit, handleDelete } = useCompensation()\n const { t } = useTranslation('Employee.Compensation')\n\n const { ...dataViewProps } = useDataView({\n data: employeeJobs,\n columns: [\n {\n key: 'title',\n title: t('allCompensations.jobColumn'),\n render: (job: Job) => job.title || '',\n },\n {\n key: 'flsaStatus',\n title: t('allCompensations.typeColumn'),\n render: (job: Job) => {\n const flsaStatus = job.compensations?.find(\n comp => comp.uuid === job.currentCompensationUuid,\n )?.flsaStatus\n return flsaStatus !== undefined ? t(`flsaStatusLabels.${flsaStatus}`) : null\n },\n },\n {\n key: 'rate',\n title: t('allCompensations.amountColumn'),\n render: (job: Job) => job.rate?.toString() || '',\n },\n {\n key: 'paymentUnit',\n title: t('allCompensations.perColumn'),\n render: (job: Job) => job.paymentUnit || '',\n },\n ],\n itemMenu: (job: Job) => (\n <HamburgerMenu\n triggerLabel={t('hamburgerTitle')}\n items={[\n {\n label: t('allCompensations.editCta'),\n icon: <PencilSvg aria-hidden />,\n onClick: () => {\n handleEdit(job.uuid)\n },\n },\n ...(!job.primary\n ? [\n {\n label: t('allCompensations.deleteCta'),\n icon: <TrashCanSvg aria-hidden />,\n onClick: () => {\n handleDelete(job.uuid)\n },\n },\n ]\n : []),\n ]}\n isLoading={isPending}\n />\n ),\n })\n\n if (mode !== 'LIST') {\n return\n }\n\n return (\n <DataView data-testid=\"data-view\" label={t('allCompensations.tableLabel')} {...dataViewProps} />\n )\n}\n"],"names":["List","employeeJobs","mode","isPending","handleEdit","handleDelete","useCompensation","useTranslation","dataViewProps","useDataView","job","flsaStatus","comp","jsx","HamburgerMenu","PencilSvg","TrashCanSvg","DataView"],"mappings":";;;;;;;;AAQO,MAAMA,IAAO,MAAM;AACxB,QAAM,EAAE,cAAAC,GAAc,MAAAC,GAAM,WAAAC,GAAW,YAAAC,GAAY,cAAAC,MAAiBC,EAAgB,GAC9E,EAAE,EAAA,IAAMC,EAAe,uBAAuB,GAE9C,EAAE,GAAGC,EAAc,IAAIC,EAAY;AAAA,IACvC,MAAMR;AAAA,IACN,SAAS;AAAA,MACP;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,4BAA4B;AAAA,QACrC,QAAQ,CAACS,MAAaA,EAAI,SAAS;AAAA,MACrC;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,6BAA6B;AAAA,QACtC,QAAQ,CAACA,MAAa;AACd,gBAAAC,IAAaD,EAAI,eAAe;AAAA,YACpC,CAAAE,MAAQA,EAAK,SAASF,EAAI;AAAA,UAAA,GACzB;AACH,iBAAOC,MAAe,SAAY,EAAE,oBAAoBA,CAAU,EAAE,IAAI;AAAA,QAAA;AAAA,MAE5E;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,+BAA+B;AAAA,QACxC,QAAQ,CAACD,MAAaA,EAAI,MAAM,cAAc;AAAA,MAChD;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,4BAA4B;AAAA,QACrC,QAAQ,CAACA,MAAaA,EAAI,eAAe;AAAA,MAAA;AAAA,IAE7C;AAAA,IACA,UAAU,CAACA,MACT,gBAAAG;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,cAAc,EAAE,gBAAgB;AAAA,QAChC,OAAO;AAAA,UACL;AAAA,YACE,OAAO,EAAE,0BAA0B;AAAA,YACnC,MAAM,gBAAAD,EAACE,GAAU,EAAA,eAAW,GAAC,CAAA;AAAA,YAC7B,SAAS,MAAM;AACb,cAAAX,EAAWM,EAAI,IAAI;AAAA,YAAA;AAAA,UAEvB;AAAA,UACA,GAAKA,EAAI,UAUL,CAAA,IATA;AAAA,YACE;AAAA,cACE,OAAO,EAAE,4BAA4B;AAAA,cACrC,MAAM,gBAAAG,EAACG,GAAY,EAAA,eAAW,GAAC,CAAA;AAAA,cAC/B,SAAS,MAAM;AACb,gBAAAX,EAAaK,EAAI,IAAI;AAAA,cAAA;AAAA,YACvB;AAAA,UACF;AAAA,QAGR;AAAA,QACA,WAAWP;AAAA,MAAA;AAAA,IAAA;AAAA,EACb,CAEH;AAED,MAAID,MAAS;AAKX,WAAA,gBAAAW,EAACI,KAAS,eAAY,aAAY,OAAO,EAAE,6BAA6B,GAAI,GAAGT,GAAe;AAElG;"}
@@ -1,51 +1,99 @@
1
1
  import { Job } from '@gusto/embedded-api/models/components/job';
2
2
  import { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage';
3
- import * as v from 'valibot';
4
- export declare const CompensationSchema: v.IntersectSchema<[v.ObjectSchema<{
5
- readonly jobTitle: v.SchemaWithPipe<[v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
6
- }, undefined>, v.VariantSchema<"adjustForMinimumWage", [v.ObjectSchema<{
7
- readonly adjustForMinimumWage: v.LiteralSchema<true, undefined>;
8
- readonly minimumWageId: v.SchemaWithPipe<[v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
9
- }, undefined>, v.ObjectSchema<{
10
- readonly adjustForMinimumWage: v.LiteralSchema<false, undefined>;
11
- }, undefined>], undefined>, v.VariantSchema<"stateWcCovered", [v.ObjectSchema<{
12
- readonly stateWcCovered: v.LiteralSchema<true, undefined>;
13
- readonly stateWcClassCode: v.SchemaWithPipe<[v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
14
- }, undefined>, v.ObjectSchema<{
15
- readonly stateWcCovered: v.LiteralSchema<false, undefined>;
16
- }, undefined>, v.ObjectSchema<{
17
- readonly stateWcCovered: v.UndefinedSchema<undefined>;
18
- }, undefined>], undefined>, v.VariantSchema<"twoPercentShareholder", [v.ObjectSchema<{
19
- readonly twoPercentShareholder: v.BooleanSchema<undefined>;
20
- }, undefined>, v.ObjectSchema<{
21
- readonly twoPercentShareholder: v.UndefinedSchema<undefined>;
22
- }, undefined>], undefined>, v.VariantSchema<"flsaStatus", [v.SchemaWithPipe<[v.ObjectSchema<{
23
- readonly flsaStatus: v.UnionSchema<[v.LiteralSchema<"Exempt", undefined>, v.LiteralSchema<"Salaried Nonexempt", undefined>, v.LiteralSchema<"Nonexempt", undefined>], undefined>;
24
- readonly paymentUnit: v.UnionSchema<[v.LiteralSchema<"Hour", undefined>, v.LiteralSchema<"Week", undefined>, v.LiteralSchema<"Month", undefined>, v.LiteralSchema<"Year", undefined>], undefined>;
25
- readonly rate: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.TransformAction<any, string>]>;
26
- }, undefined>, v.BaseValidation<{
27
- paymentUnit: "Hour" | "Week" | "Month" | "Year";
3
+ import { z } from 'zod';
4
+ export declare const CompensationSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
5
+ jobTitle: z.ZodString;
6
+ adjustForMinimumWage: z.ZodBoolean;
7
+ minimumWageId: z.ZodOptional<z.ZodString>;
8
+ stateWcCovered: z.ZodOptional<z.ZodBoolean>;
9
+ stateWcClassCode: z.ZodOptional<z.ZodString>;
10
+ twoPercentShareholder: z.ZodOptional<z.ZodBoolean>;
11
+ flsaStatus: z.ZodEnum<["Exempt", "Salaried Nonexempt", "Nonexempt", "Owner", "Commission Only Exempt", "Commission Only Nonexempt"]>;
12
+ paymentUnit: z.ZodEnum<["Hour", "Week", "Month", "Year", "Paycheck"]>;
13
+ rate: z.ZodEffects<z.ZodNumber, string, number>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ adjustForMinimumWage: boolean;
16
+ jobTitle: string;
17
+ paymentUnit: "Hour" | "Week" | "Month" | "Year" | "Paycheck";
28
18
  rate: string;
29
- flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt";
19
+ flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt" | "Owner" | "Commission Only Exempt" | "Commission Only Nonexempt";
20
+ stateWcClassCode?: string | undefined;
21
+ minimumWageId?: string | undefined;
22
+ stateWcCovered?: boolean | undefined;
23
+ twoPercentShareholder?: boolean | undefined;
30
24
  }, {
31
- paymentUnit: "Hour" | "Week" | "Month" | "Year";
25
+ adjustForMinimumWage: boolean;
26
+ jobTitle: string;
27
+ paymentUnit: "Hour" | "Week" | "Month" | "Year" | "Paycheck";
28
+ rate: number;
29
+ flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt" | "Owner" | "Commission Only Exempt" | "Commission Only Nonexempt";
30
+ stateWcClassCode?: string | undefined;
31
+ minimumWageId?: string | undefined;
32
+ stateWcCovered?: boolean | undefined;
33
+ twoPercentShareholder?: boolean | undefined;
34
+ }>, {
35
+ adjustForMinimumWage: boolean;
36
+ jobTitle: string;
37
+ paymentUnit: "Hour" | "Week" | "Month" | "Year" | "Paycheck";
32
38
  rate: string;
33
- flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt";
34
- }, v.CheckIssue<{
35
- paymentUnit: "Hour" | "Week" | "Month" | "Year";
39
+ flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt" | "Owner" | "Commission Only Exempt" | "Commission Only Nonexempt";
40
+ stateWcClassCode?: string | undefined;
41
+ minimumWageId?: string | undefined;
42
+ stateWcCovered?: boolean | undefined;
43
+ twoPercentShareholder?: boolean | undefined;
44
+ }, {
45
+ adjustForMinimumWage: boolean;
46
+ jobTitle: string;
47
+ paymentUnit: "Hour" | "Week" | "Month" | "Year" | "Paycheck";
48
+ rate: number;
49
+ flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt" | "Owner" | "Commission Only Exempt" | "Commission Only Nonexempt";
50
+ stateWcClassCode?: string | undefined;
51
+ minimumWageId?: string | undefined;
52
+ stateWcCovered?: boolean | undefined;
53
+ twoPercentShareholder?: boolean | undefined;
54
+ }>, {
55
+ adjustForMinimumWage: boolean;
56
+ jobTitle: string;
57
+ paymentUnit: "Hour" | "Week" | "Month" | "Year" | "Paycheck";
58
+ rate: string;
59
+ flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt" | "Owner" | "Commission Only Exempt" | "Commission Only Nonexempt";
60
+ stateWcClassCode?: string | undefined;
61
+ minimumWageId?: string | undefined;
62
+ stateWcCovered?: boolean | undefined;
63
+ twoPercentShareholder?: boolean | undefined;
64
+ }, {
65
+ adjustForMinimumWage: boolean;
66
+ jobTitle: string;
67
+ paymentUnit: "Hour" | "Week" | "Month" | "Year" | "Paycheck";
68
+ rate: number;
69
+ flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt" | "Owner" | "Commission Only Exempt" | "Commission Only Nonexempt";
70
+ stateWcClassCode?: string | undefined;
71
+ minimumWageId?: string | undefined;
72
+ stateWcCovered?: boolean | undefined;
73
+ twoPercentShareholder?: boolean | undefined;
74
+ }>, {
75
+ adjustForMinimumWage: boolean;
76
+ jobTitle: string;
77
+ paymentUnit: "Hour" | "Week" | "Month" | "Year" | "Paycheck";
36
78
  rate: string;
37
- flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt";
38
- }>>]>, v.ObjectSchema<{
39
- readonly flsaStatus: v.LiteralSchema<"Owner", undefined>;
40
- readonly paymentUnit: v.LiteralSchema<"Paycheck", undefined>;
41
- readonly rate: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.TransformAction<any, string>]>;
42
- }, undefined>, v.ObjectSchema<{
43
- readonly flsaStatus: v.UnionSchema<[v.LiteralSchema<"Commission Only Exempt", undefined>, v.LiteralSchema<"Commission Only Nonexempt", undefined>], undefined>;
44
- readonly paymentUnit: v.LiteralSchema<"Year", undefined>;
45
- readonly rate: v.SchemaWithPipe<[v.LiteralSchema<0, undefined>, v.TransformAction<any, string>]>;
46
- }, undefined>], undefined>], undefined>;
47
- export type CompensationInputs = v.InferInput<typeof CompensationSchema>;
48
- export type CompensationOutputs = v.InferOutput<typeof CompensationSchema>;
79
+ flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt" | "Owner" | "Commission Only Exempt" | "Commission Only Nonexempt";
80
+ stateWcClassCode?: string | undefined;
81
+ minimumWageId?: string | undefined;
82
+ stateWcCovered?: boolean | undefined;
83
+ twoPercentShareholder?: boolean | undefined;
84
+ }, {
85
+ adjustForMinimumWage: boolean;
86
+ jobTitle: string;
87
+ paymentUnit: "Hour" | "Week" | "Month" | "Year" | "Paycheck";
88
+ rate: number;
89
+ flsaStatus: "Exempt" | "Salaried Nonexempt" | "Nonexempt" | "Owner" | "Commission Only Exempt" | "Commission Only Nonexempt";
90
+ stateWcClassCode?: string | undefined;
91
+ minimumWageId?: string | undefined;
92
+ stateWcCovered?: boolean | undefined;
93
+ twoPercentShareholder?: boolean | undefined;
94
+ }>;
95
+ export type CompensationInputs = z.input<typeof CompensationSchema>;
96
+ export type CompensationOutputs = z.output<typeof CompensationSchema>;
49
97
  export type MODE = 'LIST' | 'ADD_ADDITIONAL_JOB' | 'ADD_INITIAL_JOB' | 'EDIT_ADDITIONAL_JOB' | 'EDIT_INITIAL_JOB' | 'PROCEED';
50
98
  type CompensationContextType = {
51
99
  employeeJobs: Job[];
@@ -1,73 +1,49 @@
1
- import * as e from "valibot";
2
- import { createCompoundContext as r } from "../../Base/createCompoundContext.js";
3
- import { FlsaStatus as t, FLSA_OVERTIME_SALARY_LIMIT as o } from "../../../shared/constants.js";
4
- import { yearlyRate as n } from "../../../helpers/payRateCalculator.js";
5
- const m = e.intersect([
6
- e.object({
7
- jobTitle: e.pipe(e.string(), e.nonEmpty())
8
- }),
9
- e.variant("adjustForMinimumWage", [
10
- e.object({
11
- adjustForMinimumWage: e.literal(!0),
12
- minimumWageId: e.pipe(e.string(), e.nonEmpty())
13
- }),
14
- e.object({ adjustForMinimumWage: e.literal(!1) })
1
+ import { z as t } from "zod";
2
+ import { createCompoundContext as n } from "../../Base/createCompoundContext.js";
3
+ import { FlsaStatus as r, FLSA_OVERTIME_SALARY_LIMIT as o } from "../../../shared/constants.js";
4
+ import { yearlyRate as i } from "../../../helpers/payRateCalculator.js";
5
+ const l = t.object({
6
+ jobTitle: t.string().min(1),
7
+ // adjustForMinimumWage can be true or false
8
+ adjustForMinimumWage: t.boolean(),
9
+ // If adjustForMinimumWage is true, minimumWageId is required
10
+ minimumWageId: t.string().optional(),
11
+ // stateWcCovered can be true, false, or undefined
12
+ stateWcCovered: t.boolean().optional(),
13
+ // If stateWcCovered is true, stateWcClassCode is required
14
+ stateWcClassCode: t.string().optional(),
15
+ // twoPercentShareholder can be true, false, or undefined
16
+ twoPercentShareholder: t.boolean().optional(),
17
+ // FLSA status with different payment options
18
+ flsaStatus: t.enum([
19
+ r.EXEMPT,
20
+ r.SALARIED_NONEXEMPT,
21
+ r.NONEXEMPT,
22
+ r.OWNER,
23
+ r.COMMISSION_ONLY_EXEMPT,
24
+ r.COMISSION_ONLY_NONEXEMPT
15
25
  ]),
16
- e.variant("stateWcCovered", [
17
- e.object({
18
- stateWcCovered: e.literal(!0),
19
- stateWcClassCode: e.pipe(e.string(), e.nonEmpty())
20
- }),
21
- e.object({ stateWcCovered: e.literal(!1) }),
22
- e.object({ stateWcCovered: e.undefined() })
23
- ]),
24
- e.variant("twoPercentShareholder", [
25
- e.object({ twoPercentShareholder: e.boolean() }),
26
- e.object({ twoPercentShareholder: e.undefined() })
27
- ]),
28
- e.variant("flsaStatus", [
29
- e.pipe(
30
- e.object({
31
- flsaStatus: e.union([
32
- e.literal(t.EXEMPT),
33
- e.literal(t.SALARIED_NONEXEMPT),
34
- e.literal(t.NONEXEMPT)
35
- ]),
36
- paymentUnit: e.union([
37
- e.literal("Hour"),
38
- e.literal("Week"),
39
- e.literal("Month"),
40
- e.literal("Year")
41
- ]),
42
- rate: e.pipe(e.number(), e.minValue(1), e.transform(String))
43
- }),
44
- //Exempt salary threshold validation:
45
- e.forward(
46
- e.check((a) => (
47
- //TODO: this should not be validated for non-primary jobs for NONEXEMPT
48
- a.flsaStatus !== t.EXEMPT || n(Number(a.rate), a.paymentUnit) >= o
49
- )),
50
- ["flsaStatus"]
51
- )
52
- ),
53
- e.object({
54
- flsaStatus: e.literal(t.OWNER),
55
- paymentUnit: e.literal("Paycheck"),
56
- rate: e.pipe(e.number(), e.minValue(1), e.transform(String))
57
- }),
58
- e.object({
59
- flsaStatus: e.union([
60
- e.literal(t.COMMISSION_ONLY_EXEMPT),
61
- e.literal(t.COMISSION_ONLY_NONEXEMPT)
62
- ]),
63
- paymentUnit: e.literal("Year"),
64
- rate: e.pipe(e.literal(0), e.transform(String))
65
- })
66
- ])
67
- ]), [p, c] = r("CompensationContext");
26
+ paymentUnit: t.enum(["Hour", "Week", "Month", "Year", "Paycheck"]),
27
+ rate: t.number().min(1).transform(String)
28
+ }).refine(
29
+ (e) => !(e.flsaStatus === r.OWNER && e.paymentUnit !== "Paycheck" || (e.flsaStatus === r.COMMISSION_ONLY_EXEMPT || e.flsaStatus === r.COMISSION_ONLY_NONEXEMPT) && (e.paymentUnit !== "Year" || Number(e.rate) !== 0) || e.flsaStatus === r.EXEMPT && i(Number(e.rate), e.paymentUnit) < o),
30
+ {
31
+ path: ["flsaStatus"]
32
+ }
33
+ ).refine(
34
+ (e) => e.adjustForMinimumWage ? e.minimumWageId !== void 0 && e.minimumWageId !== "" : !0,
35
+ {
36
+ path: ["minimumWageId"]
37
+ }
38
+ ).refine(
39
+ (e) => e.stateWcCovered === !0 ? e.stateWcClassCode !== void 0 && e.stateWcClassCode !== "" : !0,
40
+ {
41
+ path: ["stateWcClassCode"]
42
+ }
43
+ ), [f, p] = n("CompensationContext");
68
44
  export {
69
- c as CompensationProvider,
70
- m as CompensationSchema,
71
- p as useCompensation
45
+ p as CompensationProvider,
46
+ l as CompensationSchema,
47
+ f as useCompensation
72
48
  };
73
49
  //# sourceMappingURL=useCompensation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCompensation.js","sources":["../../../../src/components/Employee/Compensation/useCompensation.ts"],"sourcesContent":["import type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport * as v from 'valibot'\nimport { createCompoundContext } from '@/components/Base/createCompoundContext'\nimport { FLSA_OVERTIME_SALARY_LIMIT, FlsaStatus } from '@/shared/constants'\nimport { yearlyRate } from '@/helpers/payRateCalculator'\n\nexport const CompensationSchema = v.intersect([\n v.object({\n jobTitle: v.pipe(v.string(), v.nonEmpty()),\n }),\n v.variant('adjustForMinimumWage', [\n v.object({\n adjustForMinimumWage: v.literal(true),\n minimumWageId: v.pipe(v.string(), v.nonEmpty()),\n }),\n v.object({ adjustForMinimumWage: v.literal(false) }),\n ]),\n v.variant('stateWcCovered', [\n v.object({\n stateWcCovered: v.literal(true),\n stateWcClassCode: v.pipe(v.string(), v.nonEmpty()),\n }),\n v.object({ stateWcCovered: v.literal(false) }),\n v.object({ stateWcCovered: v.undefined() }),\n ]),\n v.variant('twoPercentShareholder', [\n v.object({ twoPercentShareholder: v.boolean() }),\n v.object({ twoPercentShareholder: v.undefined() }),\n ]),\n v.variant('flsaStatus', [\n v.pipe(\n v.object({\n flsaStatus: v.union([\n v.literal(FlsaStatus.EXEMPT),\n v.literal(FlsaStatus.SALARIED_NONEXEMPT),\n v.literal(FlsaStatus.NONEXEMPT),\n ]),\n paymentUnit: v.union([\n v.literal('Hour'),\n v.literal('Week'),\n v.literal('Month'),\n v.literal('Year'),\n ]),\n rate: v.pipe(v.number(), v.minValue(1), v.transform(String)),\n }),\n //Exempt salary threshold validation:\n v.forward(\n v.check(input => {\n return (\n //TODO: this should not be validated for non-primary jobs for NONEXEMPT\n input.flsaStatus !== FlsaStatus.EXEMPT ||\n yearlyRate(Number(input.rate), input.paymentUnit) >= FLSA_OVERTIME_SALARY_LIMIT\n )\n }),\n ['flsaStatus'],\n ),\n ),\n v.object({\n flsaStatus: v.literal(FlsaStatus.OWNER),\n paymentUnit: v.literal('Paycheck'),\n rate: v.pipe(v.number(), v.minValue(1), v.transform(String)),\n }),\n v.object({\n flsaStatus: v.union([\n v.literal(FlsaStatus.COMMISSION_ONLY_EXEMPT),\n v.literal(FlsaStatus.COMISSION_ONLY_NONEXEMPT),\n ]),\n paymentUnit: v.literal('Year'),\n rate: v.pipe(v.literal(0), v.transform(String)),\n }),\n ]),\n])\nexport type CompensationInputs = v.InferInput<typeof CompensationSchema>\nexport type CompensationOutputs = v.InferOutput<typeof CompensationSchema>\n\nexport type MODE =\n | 'LIST'\n | 'ADD_ADDITIONAL_JOB'\n | 'ADD_INITIAL_JOB'\n | 'EDIT_ADDITIONAL_JOB'\n | 'EDIT_INITIAL_JOB'\n | 'PROCEED'\n\ntype CompensationContextType = {\n employeeJobs: Job[]\n currentJob?: Job | null\n primaryFlsaStatus?: string\n isPending: boolean\n mode: MODE\n showFlsaChangeWarning: boolean\n minimumWages: MinimumWage[]\n state?: string\n showTwoPercentStakeholder?: boolean\n submitWithEffect: (newMode: MODE) => void\n handleAdd: () => void\n handleEdit: (uuid: string) => void\n handleDelete: (uuid: string) => void\n handleFlsaChange: (status: string | number) => void\n handleCancelAddJob: () => void\n}\nconst [useCompensation, CompensationProvider] =\n createCompoundContext<CompensationContextType>('CompensationContext')\nexport { useCompensation, CompensationProvider }\n"],"names":["CompensationSchema","v","FlsaStatus","input","yearlyRate","FLSA_OVERTIME_SALARY_LIMIT","useCompensation","CompensationProvider","createCompoundContext"],"mappings":";;;;AAOa,MAAAA,IAAqBC,EAAE,UAAU;AAAA,EAC5CA,EAAE,OAAO;AAAA,IACP,UAAUA,EAAE,KAAKA,EAAE,OAAU,GAAAA,EAAE,SAAU,CAAA;AAAA,EAAA,CAC1C;AAAA,EACDA,EAAE,QAAQ,wBAAwB;AAAA,IAChCA,EAAE,OAAO;AA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AAU,MAAM,CAAC;AAAA,MAAA,CAC5D;AAAA;AAAA,MAEDA,EAAE;AAAA,QACAA,EAAE,MAAM,CAASE;AAAA;AAAA,UAGbA,EAAM,eAAeD,EAAW,UAChCE,EAAW,OAAOD,EAAM,IAAI,GAAGA,EAAM,WAAW,KAAKE;AAAA,SAExD;AAAA,QACD,CAAC,YAAY;AAAA,MAAA;AAAA,IAEjB;AAAA,IACAJ,EAAE,OAAO;AAAA,MACP,YAAYA,EAAE,QAAQC,EAAW,KAAK;AAAA,MACtC,aAAaD,EAAE,QAAQ,UAAU;AAAA,MACjC,MAAMA,EAAE,KAAKA,EAAE,OAAO,GAAGA,EAAE,SAAS,CAAC,GAAGA,EAAE,UAAU,MAAM,CAAC;AAAA,IAAA,CAC5D;AAAA,IACDA,EAAE,OAAO;AAAA,MACP,YAAYA,EAAE,MAAM;AAAA,QAClBA,EAAE,QAAQC,EAAW,sBAAsB;AAAA,QAC3CD,EAAE,QAAQC,EAAW,wBAAwB;AAAA,MAAA,CAC9C;AAAA,MACD,aAAaD,EAAE,QAAQ,MAAM;AAAA,MAC7B,MAAMA,EAAE,KAAKA,EAAE,QAAQ,CAAC,GAAGA,EAAE,UAAU,MAAM,CAAC;AAAA,IAC/C,CAAA;AAAA,EACF,CAAA;AACH,CAAC,GA6BK,CAACK,GAAiBC,CAAoB,IAC1CC,EAA+C,qBAAqB;"}
1
+ {"version":3,"file":"useCompensation.js","sources":["../../../../src/components/Employee/Compensation/useCompensation.ts"],"sourcesContent":["import type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base/createCompoundContext'\nimport { FLSA_OVERTIME_SALARY_LIMIT, FlsaStatus } from '@/shared/constants'\nimport { yearlyRate } from '@/helpers/payRateCalculator'\n\nexport const CompensationSchema = z\n .object({\n jobTitle: z.string().min(1),\n // adjustForMinimumWage can be true or false\n adjustForMinimumWage: z.boolean(),\n // If adjustForMinimumWage is true, minimumWageId is required\n minimumWageId: z.string().optional(),\n // stateWcCovered can be true, false, or undefined\n stateWcCovered: z.boolean().optional(),\n // If stateWcCovered is true, stateWcClassCode is required\n stateWcClassCode: z.string().optional(),\n // twoPercentShareholder can be true, false, or undefined\n twoPercentShareholder: z.boolean().optional(),\n // FLSA status with different payment options\n flsaStatus: z.enum([\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMISSION_ONLY_NONEXEMPT,\n ]),\n paymentUnit: z.enum(['Hour', 'Week', 'Month', 'Year', 'Paycheck']),\n rate: z.number().min(1).transform(String),\n })\n .refine(\n data => {\n // For Owner, paymentUnit must be Paycheck\n if (data.flsaStatus === FlsaStatus.OWNER && data.paymentUnit !== 'Paycheck') {\n return false\n }\n // For Commission only, paymentUnit must be Year and rate must be 0\n if (\n (data.flsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT ||\n data.flsaStatus === FlsaStatus.COMISSION_ONLY_NONEXEMPT) &&\n (data.paymentUnit !== 'Year' || Number(data.rate) !== 0)\n ) {\n return false\n }\n // For Exempt status, validate salary threshold\n if (\n data.flsaStatus === FlsaStatus.EXEMPT &&\n yearlyRate(Number(data.rate), data.paymentUnit) < FLSA_OVERTIME_SALARY_LIMIT\n ) {\n return false\n }\n\n return true\n },\n {\n path: ['flsaStatus'],\n },\n )\n .refine(\n data => {\n if (data.adjustForMinimumWage) {\n return data.minimumWageId !== undefined && data.minimumWageId !== ''\n }\n return true\n },\n {\n path: ['minimumWageId'],\n },\n )\n .refine(\n data => {\n if (data.stateWcCovered === true) {\n return data.stateWcClassCode !== undefined && data.stateWcClassCode !== ''\n }\n return true\n },\n {\n path: ['stateWcClassCode'],\n },\n )\n\nexport type CompensationInputs = z.input<typeof CompensationSchema>\nexport type CompensationOutputs = z.output<typeof CompensationSchema>\n\nexport type MODE =\n | 'LIST'\n | 'ADD_ADDITIONAL_JOB'\n | 'ADD_INITIAL_JOB'\n | 'EDIT_ADDITIONAL_JOB'\n | 'EDIT_INITIAL_JOB'\n | 'PROCEED'\n\ntype CompensationContextType = {\n employeeJobs: Job[]\n currentJob?: Job | null\n primaryFlsaStatus?: string\n isPending: boolean\n mode: MODE\n showFlsaChangeWarning: boolean\n minimumWages: MinimumWage[]\n state?: string\n showTwoPercentStakeholder?: boolean\n submitWithEffect: (newMode: MODE) => void\n handleAdd: () => void\n handleEdit: (uuid: string) => void\n handleDelete: (uuid: string) => void\n handleFlsaChange: (status: string | number) => void\n handleCancelAddJob: () => void\n}\nconst [useCompensation, CompensationProvider] =\n createCompoundContext<CompensationContextType>('CompensationContext')\nexport { useCompensation, CompensationProvider }\n"],"names":["CompensationSchema","z","FlsaStatus","data","yearlyRate","FLSA_OVERTIME_SALARY_LIMIT","useCompensation","CompensationProvider","createCompoundContext"],"mappings":";;;;AAOa,MAAAA,IAAqBC,EAC/B,OAAO;AAAA,EACN,UAAUA,EAAE,SAAS,IAAI,CAAC;AAAA;AAAA,EAE1B,sBAAsBA,EAAE,QAAQ;AAAA;AAAA,EAEhC,eAAeA,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAEnC,gBAAgBA,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAErC,kBAAkBA,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAEtC,uBAAuBA,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAE5C,YAAYA,EAAE,KAAK;AAAA,IACjBC,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,EAAA,CACZ;AAAA,EACD,aAAaD,EAAE,KAAK,CAAC,QAAQ,QAAQ,SAAS,QAAQ,UAAU,CAAC;AAAA,EACjE,MAAMA,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,UAAU,MAAM;AAC1C,CAAC,EACA;AAAA,EACC,CAAQE,MAEF,EAAAA,EAAK,eAAeD,EAAW,SAASC,EAAK,gBAAgB,eAK9DA,EAAK,eAAeD,EAAW,0BAC9BC,EAAK,eAAeD,EAAW,8BAChCC,EAAK,gBAAgB,UAAU,OAAOA,EAAK,IAAI,MAAM,MAMtDA,EAAK,eAAeD,EAAW,UAC/BE,EAAW,OAAOD,EAAK,IAAI,GAAGA,EAAK,WAAW,IAAIE;AAAA,EAOtD;AAAA,IACE,MAAM,CAAC,YAAY;AAAA,EAAA;AAEvB,EACC;AAAA,EACC,CAAQF,MACFA,EAAK,uBACAA,EAAK,kBAAkB,UAAaA,EAAK,kBAAkB,KAE7D;AAAA,EAET;AAAA,IACE,MAAM,CAAC,eAAe;AAAA,EAAA;AAE1B,EACC;AAAA,EACC,CAAQA,MACFA,EAAK,mBAAmB,KACnBA,EAAK,qBAAqB,UAAaA,EAAK,qBAAqB,KAEnE;AAAA,EAET;AAAA,IACE,MAAM,CAAC,kBAAkB;AAAA,EAAA;AAE7B,GA8BI,CAACG,GAAiBC,CAAoB,IAC1CC,EAA+C,qBAAqB;"}
@@ -1,12 +1,16 @@
1
+ import { z } from 'zod';
1
2
  import { BaseComponentInterface, CommonComponentInterface } from '../../Base';
2
- import * as v from 'valibot';
3
3
  interface DeductionsProps extends CommonComponentInterface {
4
4
  employeeId: string;
5
5
  }
6
- declare const IncludeDeductionsSchema: v.ObjectSchema<{
7
- readonly includeDeductions: v.PicklistSchema<["Yes", "No"], undefined>;
8
- }, undefined>;
9
- export type IncludeDeductionsPayload = v.InferOutput<typeof IncludeDeductionsSchema>;
6
+ declare const IncludeDeductionsSchema: z.ZodObject<{
7
+ includeDeductions: z.ZodEnum<["Yes", "No"]>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ includeDeductions: "Yes" | "No";
10
+ }, {
11
+ includeDeductions: "Yes" | "No";
12
+ }>;
13
+ export type IncludeDeductionsPayload = z.output<typeof IncludeDeductionsSchema>;
10
14
  export declare function Deductions(props: DeductionsProps & BaseComponentInterface): import("react/jsx-runtime").JSX.Element;
11
15
  export declare const Root: ({ employeeId, className }: DeductionsProps) => import("react/jsx-runtime").JSX.Element;
12
16
  export declare const DeductionsContextual: () => import("react/jsx-runtime").JSX.Element;
@@ -1,16 +1,16 @@
1
1
  import { jsx as t, jsxs as I } from "react/jsx-runtime";
2
2
  import { useTranslation as Y } from "react-i18next";
3
3
  import { useState as M, useMemo as q, useEffect as B } from "react";
4
- import * as A from "valibot";
4
+ import { z as A } from "zod";
5
5
  import { useForm as C, FormProvider as O } from "react-hook-form";
6
- import { valibotResolver as R } from "@hookform/resolvers/valibot";
6
+ import { zodResolver as R } from "@hookform/resolvers/zod";
7
7
  import { useGarnishmentsListSuspense as y, invalidateGarnishmentsList as T } from "@gusto/embedded-api/react-query/garnishmentsList";
8
8
  import { useGarnishmentsCreateMutation as G } from "@gusto/embedded-api/react-query/garnishmentsCreate";
9
9
  import { useGarnishmentsUpdateMutation as j } from "@gusto/embedded-api/react-query/garnishmentsUpdate";
10
- import { useQueryClient as H } from "@gusto/embedded-api/ReactSDKProvider";
11
- import { DeductionSchema as V, DeductionsProvider as k } from "./useDeductions.js";
10
+ import { useQueryClient as z } from "@tanstack/react-query";
11
+ import { DeductionSchema as H, DeductionsProvider as V } from "./useDeductions.js";
12
12
  import { BaseComponent as Q } from "../../Base/Base.js";
13
- import { useBase as z } from "../../Base/useBase.js";
13
+ import { useBase as k } from "../../Base/useBase.js";
14
14
  import { Form as L } from "../../Common/Form/Form.js";
15
15
  import { useI18n as J } from "../../../i18n/I18n.js";
16
16
  import { componentEvents as s } from "../../../shared/constants.js";
@@ -20,12 +20,12 @@ import { Head as N } from "./Head.js";
20
20
  import { DeductionForm as W } from "./DeductionForm.js";
21
21
  import { DeductionsList as X } from "./DeductionsList.js";
22
22
  import { useFlow as Z } from "../../Flow/useFlow.js";
23
- A.object({ includeDeductions: A.picklist(["Yes", "No"]) });
23
+ A.object({ includeDeductions: A.enum(["Yes", "No"]) });
24
24
  function $(n) {
25
25
  return /* @__PURE__ */ t(Q, { ...n, children: /* @__PURE__ */ t(ee, { ...n, children: n.children }) });
26
26
  }
27
27
  const ee = ({ employeeId: n, className: d }) => {
28
- const { onEvent: r, baseSubmitHandler: E } = z(), h = H(), { data: b } = y({ employeeId: n }), f = b.garnishmentList, { mutateAsync: p, isPending: _ } = j({
28
+ const { onEvent: r, baseSubmitHandler: E } = k(), h = z(), { data: _ } = y({ employeeId: n }), f = _.garnishmentList, { mutateAsync: p, isPending: b } = j({
29
29
  onSettled: () => T(h, [n])
30
30
  }), { mutateAsync: x, isPending: w } = G({
31
31
  onSettled: () => T(h, [n])
@@ -42,10 +42,10 @@ const ee = ({ employeeId: n, className: d }) => {
42
42
  active: !0,
43
43
  courtOrdered: e?.courtOrdered ?? !1
44
44
  }), [e]), g = C({
45
- // resolver: valibotResolver(IncludeDeductionsSchema),
45
+ // resolver: zodResolver(IncludeDeductionsSchema),
46
46
  defaultValues: { includeDeductions: "No" }
47
47
  }), D = C({
48
- resolver: R(V),
48
+ resolver: R(H),
49
49
  defaultValues: l
50
50
  }), { reset: P } = D;
51
51
  B(() => {
@@ -102,10 +102,10 @@ const ee = ({ employeeId: n, className: d }) => {
102
102
  });
103
103
  };
104
104
  return /* @__PURE__ */ t("section", { className: d, children: /* @__PURE__ */ t(
105
- k,
105
+ V,
106
106
  {
107
107
  value: {
108
- isPending: w || _,
108
+ isPending: w || b,
109
109
  employeeId: n,
110
110
  mode: u,
111
111
  deductions: f,
@@ -135,7 +135,7 @@ const ee = ({ employeeId: n, className: d }) => {
135
135
  ] }) })
136
136
  }
137
137
  ) });
138
- }, Te = () => {
138
+ }, Le = () => {
139
139
  const { employeeId: n, onEvent: d } = Z(), { t: r } = Y("common");
140
140
  if (!n)
141
141
  throw new Error(
@@ -149,7 +149,7 @@ const ee = ({ employeeId: n, className: d }) => {
149
149
  };
150
150
  export {
151
151
  $ as Deductions,
152
- Te as DeductionsContextual,
152
+ Le as DeductionsContextual,
153
153
  ee as Root
154
154
  };
155
155
  //# sourceMappingURL=Deductions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Deductions.js","sources":["../../../../src/components/Employee/Deductions/Deductions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useEffect, useMemo, useState } from 'react'\nimport * as v from 'valibot'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { valibotResolver } from '@hookform/resolvers/valibot'\nimport {\n useGarnishmentsListSuspense,\n invalidateGarnishmentsList,\n} from '@gusto/embedded-api/react-query/garnishmentsList'\nimport { type Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api/react-query/garnishmentsUpdate'\nimport { useQueryClient } from '@gusto/embedded-api/ReactSDKProvider'\nimport {\n type DeductionInputs,\n type DeductionPayload,\n DeductionSchema,\n DeductionsProvider,\n type MODE,\n} from './useDeductions'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { Form } from '@/components/Common/Form'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { Actions } from '@/components/Employee/Deductions/Actions'\nimport { IncludeDeductionsForm } from '@/components/Employee/Deductions/IncludeDeductionsForm'\nimport { Head } from '@/components/Employee/Deductions/Head'\nimport { DeductionForm } from '@/components/Employee/Deductions/DeductionForm'\nimport { DeductionsList } from '@/components/Employee/Deductions/DeductionsList'\nimport type { EmployeeOnboardingContextInterface } from '@/components/Flow/EmployeeOnboardingFlow'\nimport { useFlow } from '@/components/Flow/useFlow'\n\ninterface DeductionsProps extends CommonComponentInterface {\n employeeId: string\n}\n\nconst IncludeDeductionsSchema = v.object({ includeDeductions: v.picklist(['Yes', 'No']) })\nexport type IncludeDeductionsPayload = v.InferOutput<typeof IncludeDeductionsSchema>\n\nexport function Deductions(props: DeductionsProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\nexport const Root = ({ employeeId, className }: DeductionsProps) => {\n const { onEvent, baseSubmitHandler } = useBase()\n const queryClient = useQueryClient()\n\n const { data } = useGarnishmentsListSuspense({ employeeId })\n const deductions = data.garnishmentList!\n\n // Used for deletion or edit of deduction\n const { mutateAsync: updateDeduction, isPending: isPendingUpdate } =\n useGarnishmentsUpdateMutation({\n onSettled: () => invalidateGarnishmentsList(queryClient, [employeeId]),\n })\n const { mutateAsync: createDeduction, isPending: isPendingCreate } =\n useGarnishmentsCreateMutation({\n onSettled: () => invalidateGarnishmentsList(queryClient, [employeeId]),\n })\n\n const activeDeductions = deductions.filter(deduction => deduction.active)\n const [mode, setMode] = useState<MODE>(activeDeductions.length < 1 ? 'INITIAL' : 'LIST')\n const [currentDeduction, setCurrentDeduction] = useState<Garnishment | null>(null)\n useI18n('Employee.Deductions')\n\n const defaultValues: DeductionInputs = useMemo(() => {\n return {\n amount: currentDeduction?.amount ? Number(currentDeduction.amount) : 0,\n description: currentDeduction?.description ?? '',\n times: currentDeduction?.times ?? null,\n recurring: currentDeduction?.recurring?.toString() ?? 'true',\n annualMaximum: currentDeduction?.annualMaximum\n ? Number(currentDeduction.annualMaximum)\n : null,\n payPeriodMaximum: currentDeduction?.payPeriodMaximum\n ? Number(currentDeduction.payPeriodMaximum)\n : null,\n deductAsPercentage: currentDeduction?.deductAsPercentage?.toString() ?? 'true',\n active: true,\n courtOrdered: currentDeduction?.courtOrdered ?? false,\n } as DeductionInputs\n }, [currentDeduction])\n\n const includeDeductionsFormMethods = useForm<IncludeDeductionsPayload>({\n // resolver: valibotResolver(IncludeDeductionsSchema),\n defaultValues: { includeDeductions: 'No' },\n })\n\n const formMethods = useForm<DeductionInputs, unknown, DeductionPayload>({\n resolver: valibotResolver(DeductionSchema),\n defaultValues,\n })\n\n const { reset: resetForm } = formMethods\n\n useEffect(() => {\n resetForm(defaultValues)\n }, [currentDeduction, defaultValues, resetForm, mode])\n\n const handleDelete = async (deduction: Garnishment) => {\n await baseSubmitHandler(deduction, async payload => {\n //Deletion of deduction is simply updating it with active: false\n const { garnishment } = await updateDeduction({\n request: {\n garnishmentId: payload.uuid,\n requestBody: {\n ...payload,\n totalAmount: payload.totalAmount ?? undefined,\n active: false,\n version: payload.version as string,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DELETED, garnishment)\n })\n }\n const onSubmit: SubmitHandler<DeductionPayload | IncludeDeductionsPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n if ('includeDeductions' in payload) {\n if (payload.includeDeductions === 'Yes') {\n setMode('ADD')\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_ADD)\n } else {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DONE)\n return\n }\n }\n if (!('includeDeductions' in payload)) {\n if (mode === 'ADD') {\n const { garnishment: createDeductionResponse } = await createDeduction({\n request: {\n employeeId: employeeId,\n requestBody: { ...payload, times: payload.recurring ? null : 1 },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CREATED, createDeductionResponse)\n } else if (mode === 'EDIT') {\n const { garnishment: updateDeductionResponse } = await updateDeduction({\n request: {\n garnishmentId: currentDeduction?.uuid ?? '',\n requestBody: {\n ...payload,\n version: currentDeduction?.version as string,\n times: payload.recurring ? null : 1,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_UPDATED, updateDeductionResponse)\n setCurrentDeduction(null)\n }\n setMode('LIST')\n }\n })\n }\n const handleAdd = () => {\n setMode('ADD')\n }\n const handleCancel = () => {\n setMode('LIST')\n setCurrentDeduction(null)\n }\n const handleEdit = (deduction: Garnishment) => {\n setMode('EDIT')\n setCurrentDeduction(deduction)\n }\n const handlePassthrough = () => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DONE)\n }\n return (\n <section className={className}>\n <DeductionsProvider\n value={{\n isPending: isPendingCreate || isPendingUpdate,\n employeeId,\n mode,\n deductions,\n handleAdd,\n handleCancel,\n handleDelete,\n handleEdit,\n handlePassthrough,\n }}\n >\n {mode === 'INITIAL' ? (\n <FormProvider {...includeDeductionsFormMethods}>\n <Form onSubmit={includeDeductionsFormMethods.handleSubmit(onSubmit)}>\n <Head />\n <IncludeDeductionsForm />\n <Actions />\n </Form>\n </FormProvider>\n ) : (\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Head />\n <DeductionsList />\n <DeductionForm />\n <Actions />\n </Form>\n </FormProvider>\n )}\n </DeductionsProvider>\n </section>\n )\n}\n\nexport const DeductionsContextual = () => {\n const { employeeId, onEvent } = useFlow<EmployeeOnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Deductions',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <Deductions employeeId={employeeId} onEvent={onEvent} />\n}\n"],"names":["v","Deductions","props","jsx","BaseComponent","Root","employeeId","className","onEvent","baseSubmitHandler","useBase","queryClient","useQueryClient","data","useGarnishmentsListSuspense","deductions","updateDeduction","isPendingUpdate","useGarnishmentsUpdateMutation","invalidateGarnishmentsList","createDeduction","isPendingCreate","useGarnishmentsCreateMutation","activeDeductions","deduction","mode","setMode","useState","currentDeduction","setCurrentDeduction","useI18n","defaultValues","useMemo","includeDeductionsFormMethods","useForm","formMethods","valibotResolver","DeductionSchema","resetForm","useEffect","handleDelete","payload","garnishment","componentEvents","onSubmit","createDeductionResponse","updateDeductionResponse","DeductionsProvider","FormProvider","jsxs","Form","Head","IncludeDeductionsForm","Actions","DeductionsList","DeductionForm","DeductionsContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyCgCA,EAAE,OAAO,EAAE,mBAAmBA,EAAE,SAAS,CAAC,OAAO,IAAI,CAAC,EA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,aAAaW,CAAQ,GAChE,UAAA;AAAA,QAAA,gBAAAzC,EAACgD,GAAK,EAAA;AAAA,0BACLC,GAAsB,EAAA;AAAA,0BACtBC,GAAQ,CAAA,CAAA;AAAA,MAAA,EACX,CAAA,EACF,CAAA,IAEC,gBAAAlD,EAAA6C,GAAA,EAAc,GAAGb,GAChB,UAAC,gBAAAc,EAAAC,GAAA,EAAK,UAAUf,EAAY,aAAaS,CAAQ,GAC/C,UAAA;AAAA,QAAA,gBAAAzC,EAACgD,GAAK,EAAA;AAAA,0BACLG,GAAe,EAAA;AAAA,0BACfC,GAAc,EAAA;AAAA,0BACdF,GAAQ,CAAA,CAAA;AAAA,MAAA,EAAA,CACX,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAGN;AAEJ,GAEaG,KAAuB,MAAM;AACxC,QAAM,EAAE,YAAAlD,GAAY,SAAAE,EAAQ,IAAIiD,EAA4C,GACtE,EAAE,GAAAC,EAAA,IAAMC,EAAe,QAAQ;AAErC,MAAI,CAACrD;AACH,UAAM,IAAI;AAAA,MACRoD,EAAE,iCAAiC;AAAA,QACjC,WAAW;AAAA,QACX,OAAO;AAAA,QACP,UAAU;AAAA,MACX,CAAA;AAAA,IACH;AAEK,SAAA,gBAAAvD,EAACF,GAAW,EAAA,YAAAK,GAAwB,SAAAE,EAAkB,CAAA;AAC/D;"}
1
+ {"version":3,"file":"Deductions.js","sources":["../../../../src/components/Employee/Deductions/Deductions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useEffect, useMemo, useState } from 'react'\nimport { z } from 'zod'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport {\n useGarnishmentsListSuspense,\n invalidateGarnishmentsList,\n} from '@gusto/embedded-api/react-query/garnishmentsList'\nimport { type Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api/react-query/garnishmentsUpdate'\nimport { useQueryClient } from '@tanstack/react-query'\nimport {\n type DeductionInputs,\n type DeductionPayload,\n DeductionSchema,\n DeductionsProvider,\n type MODE,\n} from './useDeductions'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { Form } from '@/components/Common/Form'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { Actions } from '@/components/Employee/Deductions/Actions'\nimport { IncludeDeductionsForm } from '@/components/Employee/Deductions/IncludeDeductionsForm'\nimport { Head } from '@/components/Employee/Deductions/Head'\nimport { DeductionForm } from '@/components/Employee/Deductions/DeductionForm'\nimport { DeductionsList } from '@/components/Employee/Deductions/DeductionsList'\nimport type { EmployeeOnboardingContextInterface } from '@/components/Flow/EmployeeOnboardingFlow'\nimport { useFlow } from '@/components/Flow/useFlow'\n\ninterface DeductionsProps extends CommonComponentInterface {\n employeeId: string\n}\n\nconst IncludeDeductionsSchema = z.object({ includeDeductions: z.enum(['Yes', 'No']) })\nexport type IncludeDeductionsPayload = z.output<typeof IncludeDeductionsSchema>\n\nexport function Deductions(props: DeductionsProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\nexport const Root = ({ employeeId, className }: DeductionsProps) => {\n const { onEvent, baseSubmitHandler } = useBase()\n const queryClient = useQueryClient()\n\n const { data } = useGarnishmentsListSuspense({ employeeId })\n const deductions = data.garnishmentList!\n\n // Used for deletion or edit of deduction\n const { mutateAsync: updateDeduction, isPending: isPendingUpdate } =\n useGarnishmentsUpdateMutation({\n onSettled: () => invalidateGarnishmentsList(queryClient, [employeeId]),\n })\n const { mutateAsync: createDeduction, isPending: isPendingCreate } =\n useGarnishmentsCreateMutation({\n onSettled: () => invalidateGarnishmentsList(queryClient, [employeeId]),\n })\n\n const activeDeductions = deductions.filter(deduction => deduction.active)\n const [mode, setMode] = useState<MODE>(activeDeductions.length < 1 ? 'INITIAL' : 'LIST')\n const [currentDeduction, setCurrentDeduction] = useState<Garnishment | null>(null)\n useI18n('Employee.Deductions')\n\n const defaultValues: DeductionInputs = useMemo(() => {\n return {\n amount: currentDeduction?.amount ? Number(currentDeduction.amount) : 0,\n description: currentDeduction?.description ?? '',\n times: currentDeduction?.times ?? null,\n recurring: currentDeduction?.recurring?.toString() ?? 'true',\n annualMaximum: currentDeduction?.annualMaximum\n ? Number(currentDeduction.annualMaximum)\n : null,\n payPeriodMaximum: currentDeduction?.payPeriodMaximum\n ? Number(currentDeduction.payPeriodMaximum)\n : null,\n deductAsPercentage: currentDeduction?.deductAsPercentage?.toString() ?? 'true',\n active: true,\n courtOrdered: currentDeduction?.courtOrdered ?? false,\n } as DeductionInputs\n }, [currentDeduction])\n\n const includeDeductionsFormMethods = useForm<IncludeDeductionsPayload>({\n // resolver: zodResolver(IncludeDeductionsSchema),\n defaultValues: { includeDeductions: 'No' },\n })\n\n const formMethods = useForm<DeductionInputs, unknown, DeductionPayload>({\n resolver: zodResolver(DeductionSchema),\n defaultValues,\n })\n\n const { reset: resetForm } = formMethods\n\n useEffect(() => {\n resetForm(defaultValues)\n }, [currentDeduction, defaultValues, resetForm, mode])\n\n const handleDelete = async (deduction: Garnishment) => {\n await baseSubmitHandler(deduction, async payload => {\n //Deletion of deduction is simply updating it with active: false\n const { garnishment } = await updateDeduction({\n request: {\n garnishmentId: payload.uuid,\n requestBody: {\n ...payload,\n totalAmount: payload.totalAmount ?? undefined,\n active: false,\n version: payload.version as string,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DELETED, garnishment)\n })\n }\n const onSubmit: SubmitHandler<DeductionPayload | IncludeDeductionsPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n if ('includeDeductions' in payload) {\n if (payload.includeDeductions === 'Yes') {\n setMode('ADD')\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_ADD)\n } else {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DONE)\n return\n }\n }\n if (!('includeDeductions' in payload)) {\n if (mode === 'ADD') {\n const { garnishment: createDeductionResponse } = await createDeduction({\n request: {\n employeeId: employeeId,\n requestBody: { ...payload, times: payload.recurring ? null : 1 },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CREATED, createDeductionResponse)\n } else if (mode === 'EDIT') {\n const { garnishment: updateDeductionResponse } = await updateDeduction({\n request: {\n garnishmentId: currentDeduction?.uuid ?? '',\n requestBody: {\n ...payload,\n version: currentDeduction?.version as string,\n times: payload.recurring ? null : 1,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_UPDATED, updateDeductionResponse)\n setCurrentDeduction(null)\n }\n setMode('LIST')\n }\n })\n }\n const handleAdd = () => {\n setMode('ADD')\n }\n const handleCancel = () => {\n setMode('LIST')\n setCurrentDeduction(null)\n }\n const handleEdit = (deduction: Garnishment) => {\n setMode('EDIT')\n setCurrentDeduction(deduction)\n }\n const handlePassthrough = () => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DONE)\n }\n return (\n <section className={className}>\n <DeductionsProvider\n value={{\n isPending: isPendingCreate || isPendingUpdate,\n employeeId,\n mode,\n deductions,\n handleAdd,\n handleCancel,\n handleDelete,\n handleEdit,\n handlePassthrough,\n }}\n >\n {mode === 'INITIAL' ? (\n <FormProvider {...includeDeductionsFormMethods}>\n <Form onSubmit={includeDeductionsFormMethods.handleSubmit(onSubmit)}>\n <Head />\n <IncludeDeductionsForm />\n <Actions />\n </Form>\n </FormProvider>\n ) : (\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Head />\n <DeductionsList />\n <DeductionForm />\n <Actions />\n </Form>\n </FormProvider>\n )}\n </DeductionsProvider>\n </section>\n )\n}\n\nexport const DeductionsContextual = () => {\n const { employeeId, onEvent } = useFlow<EmployeeOnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Deductions',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <Deductions employeeId={employeeId} onEvent={onEvent} />\n}\n"],"names":["z","Deductions","props","jsx","BaseComponent","Root","employeeId","className","onEvent","baseSubmitHandler","useBase","queryClient","useQueryClient","data","useGarnishmentsListSuspense","deductions","updateDeduction","isPendingUpdate","useGarnishmentsUpdateMutation","invalidateGarnishmentsList","createDeduction","isPendingCreate","useGarnishmentsCreateMutation","activeDeductions","deduction","mode","setMode","useState","currentDeduction","setCurrentDeduction","useI18n","defaultValues","useMemo","includeDeductionsFormMethods","useForm","formMethods","zodResolver","DeductionSchema","resetForm","useEffect","handleDelete","payload","garnishment","componentEvents","onSubmit","createDeductionResponse","updateDeductionResponse","DeductionsProvider","FormProvider","jsxs","Form","Head","IncludeDeductionsForm","Actions","DeductionsList","DeductionForm","DeductionsContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyCgCA,EAAE,OAAO,EAAE,mBAAmBA,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,EAAG,CAAA;AAG9E,SAASC,EAAWC,GAAiD;AAExE,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,MAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AACO,MAAMG,KAAO,CAAC,EAAE,YAAAC,GAAY,WAAAC,QAAiC;AAClE,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzCC,IAAcC,EAAe,GAE7B,EAAE,MAAAC,EAAK,IAAIC,EAA4B,EAAE,YAAAR,GAAY,GACrDS,IAAaF,EAAK,iBAGlB,EAAE,aAAaG,GAAiB,WAAWC,EAAA,IAC/CC,EAA8B;AAAA,IAC5B,WAAW,MAAMC,EAA2BR,GAAa,CAACL,CAAU,CAAC;AAAA,EAAA,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