@gusto/embedded-react-sdk 0.37.0-rc.2 → 0.37.0-rc.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 (41) hide show
  1. package/README.md +3 -0
  2. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +11 -11
  3. package/dist/components/Company/PaySchedule/_parts/Edit.js +6 -6
  4. package/dist/components/Contractor/Profile/ContractorProfileForm.js +15 -15
  5. package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilityPresentation.js +16 -16
  6. package/dist/components/Employee/Profile/PersonalDetailsInputs.js +1 -1
  7. package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployeePresentation.js +10 -10
  8. package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +10 -10
  9. package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js +44 -46
  10. package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js.map +1 -1
  11. package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js +25 -23
  12. package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js.map +1 -1
  13. package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +1 -1
  14. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +105 -106
  15. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
  16. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +54 -54
  17. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
  18. package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.d.ts +2 -1
  19. package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js +29 -27
  20. package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js.map +1 -1
  21. package/dist/components/Payroll/PayrollExecutionFlow/index.d.ts +1 -1
  22. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.d.ts +1 -1
  23. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +60 -60
  24. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
  25. package/dist/components/Payroll/PayrollFlow/PayrollExecutionFlowContextual.js +22 -20
  26. package/dist/components/Payroll/PayrollFlow/PayrollExecutionFlowContextual.js.map +1 -1
  27. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +143 -143
  28. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
  29. package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js +10 -10
  30. package/dist/components/Payroll/helpers.d.ts +1 -0
  31. package/dist/components/Payroll/helpers.js +71 -69
  32. package/dist/components/Payroll/helpers.js.map +1 -1
  33. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.d.ts +4 -4
  34. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.js +86 -89
  35. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.js.map +1 -1
  36. package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +38 -34
  37. package/dist/i18n/en/Payroll.PayrollConfiguration.json.js.map +1 -1
  38. package/dist/i18n/en/Payroll.PayrollOverview.json.js +62 -58
  39. package/dist/i18n/en/Payroll.PayrollOverview.json.js.map +1 -1
  40. package/dist/types/i18next.d.ts +4 -0
  41. package/package.json +4 -4
package/README.md CHANGED
@@ -48,6 +48,9 @@ Live documentation is available at: https://docs.gusto.com/embedded-payroll/docs
48
48
  - [Employee Onboarding](docs/workflows-overview/employee-onboarding/employee-onboarding.md)
49
49
  - [Employee Self-Onboarding](docs/workflows-overview/employee-onboarding/employee-self-onboarding.md)
50
50
  - [Run Payroll](docs/workflows-overview/run-payroll.md)
51
+ - [Off-Cycle Payroll (Bonus & Correction)](docs/workflows-overview/off-cycle-payroll.md)
52
+ - [Dismissal Payroll](docs/workflows-overview/dismissal-payroll.md)
53
+ - [Transition Payroll](docs/workflows-overview/transition-payroll.md)
51
54
  - [Hooks (Experimental)](docs/hooks/hooks.md)
52
55
  - [useEmployeeDetailsForm](docs/hooks/useEmployeeDetailsForm.md)
53
56
  - [useCompensationForm](docs/hooks/useCompensationForm.md)
@@ -3,16 +3,16 @@ import { useTranslation as c } from "react-i18next";
3
3
  import { useCreateSignatory as p } from "./useCreateSignatory.js";
4
4
  import { Flex as o } from "../../../Common/Flex/Flex.js";
5
5
  import { Grid as n } from "../../../Common/Grid/Grid.js";
6
- import { STATES_ABBR as u } from "../../../../shared/constants.js";
7
- import { usePlaceholderSSN as g, normalizeSSN as h } from "../../../../helpers/ssn.js";
8
- import { TitleSelect as f } from "../TitleSelect.js";
9
- import { useMaskedTransform as y, commonMasks as b } from "../../../../helpers/mask.js";
10
- import { useComponentContext as S } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
6
+ import { DatePickerField as u } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
7
+ import { STATES_ABBR as g } from "../../../../shared/constants.js";
8
+ import { usePlaceholderSSN as h, normalizeSSN as f } from "../../../../helpers/ssn.js";
9
+ import { TitleSelect as y } from "../TitleSelect.js";
10
+ import { useMaskedTransform as b, commonMasks as S } from "../../../../helpers/mask.js";
11
+ import { useComponentContext as D } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
11
12
  import { TextInputField as s } from "../../../Common/Fields/TextInputField/TextInputField.js";
12
- import { DatePickerField as D } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
13
13
  import { SelectField as M } from "../../../Common/Fields/SelectField/SelectField.js";
14
14
  const j = () => {
15
- const i = S(), { currentSignatory: t } = p(), { t: e } = c("Company.AssignSignatory"), d = g(t?.hasSsn), m = y(b.phoneMask);
15
+ const i = D(), { currentSignatory: t } = p(), { t: e } = c("Company.AssignSignatory"), d = h(t?.hasSsn), m = b(S.phoneMask);
16
16
  return /* @__PURE__ */ a(o, { flexDirection: "column", gap: 32, children: [
17
17
  /* @__PURE__ */ a(o, { flexDirection: "column", gap: 12, children: [
18
18
  /* @__PURE__ */ a("header", { children: [
@@ -48,7 +48,7 @@ const j = () => {
48
48
  isDisabled: !!t
49
49
  }
50
50
  ),
51
- /* @__PURE__ */ r(f, {}),
51
+ /* @__PURE__ */ r(y, {}),
52
52
  /* @__PURE__ */ r(
53
53
  s,
54
54
  {
@@ -66,12 +66,12 @@ const j = () => {
66
66
  label: e("signatoryDetails.ssn"),
67
67
  errorMessage: e("validations.ssn", { ns: "common" }),
68
68
  isRequired: !t?.hasSsn,
69
- transform: h,
69
+ transform: f,
70
70
  placeholder: d
71
71
  }
72
72
  ),
73
73
  /* @__PURE__ */ r(
74
- D,
74
+ u,
75
75
  {
76
76
  name: "birthday",
77
77
  label: e("signatoryDetails.birthday"),
@@ -110,7 +110,7 @@ const j = () => {
110
110
  M,
111
111
  {
112
112
  name: "state",
113
- options: u.map((l) => ({
113
+ options: g.map((l) => ({
114
114
  label: e(`statesHash.${l}`, { ns: "common" }),
115
115
  value: l
116
116
  })),
@@ -6,13 +6,13 @@ import { usePaySchedule as T } from "../usePaySchedule.js";
6
6
  import l from "./Edit.module.scss.js";
7
7
  import { Flex as y } from "../../../Common/Flex/Flex.js";
8
8
  import { Grid as x } from "../../../Common/Grid/Grid.js";
9
+ import { DatePickerField as h } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
9
10
  import { useComponentContext as E } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
10
11
  import { useDateFormatter as N } from "../../../../hooks/useDateFormatter.js";
11
12
  import { TextInputField as F } from "../../../Common/Fields/TextInputField/TextInputField.js";
12
13
  import { SelectField as R } from "../../../Common/Fields/SelectField/SelectField.js";
13
14
  import { RadioGroupField as O } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
14
- import { NumberInputField as h } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
15
- import { DatePickerField as f } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
15
+ import { NumberInputField as f } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
16
16
  const J = () => {
17
17
  const n = E(), { t: e } = C("Company.PaySchedule"), P = N(), { payPeriodPreview: r, mode: u, payPreviewLoading: D } = T(), { setValue: d } = q(), [a, v] = g(0), i = p({ name: "frequency" }), o = p({ name: "customTwicePerMonth" }), b = i === "Twice per month" && o === "custom" || i === "Monthly", w = i === "Twice per month" && o === "custom";
18
18
  return S(() => {
@@ -47,7 +47,7 @@ const J = () => {
47
47
  }
48
48
  ),
49
49
  /* @__PURE__ */ t(
50
- f,
50
+ h,
51
51
  {
52
52
  name: "anchorPayDate",
53
53
  label: e("labels.firstPayDate"),
@@ -56,7 +56,7 @@ const J = () => {
56
56
  }
57
57
  ),
58
58
  /* @__PURE__ */ t(
59
- f,
59
+ h,
60
60
  {
61
61
  name: "anchorEndOfPayPeriod",
62
62
  label: e("labels.firstPayPeriodEndDate"),
@@ -64,8 +64,8 @@ const J = () => {
64
64
  isRequired: !0
65
65
  }
66
66
  ),
67
- /* @__PURE__ */ t("div", { className: b ? "" : l.visuallyHidden, children: /* @__PURE__ */ t(h, { name: "day1", label: e("labels.firstPayDayOfTheMonth"), isRequired: !0 }) }),
68
- /* @__PURE__ */ t("div", { className: w ? "" : l.visuallyHidden, children: /* @__PURE__ */ t(h, { name: "day2", label: e("labels.lastPayDayOfTheMonth"), isRequired: !0 }) })
67
+ /* @__PURE__ */ t("div", { className: b ? "" : l.visuallyHidden, children: /* @__PURE__ */ t(f, { name: "day1", label: e("labels.firstPayDayOfTheMonth"), isRequired: !0 }) }),
68
+ /* @__PURE__ */ t("div", { className: w ? "" : l.visuallyHidden, children: /* @__PURE__ */ t(f, { name: "day2", label: e("labels.lastPayDayOfTheMonth"), isRequired: !0 }) })
69
69
  ] }) }),
70
70
  /* @__PURE__ */ t(y, { flexDirection: "column", gap: 4, justifyContent: "center", alignItems: "center", children: r && r[a] ? /* @__PURE__ */ m("div", { className: l.calendarContainer, children: [
71
71
  !D && /* @__PURE__ */ t(
@@ -6,15 +6,15 @@ import { useComponentContext as D } from "../../../contexts/ComponentAdapter/use
6
6
  import { useI18n as I } from "../../../i18n/I18n.js";
7
7
  import { Form as O } from "../../Common/Form/Form.js";
8
8
  import { Grid as n } from "../../Common/Grid/Grid.js";
9
- import { usePlaceholderSSN as x, normalizeSSN as w } from "../../../helpers/ssn.js";
10
- import { usePlaceholderEin as E, normalizeEin as j } from "../../../helpers/federalEin.js";
11
- import { ContractorOnboardingStatus as v } from "../../../shared/constants.js";
9
+ import { DatePickerField as x } from "../../Common/Fields/DatePickerField/DatePickerField.js";
10
+ import { usePlaceholderSSN as w, normalizeSSN as E } from "../../../helpers/ssn.js";
11
+ import { usePlaceholderEin as j, normalizeEin as v } from "../../../helpers/federalEin.js";
12
+ import { ContractorOnboardingStatus as G } from "../../../shared/constants.js";
12
13
  import { TextInputField as l } from "../../Common/Fields/TextInputField/TextInputField.js";
13
14
  import { RadioGroupField as d } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
14
- import { NumberInputField as G } from "../../Common/Fields/NumberInputField/NumberInputField.js";
15
- import { Flex as z } from "../../Common/Flex/Flex.js";
16
- import { SwitchField as A } from "../../Common/Fields/SwitchField/SwitchField.js";
17
- import { DatePickerField as B } from "../../Common/Fields/DatePickerField/DatePickerField.js";
15
+ import { NumberInputField as z } from "../../Common/Fields/NumberInputField/NumberInputField.js";
16
+ import { Flex as A } from "../../Common/Flex/Flex.js";
17
+ import { SwitchField as B } from "../../Common/Fields/SwitchField/SwitchField.js";
18
18
  function re({
19
19
  formMethods: u,
20
20
  handleSubmit: f,
@@ -33,7 +33,7 @@ function re({
33
33
  }) {
34
34
  const a = D();
35
35
  I("Contractor.Profile");
36
- const { t: e } = T("Contractor.Profile"), q = x(t?.hasSsn ?? !1), P = E(t?.hasEin ?? !1);
36
+ const { t: e } = T("Contractor.Profile"), q = w(t?.hasSsn ?? !1), P = j(t?.hasEin ?? !1);
37
37
  return /* @__PURE__ */ i("section", { className: F, children: /* @__PURE__ */ i(S, { ...u, children: /* @__PURE__ */ r(O, { onSubmit: f, children: [
38
38
  /* @__PURE__ */ r(n, { gridTemplateColumns: "1fr", gap: 24, className: "mb-8", children: [
39
39
  /* @__PURE__ */ r("header", { children: [
@@ -42,12 +42,12 @@ function re({
42
42
  ] }),
43
43
  /* @__PURE__ */ i("div", { className: C.switchFieldContainer, children: /* @__PURE__ */ r(n, { gap: 16, children: [
44
44
  /* @__PURE__ */ i(
45
- A,
45
+ B,
46
46
  {
47
47
  name: "selfOnboarding",
48
48
  label: e("fields.selfOnboarding.label"),
49
49
  description: e("fields.selfOnboarding.description"),
50
- isDisabled: t && t.onboardingStatus !== v.ADMIN_ONBOARDING_INCOMPLETE
50
+ isDisabled: t && t.onboardingStatus !== G.ADMIN_ONBOARDING_INCOMPLETE
51
51
  }
52
52
  ),
53
53
  p && /* @__PURE__ */ i(
@@ -81,7 +81,7 @@ function re({
81
81
  name: "ssn",
82
82
  label: e("fields.ssn.label"),
83
83
  placeholder: q,
84
- transform: w,
84
+ transform: E,
85
85
  isRequired: !0
86
86
  }
87
87
  )
@@ -101,7 +101,7 @@ function re({
101
101
  name: "ein",
102
102
  label: e("fields.ein.label"),
103
103
  placeholder: P,
104
- transform: j,
104
+ transform: v,
105
105
  isRequired: !0
106
106
  }
107
107
  )
@@ -116,7 +116,7 @@ function re({
116
116
  }
117
117
  ),
118
118
  h && /* @__PURE__ */ i(
119
- G,
119
+ z,
120
120
  {
121
121
  name: "hourlyRate",
122
122
  label: e("fields.hourlyRate.label"),
@@ -126,7 +126,7 @@ function re({
126
126
  }
127
127
  ),
128
128
  /* @__PURE__ */ i(
129
- B,
129
+ x,
130
130
  {
131
131
  name: "startDate",
132
132
  label: e("fields.startDate.label"),
@@ -135,7 +135,7 @@ function re({
135
135
  }
136
136
  )
137
137
  ] }),
138
- /* @__PURE__ */ i(z, { gap: 12, justifyContent: "flex-end", children: /* @__PURE__ */ i(a.Button, { type: "submit", variant: "primary", isDisabled: o.isSubmitting, children: o.isSubmitting ? e(s ? "buttons.updating" : "buttons.creating") : e(s ? "buttons.update" : "buttons.create") }) })
138
+ /* @__PURE__ */ i(A, { gap: 12, justifyContent: "flex-end", children: /* @__PURE__ */ i(a.Button, { type: "submit", variant: "primary", isDisabled: o.isSubmitting, children: o.isSubmitting ? e(s ? "buttons.updating" : "buttons.creating") : e(s ? "buttons.update" : "buttons.create") }) })
139
139
  ] }) }) });
140
140
  }
141
141
  export {
@@ -8,14 +8,14 @@ import { generateEmploymentEligibilitySchema as k } from "./EmploymentEligibilit
8
8
  import { COUNTRIES as P } from "./countries.js";
9
9
  import { Flex as b } from "../../../Common/Flex/Flex.js";
10
10
  import { ActionsLayout as V } from "../../../Common/ActionsLayout/ActionsLayout.js";
11
- import { ComboBoxField as B } from "../../../Common/Fields/ComboBoxField/ComboBoxField.js";
12
- import { Form as H } from "../../../Common/Form/Form.js";
13
- import { useComponentContext as K } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
14
- import { useI18n as M } from "../../../../i18n/I18n.js";
15
- import { SelectField as G } from "../../../Common/Fields/SelectField/SelectField.js";
16
- import { RadioGroupField as U } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
17
- import { TextInputField as W } from "../../../Common/Fields/TextInputField/TextInputField.js";
18
- import { DatePickerField as J } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
11
+ import { DatePickerField as B } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
12
+ import { ComboBoxField as H } from "../../../Common/Fields/ComboBoxField/ComboBoxField.js";
13
+ import { Form as K } from "../../../Common/Form/Form.js";
14
+ import { useComponentContext as M } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
15
+ import { useI18n as G } from "../../../../i18n/I18n.js";
16
+ import { SelectField as U } from "../../../Common/Fields/SelectField/SelectField.js";
17
+ import { RadioGroupField as W } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
18
+ import { TextInputField as J } from "../../../Common/Fields/TextInputField/TextInputField.js";
19
19
  const Q = {
20
20
  citizen: "statusDescriptions.citizen",
21
21
  permanent_resident: "statusDescriptions.permanent_resident",
@@ -27,8 +27,8 @@ const Q = {
27
27
  hasDocumentNumber: y,
28
28
  isPending: g
29
29
  }) => {
30
- M("Employee.EmploymentEligibility");
31
- const { Heading: D, Text: x, Alert: z, Button: E, Link: N } = K(), { t: e } = L("Employee.EmploymentEligibility"), [a, m] = I(!!y), r = O({
30
+ G("Employee.EmploymentEligibility");
31
+ const { Heading: D, Text: x, Alert: z, Button: E, Link: N } = M(), { t: e } = L("Employee.EmploymentEligibility"), [a, m] = I(!!y), r = O({
32
32
  resolver: j(k(a)),
33
33
  defaultValues: f
34
34
  }), { control: l, setValue: u, clearErrors: c } = r, o = d({ control: l, name: "authorizationStatus" }), s = d({ control: l, name: "documentType" }), _ = Object.values(q).map((n) => ({
@@ -45,7 +45,7 @@ const Q = {
45
45
  uscis_alien_registration_number: 9,
46
46
  form_i94: 11
47
47
  };
48
- return /* @__PURE__ */ t($, { ...r, children: /* @__PURE__ */ t(H, { onSubmit: r.handleSubmit(h), children: /* @__PURE__ */ p(b, { flexDirection: "column", gap: 16, children: [
48
+ return /* @__PURE__ */ t($, { ...r, children: /* @__PURE__ */ t(K, { onSubmit: r.handleSubmit(h), children: /* @__PURE__ */ p(b, { flexDirection: "column", gap: 16, children: [
49
49
  /* @__PURE__ */ p(b, { flexDirection: "column", gap: 2, children: [
50
50
  /* @__PURE__ */ t(D, { as: "h2", children: e("title") }),
51
51
  /* @__PURE__ */ t(x, { variant: "supporting", children: /* @__PURE__ */ t(
@@ -60,7 +60,7 @@ const Q = {
60
60
  ) })
61
61
  ] }),
62
62
  /* @__PURE__ */ t(
63
- G,
63
+ U,
64
64
  {
65
65
  name: "authorizationStatus",
66
66
  label: e("select.label"),
@@ -79,9 +79,9 @@ const Q = {
79
79
  disableScrollIntoView: !0
80
80
  }
81
81
  ),
82
- o === "alien" && /* @__PURE__ */ t(J, { name: "expirationDate", label: e("expirationDate.label") }),
82
+ o === "alien" && /* @__PURE__ */ t(B, { name: "expirationDate", label: e("expirationDate.label") }),
83
83
  F && /* @__PURE__ */ t(
84
- U,
84
+ W,
85
85
  {
86
86
  name: "documentType",
87
87
  label: e("authorizationDocument.label"),
@@ -91,7 +91,7 @@ const Q = {
91
91
  }
92
92
  ),
93
93
  R && i && /* @__PURE__ */ t(
94
- W,
94
+ J,
95
95
  {
96
96
  name: "documentNumber",
97
97
  label: e(`documentNumber.${i}.label`),
@@ -102,7 +102,7 @@ const Q = {
102
102
  }
103
103
  ),
104
104
  s === "foreign_passport" && o === "alien" && /* @__PURE__ */ t(
105
- B,
105
+ H,
106
106
  {
107
107
  name: "country",
108
108
  label: e("country.label"),
@@ -3,12 +3,12 @@ import { z as t } from "zod";
3
3
  import { useFormContext as c } from "react-hook-form";
4
4
  import { useTranslation as o } from "react-i18next";
5
5
  import { Grid as b } from "../../Common/Grid/Grid.js";
6
+ import { DatePickerField as p } from "../../Common/Fields/DatePickerField/DatePickerField.js";
6
7
  import { removeNonDigits as S, addressInline as h } from "../../../helpers/formattedStrings.js";
7
8
  import { usePlaceholderSSN as g, normalizeSSN as N } from "../../../helpers/ssn.js";
8
9
  import { SSN_REGEX as D, nameValidation as m } from "../../../helpers/validations.js";
9
10
  import { TextInputField as i } from "../../Common/Fields/TextInputField/TextInputField.js";
10
11
  import { SelectField as I } from "../../Common/Fields/SelectField/SelectField.js";
11
- import { DatePickerField as p } from "../../Common/Fields/DatePickerField/DatePickerField.js";
12
12
  const v = t.object({
13
13
  firstName: m,
14
14
  middleInitial: t.string().optional(),
@@ -5,11 +5,11 @@ import { useForm as D, FormProvider as g } from "react-hook-form";
5
5
  import { zodResolver as E } from "@hookform/resolvers/zod";
6
6
  import { Flex as a } from "../../../Common/Flex/Flex.js";
7
7
  import { ActionsLayout as R } from "../../../Common/ActionsLayout/ActionsLayout.js";
8
- import { Form as x } from "../../../Common/Form/Form.js";
9
- import { useComponentContext as F } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
10
- import { useI18n as W } from "../../../../i18n/I18n.js";
11
- import { RadioGroupField as q } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
12
- import { DatePickerField as T } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
8
+ import { DatePickerField as x } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
9
+ import { Form as F } from "../../../Common/Form/Form.js";
10
+ import { useComponentContext as W } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
11
+ import { useI18n as q } from "../../../../i18n/I18n.js";
12
+ import { RadioGroupField as T } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
13
13
  const k = t.object({
14
14
  lastDayOfWork: t.date({ error: "validation.lastDayRequired" }),
15
15
  payrollOption: t.enum(["dismissalPayroll", "regularPayroll", "anotherWay"], {
@@ -23,8 +23,8 @@ function I({
23
23
  onCancel: y,
24
24
  isLoading: s
25
25
  }) {
26
- const { Alert: u, Heading: f, Text: p, Button: m } = F();
27
- W("Employee.Terminations.TerminateEmployee");
26
+ const { Alert: u, Heading: f, Text: p, Button: m } = W();
27
+ q("Employee.Terminations.TerminateEmployee");
28
28
  const { t: o } = v("Employee.Terminations.TerminateEmployee"), O = (P) => P.runTerminationPayroll === !0 ? "dismissalPayroll" : "regularPayroll", h = {
29
29
  lastDayOfWork: l?.effectiveDate ? new Date(l.effectiveDate) : void 0,
30
30
  payrollOption: l ? O(l) : "dismissalPayroll"
@@ -48,14 +48,14 @@ function I({
48
48
  description: o("form.payrollOption.options.anotherWay.description")
49
49
  }
50
50
  ];
51
- return /* @__PURE__ */ r(g, { ...i, children: /* @__PURE__ */ r(x, { onSubmit: i.handleSubmit(d), children: /* @__PURE__ */ e(a, { flexDirection: "column", gap: 24, children: [
51
+ return /* @__PURE__ */ r(g, { ...i, children: /* @__PURE__ */ r(F, { onSubmit: i.handleSubmit(d), children: /* @__PURE__ */ e(a, { flexDirection: "column", gap: 24, children: [
52
52
  /* @__PURE__ */ e(a, { flexDirection: "column", gap: 4, children: [
53
53
  /* @__PURE__ */ r(f, { as: "h2", children: o("title", { employeeName: n }) }),
54
54
  /* @__PURE__ */ r(p, { variant: "supporting", children: o("subtitle") })
55
55
  ] }),
56
56
  /* @__PURE__ */ e(a, { flexDirection: "column", gap: 24, children: [
57
57
  /* @__PURE__ */ r(
58
- T,
58
+ x,
59
59
  {
60
60
  name: "lastDayOfWork",
61
61
  label: o("form.lastDayOfEmployment.label"),
@@ -65,7 +65,7 @@ function I({
65
65
  }
66
66
  ),
67
67
  /* @__PURE__ */ r(
68
- q,
68
+ T,
69
69
  {
70
70
  name: "payrollOption",
71
71
  label: o("form.payrollOption.label"),
@@ -15,11 +15,11 @@ import { useComponentContext as S } from "../../../../contexts/ComponentAdapter/
15
15
  import { useComponentDictionary as z, useI18n as g } from "../../../../i18n/I18n.js";
16
16
  import { Flex as p, FlexItem as f } from "../../../Common/Flex/Flex.js";
17
17
  import { payrollWireEvents as N } from "../../../../shared/constants.js";
18
- import { TextAreaField as V } from "../../../Common/Fields/TextAreaField/TextAreaField.js";
19
- import { useDateFormatter as J } from "../../../../hooks/useDateFormatter.js";
20
- import { NumberInputField as Q } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
21
- import { TextInputField as X } from "../../../Common/Fields/TextInputField/TextInputField.js";
22
- import { DatePickerField as Z } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
18
+ import { DatePickerField as V } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
19
+ import { TextAreaField as J } from "../../../Common/Fields/TextAreaField/TextAreaField.js";
20
+ import { useDateFormatter as Q } from "../../../../hooks/useDateFormatter.js";
21
+ import { NumberInputField as X } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
22
+ import { TextInputField as Z } from "../../../Common/Fields/TextInputField/TextInputField.js";
23
23
  const $ = r.object({
24
24
  amountSent: r.number().positive(),
25
25
  dateSent: r.date(),
@@ -41,7 +41,7 @@ const oe = ({
41
41
  modalContainerRef: y
42
42
  }) => {
43
43
  z("Payroll.ConfirmWireDetailsForm", i), g("Payroll.ConfirmWireDetailsForm");
44
- const { onEvent: a, baseSubmitHandler: I } = Y(), { t } = F("Payroll.ConfirmWireDetailsForm"), { Heading: v, Text: b } = S(), R = J(), { data: P } = U({
44
+ const { onEvent: a, baseSubmitHandler: I } = Y(), { t } = F("Payroll.ConfirmWireDetailsForm"), { Heading: v, Text: b } = S(), R = Q(), { data: P } = U({
45
45
  wireInRequestUuid: o
46
46
  }), W = P.wireInRequest, { data: q } = G({
47
47
  companyId: n,
@@ -83,7 +83,7 @@ const oe = ({
83
83
  className: d.form,
84
84
  children: /* @__PURE__ */ m(p, { flexDirection: "column", gap: 20, children: [
85
85
  /* @__PURE__ */ e(
86
- Q,
86
+ X,
87
87
  {
88
88
  name: "amountSent",
89
89
  label: t("amountLabel"),
@@ -93,7 +93,7 @@ const oe = ({
93
93
  }
94
94
  ),
95
95
  /* @__PURE__ */ e(
96
- Z,
96
+ V,
97
97
  {
98
98
  name: "dateSent",
99
99
  label: t("dateLabel"),
@@ -103,7 +103,7 @@ const oe = ({
103
103
  }
104
104
  ),
105
105
  /* @__PURE__ */ e(
106
- X,
106
+ Z,
107
107
  {
108
108
  name: "bankName",
109
109
  label: t("bankNameLabel"),
@@ -113,7 +113,7 @@ const oe = ({
113
113
  errorMessage: t("validations.bankName")
114
114
  }
115
115
  ),
116
- /* @__PURE__ */ e(V, { name: "additionalNotes", label: t("notesLabel"), rows: 3 })
116
+ /* @__PURE__ */ e(J, { name: "additionalNotes", label: t("notesLabel"), rows: 3 })
117
117
  ] })
118
118
  }
119
119
  ) })
@@ -1,73 +1,71 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { useEffect as L, useMemo as p, useState as O } from "react";
3
- import { usePaySchedulesGetUnprocessedTerminationPeriodsSuspense as T } from "@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods";
4
- import { usePayrollsCreateOffCycleMutation as b } from "@gusto/embedded-api/react-query/payrollsCreateOffCycle";
5
- import { OffCycleReason as g } from "@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls";
6
- import { RFCDate as a } from "@gusto/embedded-api/types/rfcdate";
7
- import { useTranslation as M } from "react-i18next";
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { useEffect as A, useMemo as y, useState as O } from "react";
3
+ import { usePaySchedulesGetUnprocessedTerminationPeriodsSuspense as b } from "@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods";
4
+ import { usePayrollsCreateOffCycleMutation as g } from "@gusto/embedded-api/react-query/payrollsCreateOffCycle";
5
+ import { OffCycleReason as L } from "@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls";
6
+ import { RFCDate as D } from "@gusto/embedded-api/types/rfcdate";
7
+ import { useTranslation as T } from "react-i18next";
8
8
  import { DismissalPayPeriodSelectionPresentation as K } from "./DismissalPayPeriodSelectionPresentation.js";
9
- import { BaseComponent as $ } from "../../../Base/Base.js";
10
- import { useBase as k } from "../../../Base/useBase.js";
11
- import { componentEvents as S } from "../../../../shared/constants.js";
12
- import { SDKInternalError as d } from "../../../../types/sdkError.js";
13
- import { useComponentDictionary as N, useI18n as Y } from "../../../../i18n/I18n.js";
14
- import { formatPayPeriodRange as q, addBusinessDays as x } from "../../../../helpers/dateFormatting.js";
15
- import { ACH_LEAD_TIME_BUSINESS_DAYS as H } from "../../OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation.js";
16
- function se(t) {
17
- return /* @__PURE__ */ f($, { ...t, children: /* @__PURE__ */ f(I, { ...t }) });
9
+ import { BaseComponent as M } from "../../../Base/Base.js";
10
+ import { useBase as $ } from "../../../Base/useBase.js";
11
+ import { componentEvents as p } from "../../../../shared/constants.js";
12
+ import { SDKInternalError as u } from "../../../../types/sdkError.js";
13
+ import { useComponentDictionary as q, useI18n as x } from "../../../../i18n/I18n.js";
14
+ import { formatPayPeriodRange as N } from "../../../../helpers/dateFormatting.js";
15
+ function oe(t) {
16
+ return /* @__PURE__ */ d(M, { ...t, children: /* @__PURE__ */ d(Y, { ...t }) });
18
17
  }
19
- const E = (t) => `${t.startDate}__${t.endDate}`;
20
- function I({ companyId: t, employeeId: n, payrollId: r, dictionary: w }) {
21
- N("Payroll.Dismissal", w), Y("Payroll.Dismissal");
22
- const { t: i } = M("Payroll.Dismissal"), { onEvent: l, baseSubmitHandler: C } = k(), { data: P } = T({ companyId: t }), { mutateAsync: _, isPending: h } = b(), U = !!r && !!n;
23
- L(() => {
24
- r && n && l(S.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: r });
25
- }, [r, n, l]);
26
- const m = p(() => (P.unprocessedTerminationPayPeriodList ?? []).filter((o) => !n || o.employeeUuid === n).filter(
18
+ const S = (t) => `${t.startDate}__${t.endDate}`;
19
+ function Y({ companyId: t, employeeId: r, payrollId: n, dictionary: E }) {
20
+ q("Payroll.Dismissal", E), x("Payroll.Dismissal");
21
+ const { t: i } = T("Payroll.Dismissal"), { onEvent: l, baseSubmitHandler: C } = $(), { data: f } = b({ companyId: t }), { mutateAsync: w, isPending: U } = g(), v = !!n && !!r;
22
+ A(() => {
23
+ n && r && l(p.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: n });
24
+ }, [n, r, l]);
25
+ const m = y(() => (f.unprocessedTerminationPayPeriodList ?? []).filter((o) => !r || o.employeeUuid === r).filter(
27
26
  (o) => !!o.startDate && !!o.endDate && !!o.employeeUuid
28
- ), [P, n]), c = p(() => m.map((e) => {
29
- const o = q(e.startDate, e.endDate), u = e.employeeName ? `${o} (${e.employeeName})` : o;
27
+ ), [f, r]), c = y(() => m.map((e) => {
28
+ const o = N(e.startDate, e.endDate), a = e.employeeName ? `${o} (${e.employeeName})` : o;
30
29
  return {
31
- value: E(e),
32
- label: u
30
+ value: S(e),
31
+ label: a
33
32
  };
34
- }), [m]), A = c.length === 1 ? c[0].value : void 0, [s, B] = O(A), v = async () => {
33
+ }), [m]), h = c.length === 1 ? c[0].value : void 0, [s, B] = O(h), R = async () => {
35
34
  await C({ selectedPeriodKey: s }, async () => {
36
35
  if (s === void 0)
37
- throw new d(i("errors.noPayPeriodSelected"));
38
- const e = m.find((R) => E(R) === s);
36
+ throw new u(i("errors.noPayPeriodSelected"));
37
+ const e = m.find((_) => S(_) === s);
39
38
  if (!e)
40
- throw new d(i("errors.invalidPayPeriod"));
41
- const o = n ?? e.employeeUuid, u = e.checkDate ? new a(e.checkDate) : new a(x(/* @__PURE__ */ new Date(), H)), y = await _({
39
+ throw new u(i("errors.invalidPayPeriod"));
40
+ const o = r ?? e.employeeUuid, a = await w({
42
41
  request: {
43
42
  companyId: t,
44
43
  requestBody: {
45
44
  offCycle: !0,
46
- offCycleReason: g.DismissedEmployee,
47
- startDate: new a(e.startDate),
48
- endDate: new a(e.endDate),
49
- employeeUuids: [o],
50
- checkDate: u
45
+ offCycleReason: L.DismissedEmployee,
46
+ startDate: new D(e.startDate),
47
+ endDate: new D(e.endDate),
48
+ employeeUuids: [o]
51
49
  }
52
50
  }
53
- }), D = y.payrollUnprocessed?.payrollUuid ?? y.payrollUnprocessed?.uuid;
54
- if (!D)
55
- throw new d(i("errors.missingPayrollId"));
56
- l(S.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: D });
51
+ }), P = a.payrollUnprocessed?.payrollUuid ?? a.payrollUnprocessed?.uuid;
52
+ if (!P)
53
+ throw new u(i("errors.missingPayrollId"));
54
+ l(p.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: P });
57
55
  });
58
56
  };
59
- return U ? null : /* @__PURE__ */ f(
57
+ return v ? null : /* @__PURE__ */ d(
60
58
  K,
61
59
  {
62
60
  payPeriodOptions: c,
63
61
  selectedPeriodKey: s,
64
62
  onSelectPeriod: B,
65
- onSubmit: v,
66
- isPending: h
63
+ onSubmit: R,
64
+ isPending: U
67
65
  }
68
66
  );
69
67
  }
70
68
  export {
71
- se as DismissalPayPeriodSelection
69
+ oe as DismissalPayPeriodSelection
72
70
  };
73
71
  //# sourceMappingURL=DismissalPayPeriodSelection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DismissalPayPeriodSelection.js","sources":["../../../../../src/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\nimport { usePaySchedulesGetUnprocessedTerminationPeriodsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods'\nimport { usePayrollsCreateOffCycleMutation } from '@gusto/embedded-api/react-query/payrollsCreateOffCycle'\nimport type { UnprocessedTerminationPayPeriod } from '@gusto/embedded-api/models/components/unprocessedterminationpayperiod'\nimport { OffCycleReason } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useTranslation } from 'react-i18next'\nimport { DismissalPayPeriodSelectionPresentation } from './DismissalPayPeriodSelectionPresentation'\nimport { BaseComponent } from '@/components/Base/Base'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { componentEvents } from '@/shared/constants'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { addBusinessDays, formatPayPeriodRange } from '@/helpers/dateFormatting'\nimport { ACH_LEAD_TIME_BUSINESS_DAYS } from '@/components/Payroll/OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation'\nimport type { SelectOption } from '@/components/Common/UI/Select/SelectTypes'\n\nexport interface DismissalPayPeriodSelectionProps extends BaseComponentInterface<'Payroll.Dismissal'> {\n companyId: string\n employeeId?: string\n payrollId?: string\n}\n\nexport function DismissalPayPeriodSelection(props: DismissalPayPeriodSelectionProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\ntype RequiredPayPeriod = UnprocessedTerminationPayPeriod &\n Required<Pick<UnprocessedTerminationPayPeriod, 'startDate' | 'endDate' | 'employeeUuid'>>\n\nconst payPeriodKey = (period: RequiredPayPeriod) => `${period.startDate}__${period.endDate}`\n\nfunction Root({ companyId, employeeId, payrollId, dictionary }: DismissalPayPeriodSelectionProps) {\n useComponentDictionary('Payroll.Dismissal', dictionary)\n useI18n('Payroll.Dismissal')\n const { t } = useTranslation('Payroll.Dismissal')\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data } = usePaySchedulesGetUnprocessedTerminationPeriodsSuspense({ companyId })\n const { mutateAsync: createOffCyclePayroll, isPending } = usePayrollsCreateOffCycleMutation()\n\n const shouldAutoAdvance = Boolean(payrollId) && Boolean(employeeId)\n\n useEffect(() => {\n if (payrollId && employeeId) {\n onEvent(componentEvents.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: payrollId })\n }\n }, [payrollId, employeeId, onEvent])\n\n const employeePayPeriods: RequiredPayPeriod[] = useMemo(() => {\n const allPeriods = data.unprocessedTerminationPayPeriodList ?? []\n return allPeriods\n .filter(period => !employeeId || period.employeeUuid === employeeId)\n .filter(\n (period): period is RequiredPayPeriod =>\n Boolean(period.startDate) && Boolean(period.endDate) && Boolean(period.employeeUuid),\n )\n }, [data, employeeId])\n\n const payPeriodOptions: SelectOption[] = useMemo(() => {\n return employeePayPeriods.map(period => {\n const dateRange = formatPayPeriodRange(period.startDate, period.endDate)\n const label = period.employeeName ? `${dateRange} (${period.employeeName})` : dateRange\n return {\n value: payPeriodKey(period),\n label,\n }\n })\n }, [employeePayPeriods])\n\n const initialSelection = payPeriodOptions.length === 1 ? payPeriodOptions[0]!.value : undefined\n const [selectedPeriodKey, setSelectedPeriodKey] = useState(initialSelection)\n\n const handleSubmit = async () => {\n await baseSubmitHandler({ selectedPeriodKey }, async () => {\n if (selectedPeriodKey === undefined) {\n throw new SDKInternalError(t('errors.noPayPeriodSelected'))\n }\n\n const period = employeePayPeriods.find(p => payPeriodKey(p) === selectedPeriodKey)\n if (!period) {\n throw new SDKInternalError(t('errors.invalidPayPeriod'))\n }\n\n const resolvedEmployeeId = employeeId ?? period.employeeUuid\n\n const checkDate = period.checkDate\n ? new RFCDate(period.checkDate)\n : new RFCDate(addBusinessDays(new Date(), ACH_LEAD_TIME_BUSINESS_DAYS))\n\n const response = await createOffCyclePayroll({\n request: {\n companyId,\n requestBody: {\n offCycle: true,\n offCycleReason: OffCycleReason.DismissedEmployee,\n startDate: new RFCDate(period.startDate),\n endDate: new RFCDate(period.endDate),\n employeeUuids: [resolvedEmployeeId],\n checkDate,\n },\n },\n })\n\n const payrollUuid =\n response.payrollUnprocessed?.payrollUuid ?? response.payrollUnprocessed?.uuid\n\n if (!payrollUuid) {\n throw new SDKInternalError(t('errors.missingPayrollId'))\n }\n\n onEvent(componentEvents.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid })\n })\n }\n\n if (shouldAutoAdvance) {\n return null\n }\n\n return (\n <DismissalPayPeriodSelectionPresentation\n payPeriodOptions={payPeriodOptions}\n selectedPeriodKey={selectedPeriodKey}\n onSelectPeriod={setSelectedPeriodKey}\n onSubmit={handleSubmit}\n isPending={isPending}\n />\n )\n}\n"],"names":["DismissalPayPeriodSelection","props","jsx","BaseComponent","Root","payPeriodKey","period","companyId","employeeId","payrollId","dictionary","useComponentDictionary","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","data","usePaySchedulesGetUnprocessedTerminationPeriodsSuspense","createOffCyclePayroll","isPending","usePayrollsCreateOffCycleMutation","shouldAutoAdvance","useEffect","componentEvents","employeePayPeriods","useMemo","payPeriodOptions","dateRange","formatPayPeriodRange","label","initialSelection","selectedPeriodKey","setSelectedPeriodKey","useState","handleSubmit","SDKInternalError","p","resolvedEmployeeId","checkDate","RFCDate","addBusinessDays","ACH_LEAD_TIME_BUSINESS_DAYS","response","OffCycleReason","payrollUuid","DismissalPayPeriodSelectionPresentation"],"mappings":";;;;;;;;;;;;;;;AAwBO,SAASA,GAA4BC,GAAyC;AACnF,SACE,gBAAAC,EAACC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V,WAAAf;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"DismissalPayPeriodSelection.js","sources":["../../../../../src/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\nimport { usePaySchedulesGetUnprocessedTerminationPeriodsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods'\nimport { usePayrollsCreateOffCycleMutation } from '@gusto/embedded-api/react-query/payrollsCreateOffCycle'\nimport type { UnprocessedTerminationPayPeriod } from '@gusto/embedded-api/models/components/unprocessedterminationpayperiod'\nimport { OffCycleReason } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useTranslation } from 'react-i18next'\nimport { DismissalPayPeriodSelectionPresentation } from './DismissalPayPeriodSelectionPresentation'\nimport { BaseComponent } from '@/components/Base/Base'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { componentEvents } from '@/shared/constants'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { formatPayPeriodRange } from '@/helpers/dateFormatting'\nimport type { SelectOption } from '@/components/Common/UI/Select/SelectTypes'\n\nexport interface DismissalPayPeriodSelectionProps extends BaseComponentInterface<'Payroll.Dismissal'> {\n companyId: string\n employeeId?: string\n payrollId?: string\n}\n\nexport function DismissalPayPeriodSelection(props: DismissalPayPeriodSelectionProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\ntype RequiredPayPeriod = UnprocessedTerminationPayPeriod &\n Required<Pick<UnprocessedTerminationPayPeriod, 'startDate' | 'endDate' | 'employeeUuid'>>\n\nconst payPeriodKey = (period: RequiredPayPeriod) => `${period.startDate}__${period.endDate}`\n\nfunction Root({ companyId, employeeId, payrollId, dictionary }: DismissalPayPeriodSelectionProps) {\n useComponentDictionary('Payroll.Dismissal', dictionary)\n useI18n('Payroll.Dismissal')\n const { t } = useTranslation('Payroll.Dismissal')\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data } = usePaySchedulesGetUnprocessedTerminationPeriodsSuspense({ companyId })\n const { mutateAsync: createOffCyclePayroll, isPending } = usePayrollsCreateOffCycleMutation()\n\n const shouldAutoAdvance = Boolean(payrollId) && Boolean(employeeId)\n\n useEffect(() => {\n if (payrollId && employeeId) {\n onEvent(componentEvents.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: payrollId })\n }\n }, [payrollId, employeeId, onEvent])\n\n const employeePayPeriods: RequiredPayPeriod[] = useMemo(() => {\n const allPeriods = data.unprocessedTerminationPayPeriodList ?? []\n return allPeriods\n .filter(period => !employeeId || period.employeeUuid === employeeId)\n .filter(\n (period): period is RequiredPayPeriod =>\n Boolean(period.startDate) && Boolean(period.endDate) && Boolean(period.employeeUuid),\n )\n }, [data, employeeId])\n\n const payPeriodOptions: SelectOption[] = useMemo(() => {\n return employeePayPeriods.map(period => {\n const dateRange = formatPayPeriodRange(period.startDate, period.endDate)\n const label = period.employeeName ? `${dateRange} (${period.employeeName})` : dateRange\n return {\n value: payPeriodKey(period),\n label,\n }\n })\n }, [employeePayPeriods])\n\n const initialSelection = payPeriodOptions.length === 1 ? payPeriodOptions[0]!.value : undefined\n const [selectedPeriodKey, setSelectedPeriodKey] = useState(initialSelection)\n\n const handleSubmit = async () => {\n await baseSubmitHandler({ selectedPeriodKey }, async () => {\n if (selectedPeriodKey === undefined) {\n throw new SDKInternalError(t('errors.noPayPeriodSelected'))\n }\n\n const period = employeePayPeriods.find(p => payPeriodKey(p) === selectedPeriodKey)\n if (!period) {\n throw new SDKInternalError(t('errors.invalidPayPeriod'))\n }\n\n const resolvedEmployeeId = employeeId ?? period.employeeUuid\n\n const response = await createOffCyclePayroll({\n request: {\n companyId,\n requestBody: {\n offCycle: true,\n offCycleReason: OffCycleReason.DismissedEmployee,\n startDate: new RFCDate(period.startDate),\n endDate: new RFCDate(period.endDate),\n employeeUuids: [resolvedEmployeeId],\n },\n },\n })\n\n const payrollUuid =\n response.payrollUnprocessed?.payrollUuid ?? response.payrollUnprocessed?.uuid\n\n if (!payrollUuid) {\n throw new SDKInternalError(t('errors.missingPayrollId'))\n }\n\n onEvent(componentEvents.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid })\n })\n }\n\n if (shouldAutoAdvance) {\n return null\n }\n\n return (\n <DismissalPayPeriodSelectionPresentation\n payPeriodOptions={payPeriodOptions}\n selectedPeriodKey={selectedPeriodKey}\n onSelectPeriod={setSelectedPeriodKey}\n onSubmit={handleSubmit}\n isPending={isPending}\n />\n )\n}\n"],"names":["DismissalPayPeriodSelection","props","jsx","BaseComponent","Root","payPeriodKey","period","companyId","employeeId","payrollId","dictionary","useComponentDictionary","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","data","usePaySchedulesGetUnprocessedTerminationPeriodsSuspense","createOffCyclePayroll","isPending","usePayrollsCreateOffCycleMutation","shouldAutoAdvance","useEffect","componentEvents","employeePayPeriods","useMemo","payPeriodOptions","dateRange","formatPayPeriodRange","label","initialSelection","selectedPeriodKey","setSelectedPeriodKey","useState","handleSubmit","SDKInternalError","p","resolvedEmployeeId","response","OffCycleReason","RFCDate","payrollUuid","DismissalPayPeriodSelectionPresentation"],"mappings":";;;;;;;;;;;;;;AAuBO,SAASA,GAA4BC,GAAyC;AACnF,SACE,gBAAAC,EAACC,KAAe,GAAGF,GACjB,4BAACG,GAAA,EAAM,GAAGH,GAAO,EAAA,CACnB;AAEJ;AAKA,MAAMI,IAAe,CAACC,MAA8B,GAAGA,EAAO,SAAS,KAAKA,EAAO,OAAO;AAE1F,SAASF,EAAK,EAAE,WAAAG,GAAW,YAAAC,GAAY,WAAAC,GAAW,YAAAC,KAAgD;AAChG,EAAAC,EAAuB,qBAAqBD,CAAU,GACtDE,EAAQ,mBAAmB;AAC3B,QAAM,EAAE,G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