@gusto/embedded-react-sdk 0.57.1 → 0.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/components/Base/Base.js +2 -3
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +6 -8
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +8 -10
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -6
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +6 -8
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -6
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/TitleSelect.js +10 -11
- package/dist/components/Company/AssignSignatory/TitleSelect.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -8
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +8 -9
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -6
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +10 -12
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +11 -13
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +5 -7
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -6
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Actions.js +7 -9
- package/dist/components/Company/FederalTaxes/Actions.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +8 -11
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Actions.js +5 -7
- package/dist/components/Company/Industry/Actions.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -9
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Industry/Edit.js +10 -12
- package/dist/components/Company/Industry/Edit.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +8 -10
- package/dist/components/Company/Locations/LocationForm/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -6
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/Actions.js +6 -8
- package/dist/components/Company/Locations/LocationsList/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +11 -13
- package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -6
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -6
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/PayScheduleForm.js +66 -62
- package/dist/components/Company/PaySchedule/PayScheduleForm.js.map +1 -1
- package/dist/components/Company/PaySchedule/PayScheduleForm.module.scss.js +2 -2
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +80 -68
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js +11 -13
- package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js +49 -44
- package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +5 -7
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -6
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +6 -8
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -6
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +3 -6
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
- package/dist/components/Contractor/Compensation/management/CompensationCard/CompensationCard.js +16 -17
- package/dist/components/Contractor/Compensation/management/CompensationCard/CompensationCard.js.map +1 -1
- package/dist/components/Contractor/Documents/management/DocumentsCard/DocumentsCard.js +8 -9
- package/dist/components/Contractor/Documents/management/DocumentsCard/DocumentsCard.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/shared/ContractorBankAccountFormBody/ContractorBankAccountFormBody.js +6 -8
- package/dist/components/Contractor/PaymentMethod/shared/ContractorBankAccountFormBody/ContractorBankAccountFormBody.js.map +1 -1
- package/dist/components/Contractor/Profile/management/ProfileCard/ProfileCard.js +26 -27
- package/dist/components/Contractor/Profile/management/ProfileCard/ProfileCard.js.map +1 -1
- package/dist/components/Contractor/Profile/management/ProfileEditForm.js +11 -11
- package/dist/components/Employee/Deductions/management/DeductionsCard/DeductionsCard.js +12 -13
- package/dist/components/Employee/Deductions/management/DeductionsCard/DeductionsCard.js.map +1 -1
- package/dist/components/Employee/Documents/management/DocumentsCard/DocumentsCard.js +12 -13
- package/dist/components/Employee/Documents/management/DocumentsCard/DocumentsCard.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/Actions.js +6 -8
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -6
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/management/FederalTaxesEditForm.js +3 -4
- package/dist/components/Employee/FederalTaxes/management/FederalTaxesEditForm.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/onboarding/FederalTaxes.js +3 -4
- package/dist/components/Employee/FederalTaxes/onboarding/FederalTaxes.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/BankFormBody/BankFormBody.js +22 -24
- package/dist/components/Employee/PaymentMethod/shared/BankFormBody/BankFormBody.js.map +1 -1
- package/dist/components/Employee/Paystubs/management/PaystubsCard/PaystubsCard.js +8 -9
- package/dist/components/Employee/Paystubs/management/PaystubsCard/PaystubsCard.js.map +1 -1
- package/dist/components/Employee/Profile/management/ProfileCard/ProfileCard.js +14 -15
- package/dist/components/Employee/Profile/management/ProfileCard/ProfileCard.js.map +1 -1
- package/dist/components/Employee/Profile/management/ProfileEditForm.js +1 -1
- package/dist/components/Employee/Profile/onboarding/EmployeeProfile.js +1 -1
- package/dist/components/Employee/StateTaxes/management/StateTaxesEditForm.js +7 -8
- package/dist/components/Employee/StateTaxes/management/StateTaxesEditForm.js.map +1 -1
- package/dist/components/Employee/StateTaxes/onboarding/StateTaxes.js +7 -8
- package/dist/components/Employee/StateTaxes/onboarding/StateTaxes.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +56 -54
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +14 -16
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js +6 -8
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js +9 -11
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +74 -88
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +44 -46
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.js +63 -61
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.js.map +1 -1
- package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js +14 -13
- package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js.map +1 -1
- package/dist/components/Payroll/helpers.js +52 -48
- package/dist/components/Payroll/helpers.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +13 -16
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/Payroll/useUnprocessedTransitionPayPeriods.js +2 -2
- package/dist/components/Payroll/useUnprocessedTransitionPayPeriods.js.map +1 -1
- package/dist/components/TimeOff/HolidayPolicyDetail/HolidayPolicyDetailPresentation.js +2 -4
- package/dist/components/TimeOff/HolidayPolicyDetail/HolidayPolicyDetailPresentation.js.map +1 -1
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js +6 -8
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js.map +1 -1
- package/dist/components/TimeOff/shared/PolicyDetailLayout/PolicyDetailLayout.js +28 -30
- package/dist/components/TimeOff/shared/PolicyDetailLayout/PolicyDetailLayout.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +2 -4
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/helpers/dateFormatting.js +47 -40
- package/dist/helpers/dateFormatting.js.map +1 -1
- package/dist/i18n/en/Company.Management.PaySchedule.json.js +20 -18
- package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -1
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +6 -4
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollHistory.json.js +5 -5
- package/dist/i18n/en/Payroll.PayrollOverview.json.js +1 -1
- package/dist/package.json.js +1 -1
- package/dist/partner-hook-utils/form/fields/CheckboxHookField.js +8 -10
- package/dist/partner-hook-utils/form/fields/CheckboxHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/NumberInputHookField.js +12 -14
- package/dist/partner-hook-utils/form/fields/NumberInputHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js +13 -15
- package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/SelectHookField.js +10 -12
- package/dist/partner-hook-utils/form/fields/SelectHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/SwitchHookField.js +14 -16
- package/dist/partner-hook-utils/form/fields/SwitchHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/TextInputHookField.js +8 -10
- package/dist/partner-hook-utils/form/fields/TextInputHookField.js.map +1 -1
- package/dist/src/components/Company/PaySchedule/PayScheduleForm.d.ts +6 -0
- package/dist/src/components/Payroll/helpers.d.ts +20 -0
- package/dist/src/helpers/dateFormatting.d.ts +13 -0
- package/dist/src/i18n/types.d.ts +14 -2
- package/dist/style.css +1 -1
- package/package.json +7 -7
|
@@ -4,16 +4,15 @@ import { useTranslation as f } from "react-i18next";
|
|
|
4
4
|
import { useContractorDocumentsGetPdf as D } from "@gusto/embedded-api/react-query/contractorDocumentsGetPdf";
|
|
5
5
|
import { requiresSignature as y } from "../../shared/documentSigningStatus.js";
|
|
6
6
|
import { useContractorDocumentsList as S } from "../../shared/useContractorDocumentsList/useContractorDocumentsList.js";
|
|
7
|
-
import "classnames";
|
|
8
|
-
import { componentEvents as p } from "../../../../../shared/constants.js";
|
|
9
7
|
import { Loading as w } from "../../../../Common/Loading/Loading.js";
|
|
10
|
-
import { EmptyData as
|
|
8
|
+
import { EmptyData as p } from "../../../../Common/EmptyData/EmptyData.js";
|
|
11
9
|
import { BaseBoundaries as E, BaseLayout as T } from "../../../../Base/Base.js";
|
|
12
10
|
import { useComponentContext as C } from "../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
11
|
import { useI18n as M } from "../../../../../i18n/I18n.js";
|
|
12
|
+
import { componentEvents as g } from "../../../../../shared/constants.js";
|
|
14
13
|
import { useDataView as B } from "../../../../Common/DataView/useDataView.js";
|
|
15
14
|
import { DataView as _ } from "../../../../Common/DataView/DataView.js";
|
|
16
|
-
function
|
|
15
|
+
function I({ LoaderComponent: o, ...r }) {
|
|
17
16
|
return /* @__PURE__ */ t(
|
|
18
17
|
E,
|
|
19
18
|
{
|
|
@@ -45,14 +44,14 @@ function N({ contractorId: o, onEvent: r, LoaderComponent: a }) {
|
|
|
45
44
|
data: c,
|
|
46
45
|
columns: d,
|
|
47
46
|
itemMenu: (n) => n.uuid ? /* @__PURE__ */ t(x, { contractorId: o, documentUuid: n.uuid, onEvent: r }) : null,
|
|
48
|
-
emptyState: () => /* @__PURE__ */ t(
|
|
47
|
+
emptyState: () => /* @__PURE__ */ t(p, { title: e("emptyState.title") })
|
|
49
48
|
});
|
|
50
49
|
return /* @__PURE__ */ t(T, { error: s.errorHandling.errors, LoaderComponent: a, children: /* @__PURE__ */ t(
|
|
51
50
|
i.Box,
|
|
52
51
|
{
|
|
53
52
|
withPadding: !u,
|
|
54
53
|
header: /* @__PURE__ */ t(i.BoxHeader, { title: e("title") }),
|
|
55
|
-
children: m ? /* @__PURE__ */ t(w, {}) : u ? /* @__PURE__ */ t(_, { label: e("listLabel"), isWithinBox: !0, ...l }) : /* @__PURE__ */ t(
|
|
54
|
+
children: m ? /* @__PURE__ */ t(w, {}) : u ? /* @__PURE__ */ t(_, { label: e("listLabel"), isWithinBox: !0, ...l }) : /* @__PURE__ */ t(p, { title: e("emptyState.title") })
|
|
56
55
|
}
|
|
57
56
|
) });
|
|
58
57
|
}
|
|
@@ -62,13 +61,13 @@ function x({
|
|
|
62
61
|
onEvent: a
|
|
63
62
|
}) {
|
|
64
63
|
const { t: e } = f("Contractor.Management.Documents"), i = C(), [s, m] = h(!1), { refetch: c } = D({ documentUuid: r }, { enabled: !1 }), u = async () => {
|
|
65
|
-
a(
|
|
64
|
+
a(g.CONTRACTOR_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED, {
|
|
66
65
|
contractorId: o,
|
|
67
66
|
documentUuid: r
|
|
68
67
|
}), m(!0);
|
|
69
68
|
try {
|
|
70
69
|
const { data: d } = await c(), l = d?.documentPdf?.documentUrl;
|
|
71
|
-
l && (window.open(l, "_blank", "noopener,noreferrer"), a(
|
|
70
|
+
l && (window.open(l, "_blank", "noopener,noreferrer"), a(g.CONTRACTOR_MANAGEMENT_DOCUMENTS_CARD_VIEWED, {
|
|
72
71
|
contractorId: o,
|
|
73
72
|
documentUuid: r
|
|
74
73
|
}));
|
|
@@ -89,6 +88,6 @@ function x({
|
|
|
89
88
|
);
|
|
90
89
|
}
|
|
91
90
|
export {
|
|
92
|
-
|
|
91
|
+
I as DocumentsCard
|
|
93
92
|
};
|
|
94
93
|
//# sourceMappingURL=DocumentsCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentsCard.js","sources":["../../../../../../src/components/Contractor/Documents/management/DocumentsCard/DocumentsCard.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useContractorDocumentsGetPdf } from '@gusto/embedded-api/react-query/contractorDocumentsGetPdf'\nimport type { Document } from '@gusto/embedded-api/models/components/document'\nimport { requiresSignature } from '../../shared/documentSigningStatus'\nimport { useContractorDocumentsList } from '../../shared/useContractorDocumentsList'\nimport { DataView, EmptyData, useDataView, Loading } from '@/components/Common'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { LoaderComponentType } from '@/components/Base'\n\n/**\n * Props for {@link DocumentsCard}.\n *\n * @public\n */\nexport interface DocumentsCardProps {\n /** The associated contractor identifier. */\n contractorId: string\n /** Event handler fired when the user views a document. */\n onEvent: OnEventType<EventType, unknown>\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n/**\n * Standalone read-only \"Documents\" card.\n *\n * @remarks\n * Fetches its own data via {@link useContractorDocumentsList} and renders a\n * table of the contractor's forms with a per-row \"View\" action that opens\n * the document's PDF in a new tab. Read-only — signing happens during\n * contractor onboarding, not from this surface.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/management/documents/card/viewRequested` | Fired when a document row's \"View\" button is clicked, before the PDF is fetched | `{ contractorId: string, documentUuid: string }` |\n * | `contractor/management/documents/card/viewed` | Fired after the PDF is fetched and opened in a new tab | `{ contractorId: string, documentUuid: string }` |\n *\n * @param props - See {@link DocumentsCardProps}.\n * @returns The contractor documents card.\n * @public\n */\nexport function DocumentsCard({ LoaderComponent, ...props }: DocumentsCardProps) {\n return (\n <BaseBoundaries\n componentName=\"Contractor.Management.Documents\"\n LoaderComponent={LoaderComponent}\n >\n <DocumentsCardContent LoaderComponent={LoaderComponent} {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction DocumentsCardContent({ contractorId, onEvent, LoaderComponent }: DocumentsCardProps) {\n useI18n('Contractor.Management.Documents')\n const { t } = useTranslation('Contractor.Management.Documents')\n const Components = useComponentContext()\n const documentsList = useContractorDocumentsList({ contractorId })\n\n const isLoading = documentsList.isLoading\n const documents = documentsList.isLoading ? [] : documentsList.data.documents\n const isShowingTable = documents.length > 0\n\n const columns = [\n {\n key: 'title',\n title: t('nameColumn'),\n render: (document: Document) => (\n <Components.Text weight=\"medium\" size=\"sm\">\n {document.title ?? document.name ?? t('emptyPlaceholder')}\n </Components.Text>\n ),\n },\n {\n key: 'description',\n title: t('descriptionColumn'),\n render: (document: Document) => (\n <Components.Text variant=\"supporting\" size=\"sm\">\n {document.description ?? t('emptyPlaceholder')}\n </Components.Text>\n ),\n },\n {\n key: 'signingStatus',\n title: t('signingStatusColumn'),\n render: (document: Document) =>\n requiresSignature(document) ? (\n <Components.Badge status=\"warning\">{t('signingStatus.notSigned')}</Components.Badge>\n ) : (\n <Components.Badge status=\"success\">{t('signingStatus.signed')}</Components.Badge>\n ),\n },\n ]\n\n const dataViewProps = useDataView({\n data: documents,\n columns,\n itemMenu: document =>\n document.uuid ? (\n <ViewButton contractorId={contractorId} documentUuid={document.uuid} onEvent={onEvent} />\n ) : null,\n emptyState: () => <EmptyData title={t('emptyState.title')} />,\n })\n\n return (\n <BaseLayout error={documentsList.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <Components.Box\n withPadding={!isShowingTable}\n header={<Components.BoxHeader title={t('title')} />}\n >\n {isLoading ? (\n <Loading />\n ) : isShowingTable ? (\n <DataView label={t('listLabel')} isWithinBox {...dataViewProps} />\n ) : (\n <EmptyData title={t('emptyState.title')} />\n )}\n </Components.Box>\n </BaseLayout>\n )\n}\n\nfunction ViewButton({\n contractorId,\n documentUuid,\n onEvent,\n}: {\n contractorId: string\n documentUuid: string\n onEvent: OnEventType<EventType, unknown>\n}) {\n const { t } = useTranslation('Contractor.Management.Documents')\n const Components = useComponentContext()\n const [isOpening, setIsOpening] = useState(false)\n const { refetch } = useContractorDocumentsGetPdf({ documentUuid }, { enabled: false })\n\n const handleView = async () => {\n onEvent(componentEvents.CONTRACTOR_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED, {\n contractorId,\n documentUuid,\n })\n setIsOpening(true)\n try {\n const { data } = await refetch()\n const url = data?.documentPdf?.documentUrl\n if (url) {\n window.open(url, '_blank', 'noopener,noreferrer')\n onEvent(componentEvents.CONTRACTOR_MANAGEMENT_DOCUMENTS_CARD_VIEWED, {\n contractorId,\n documentUuid,\n })\n }\n } finally {\n setIsOpening(false)\n }\n }\n\n return (\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n void handleView()\n }}\n isLoading={isOpening}\n >\n {t('viewCta')}\n </Components.Button>\n )\n}\n"],"names":["DocumentsCard","LoaderComponent","props","jsx","BaseBoundaries","DocumentsCardContent","contractorId","onEvent","useI18n","t","useTranslation","Components","useComponentContext","documentsList","useContractorDocumentsList","isLoading","documents","isShowingTable","columns","document","requiresSignature","dataViewProps","useDataView","ViewButton","EmptyData","BaseLayout","Loading","DataView","documentUuid","isOpening","setIsOpening","useState","refetch","useContractorDocumentsGetPdf","handleView","componentEvents","data","url"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DocumentsCard.js","sources":["../../../../../../src/components/Contractor/Documents/management/DocumentsCard/DocumentsCard.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useContractorDocumentsGetPdf } from '@gusto/embedded-api/react-query/contractorDocumentsGetPdf'\nimport type { Document } from '@gusto/embedded-api/models/components/document'\nimport { requiresSignature } from '../../shared/documentSigningStatus'\nimport { useContractorDocumentsList } from '../../shared/useContractorDocumentsList'\nimport { DataView, EmptyData, useDataView, Loading } from '@/components/Common'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { LoaderComponentType } from '@/components/Base'\n\n/**\n * Props for {@link DocumentsCard}.\n *\n * @public\n */\nexport interface DocumentsCardProps {\n /** The associated contractor identifier. */\n contractorId: string\n /** Event handler fired when the user views a document. */\n onEvent: OnEventType<EventType, unknown>\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n/**\n * Standalone read-only \"Documents\" card.\n *\n * @remarks\n * Fetches its own data via {@link useContractorDocumentsList} and renders a\n * table of the contractor's forms with a per-row \"View\" action that opens\n * the document's PDF in a new tab. Read-only — signing happens during\n * contractor onboarding, not from this surface.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/management/documents/card/viewRequested` | Fired when a document row's \"View\" button is clicked, before the PDF is fetched | `{ contractorId: string, documentUuid: string }` |\n * | `contractor/management/documents/card/viewed` | Fired after the PDF is fetched and opened in a new tab | `{ contractorId: string, documentUuid: string }` |\n *\n * @param props - See {@link DocumentsCardProps}.\n * @returns The contractor documents card.\n * @public\n */\nexport function DocumentsCard({ LoaderComponent, ...props }: DocumentsCardProps) {\n return (\n <BaseBoundaries\n componentName=\"Contractor.Management.Documents\"\n LoaderComponent={LoaderComponent}\n >\n <DocumentsCardContent LoaderComponent={LoaderComponent} {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction DocumentsCardContent({ contractorId, onEvent, LoaderComponent }: DocumentsCardProps) {\n useI18n('Contractor.Management.Documents')\n const { t } = useTranslation('Contractor.Management.Documents')\n const Components = useComponentContext()\n const documentsList = useContractorDocumentsList({ contractorId })\n\n const isLoading = documentsList.isLoading\n const documents = documentsList.isLoading ? [] : documentsList.data.documents\n const isShowingTable = documents.length > 0\n\n const columns = [\n {\n key: 'title',\n title: t('nameColumn'),\n render: (document: Document) => (\n <Components.Text weight=\"medium\" size=\"sm\">\n {document.title ?? document.name ?? t('emptyPlaceholder')}\n </Components.Text>\n ),\n },\n {\n key: 'description',\n title: t('descriptionColumn'),\n render: (document: Document) => (\n <Components.Text variant=\"supporting\" size=\"sm\">\n {document.description ?? t('emptyPlaceholder')}\n </Components.Text>\n ),\n },\n {\n key: 'signingStatus',\n title: t('signingStatusColumn'),\n render: (document: Document) =>\n requiresSignature(document) ? (\n <Components.Badge status=\"warning\">{t('signingStatus.notSigned')}</Components.Badge>\n ) : (\n <Components.Badge status=\"success\">{t('signingStatus.signed')}</Components.Badge>\n ),\n },\n ]\n\n const dataViewProps = useDataView({\n data: documents,\n columns,\n itemMenu: document =>\n document.uuid ? (\n <ViewButton contractorId={contractorId} documentUuid={document.uuid} onEvent={onEvent} />\n ) : null,\n emptyState: () => <EmptyData title={t('emptyState.title')} />,\n })\n\n return (\n <BaseLayout error={documentsList.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <Components.Box\n withPadding={!isShowingTable}\n header={<Components.BoxHeader title={t('title')} />}\n >\n {isLoading ? (\n <Loading />\n ) : isShowingTable ? (\n <DataView label={t('listLabel')} isWithinBox {...dataViewProps} />\n ) : (\n <EmptyData title={t('emptyState.title')} />\n )}\n </Components.Box>\n </BaseLayout>\n )\n}\n\nfunction ViewButton({\n contractorId,\n documentUuid,\n onEvent,\n}: {\n contractorId: string\n documentUuid: string\n onEvent: OnEventType<EventType, unknown>\n}) {\n const { t } = useTranslation('Contractor.Management.Documents')\n const Components = useComponentContext()\n const [isOpening, setIsOpening] = useState(false)\n const { refetch } = useContractorDocumentsGetPdf({ documentUuid }, { enabled: false })\n\n const handleView = async () => {\n onEvent(componentEvents.CONTRACTOR_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED, {\n contractorId,\n documentUuid,\n })\n setIsOpening(true)\n try {\n const { data } = await refetch()\n const url = data?.documentPdf?.documentUrl\n if (url) {\n window.open(url, '_blank', 'noopener,noreferrer')\n onEvent(componentEvents.CONTRACTOR_MANAGEMENT_DOCUMENTS_CARD_VIEWED, {\n contractorId,\n documentUuid,\n })\n }\n } finally {\n setIsOpening(false)\n }\n }\n\n return (\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n void handleView()\n }}\n isLoading={isOpening}\n >\n {t('viewCta')}\n </Components.Button>\n )\n}\n"],"names":["DocumentsCard","LoaderComponent","props","jsx","BaseBoundaries","DocumentsCardContent","contractorId","onEvent","useI18n","t","useTranslation","Components","useComponentContext","documentsList","useContractorDocumentsList","isLoading","documents","isShowingTable","columns","document","requiresSignature","dataViewProps","useDataView","ViewButton","EmptyData","BaseLayout","Loading","DataView","documentUuid","isOpening","setIsOpening","useState","refetch","useContractorDocumentsGetPdf","handleView","componentEvents","data","url"],"mappings":";;;;;;;;;;;;;;AA+CO,SAASA,EAAc,EAAE,iBAAAC,GAAiB,GAAGC,KAA6B;AAC/E,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,eAAc;AAAA,MACd,iBAAAH;AAAA,MAEA,UAAA,gBAAAE,EAACE,GAAA,EAAqB,iBAAAJ,GAAmC,GAAGC,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAGzE;AAEA,SAASG,EAAqB,EAAE,cAAAC,GAAc,SAAAC,GAAS,iBAAAN,KAAuC;AAC5F,EAAAO,EAAQ,iCAAiC;AACzC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,iCAAiC,GACxDC,IAAaC,EAAA,GACbC,IAAgBC,EAA2B,EAAE,cAAAR,GAAc,GAE3DS,IAAYF,EAAc,WAC1BG,IAAYH,EAAc,YAAY,CAAA,IAAKA,EAAc,KAAK,WAC9DI,IAAiBD,EAAU,SAAS,GAEpCE,IAAU;AAAA,IACd;AAAA,MACE,KAAK;AAAA,MACL,OAAOT,EAAE,YAAY;AAAA,MACrB,QAAQ,CAACU,MACP,gBAAAhB,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,WAAW,GAAG,aAAW,IAAE,GAAGY,GAAe,sBAE/DG,GAAA,EAAU,OAAOf,EAAE,kBAAkB,EAAA,CAAG;AAAA,IAAA;AAAA,EAAA,GAG/C;AAEJ;AAEA,SAASc,EAAW;AAAA,EAClB,cAAAjB;AAAA,EACA,cAAAsB;AAAA,EACA,SAAArB;AACF,GAIG;AACD,QAAM,EAAE,GAAAE,EAAA,IAAMC,EAAe,iCAAiC,GACxDC,IAAaC,EAAA,GACb,CAACiB,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1C,EAAE,SAAAC,EAAA,IAAYC,EAA6B,EAAE,cAAAL,KAAgB,EAAE,SAAS,IAAO,GAE/EM,IAAa,YAAY;AAC7B,IAAA3B,EAAQ4B,EAAgB,qDAAqD;AAAA,MAC3E,cAAA7B;AAAA,MACA,cAAAsB;AAAA,IAAA,CACD,GACDE,EAAa,EAAI;AACjB,QAAI;AACF,YAAM,EAAE,MAAAM,MAAS,MAAMJ,EAAA,GACjBK,IAAMD,GAAM,aAAa;AAC/B,MAAIC,MACF,OAAO,KAAKA,GAAK,UAAU,qBAAqB,GAChD9B,EAAQ4B,EAAgB,6CAA6C;AAAA,QACnE,cAAA7B;AAAA,QACA,cAAAsB;AAAA,MAAA,CACD;AAAA,IAEL,UAAA;AACE,MAAAE,EAAa,EAAK;AAAA,IACpB;AAAA,EACF;AAEA,SACE,gBAAA3B;AAAA,IAACQ,EAAW;AAAA,IAAX;AAAA,MACC,SAAQ;AAAA,MACR,SAAS,MAAM;AACb,QAAKuB,EAAA;AAAA,MACP;AAAA,MACA,WAAWL;AAAA,MAEV,YAAE,SAAS;AAAA,IAAA;AAAA,EAAA;AAGlB;"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { jsx as r, jsxs as s } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as f } from "react-i18next";
|
|
3
3
|
import { useContractorBankAccountForm as C } from "../useContractorBankAccountForm/useContractorBankAccountForm.js";
|
|
4
|
-
import "classnames";
|
|
5
|
-
import "../../../../../shared/constants.js";
|
|
6
4
|
import { ActionsLayout as B } from "../../../../Common/ActionsLayout/ActionsLayout.js";
|
|
7
5
|
import { Form as k } from "../../../../Common/Form/Form.js";
|
|
8
6
|
import { BaseLayout as m } from "../../../../Base/Base.js";
|
|
@@ -11,16 +9,16 @@ import { SDKFormProvider as F } from "../../../../../partner-hook-utils/form/SDK
|
|
|
11
9
|
import { useI18n as A, useComponentDictionary as h } from "../../../../../i18n/I18n.js";
|
|
12
10
|
import { useComponentContext as y } from "../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
11
|
import { ContractorBankAccountFields as b } from "../ContractorBankAccountFields/ContractorBankAccountFields.js";
|
|
14
|
-
function
|
|
12
|
+
function K({
|
|
15
13
|
contractorId: u,
|
|
16
14
|
dictionary: t,
|
|
17
15
|
onSaved: d,
|
|
18
16
|
onCancel: n,
|
|
19
17
|
LoaderComponent: i,
|
|
20
|
-
...
|
|
18
|
+
...l
|
|
21
19
|
}) {
|
|
22
20
|
A("Contractor.BankAccountFields"), h("Contractor.BankAccountFields", t);
|
|
23
|
-
const o = C({ contractorId: u, ...
|
|
21
|
+
const o = C({ contractorId: u, ...l }), { t: c } = f("Contractor.BankAccountFields"), e = y();
|
|
24
22
|
if (o.isLoading)
|
|
25
23
|
return /* @__PURE__ */ r(
|
|
26
24
|
m,
|
|
@@ -30,11 +28,11 @@ function T({
|
|
|
30
28
|
LoaderComponent: i
|
|
31
29
|
}
|
|
32
30
|
);
|
|
33
|
-
const
|
|
31
|
+
const p = async () => {
|
|
34
32
|
const a = await o.actions.onSubmit();
|
|
35
33
|
a && d(a.data);
|
|
36
34
|
};
|
|
37
|
-
return /* @__PURE__ */ r(m, { error: o.errorHandling.errors, LoaderComponent: i, children: /* @__PURE__ */ r(F, { formHookResult: o, children: /* @__PURE__ */ s(k, { onSubmit:
|
|
35
|
+
return /* @__PURE__ */ r(m, { error: o.errorHandling.errors, LoaderComponent: i, children: /* @__PURE__ */ r(F, { formHookResult: o, children: /* @__PURE__ */ s(k, { onSubmit: p, children: [
|
|
38
36
|
/* @__PURE__ */ r(b, { bankAccountForm: o, dictionary: t }),
|
|
39
37
|
/* @__PURE__ */ s(B, { children: [
|
|
40
38
|
n && /* @__PURE__ */ r(e.Button, { variant: "secondary", type: "button", onClick: n, children: c("cancelCta") }),
|
|
@@ -43,6 +41,6 @@ function T({
|
|
|
43
41
|
] }) }) });
|
|
44
42
|
}
|
|
45
43
|
export {
|
|
46
|
-
|
|
44
|
+
K as ContractorBankAccountFormBody
|
|
47
45
|
};
|
|
48
46
|
//# sourceMappingURL=ContractorBankAccountFormBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractorBankAccountFormBody.js","sources":["../../../../../../src/components/Contractor/PaymentMethod/shared/ContractorBankAccountFormBody/ContractorBankAccountFormBody.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { ContractorBankAccount } from '@gusto/embedded-api/models/components/contractorbankaccount'\nimport { useContractorBankAccountForm } from '../useContractorBankAccountForm'\nimport type { UseContractorBankAccountFormProps } from '../useContractorBankAccountForm'\nimport {\n ContractorBankAccountFields,\n type ContractorBankAccountFieldsDictionary,\n} from '../ContractorBankAccountFields'\nimport { ActionsLayout } from '@/components/Common'\nimport { Form } from '@/components/Common/Form'\nimport { BaseLayout } from '@/components/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { LoaderComponentType } from '@/components/Base'\n\n/** @internal */\nexport interface ContractorBankAccountFormBodyProps extends Omit<\n UseContractorBankAccountFormProps,\n 'contractorId'\n> {\n /** The associated contractor identifier. */\n contractorId: string\n /**\n * Translation overrides for the form's strings. Each consuming surface\n * passes the dictionary it resolved from its own namespace so a partner\n * override on one surface doesn't leak into the other.\n */\n dictionary?: ContractorBankAccountFieldsDictionary\n /** Called with the created bank account after a successful submit. */\n onSaved: (bankAccount: ContractorBankAccount) => void\n onCancel?: () => void\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n/**\n * Shared bank-account form body. Owns the `useContractorBankAccountForm`\n * composition, the shared field set, and the submit/cancel actions. Reads\n * its copy from the internal `Contractor.BankAccountFields` namespace;\n * consuming surfaces inject their own copy via the `dictionary` prop and map\n * the `onSaved`/`onCancel` callbacks onto their surface-specific events.\n *\n * @internal\n */\nexport function ContractorBankAccountFormBody({\n contractorId,\n dictionary,\n onSaved,\n onCancel,\n LoaderComponent,\n ...hookProps\n}: ContractorBankAccountFormBodyProps) {\n useI18n('Contractor.BankAccountFields')\n useComponentDictionary('Contractor.BankAccountFields', dictionary)\n const bankAccountForm = useContractorBankAccountForm({ contractorId, ...hookProps })\n const { t } = useTranslation('Contractor.BankAccountFields')\n const Components = useComponentContext()\n\n if (bankAccountForm.isLoading) {\n return (\n <BaseLayout\n isLoading\n error={bankAccountForm.errorHandling.errors}\n LoaderComponent={LoaderComponent}\n />\n )\n }\n\n const handleSubmit = async () => {\n const result = await bankAccountForm.actions.onSubmit()\n if (result) {\n onSaved(result.data)\n }\n }\n\n return (\n <BaseLayout error={bankAccountForm.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <SDKFormProvider formHookResult={bankAccountForm}>\n <Form onSubmit={handleSubmit}>\n <ContractorBankAccountFields bankAccountForm={bankAccountForm} dictionary={dictionary} />\n <ActionsLayout>\n {onCancel && (\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onCancel}>\n {t('cancelCta')}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={bankAccountForm.status.isPending}>\n {t('saveCta')}\n </Components.Button>\n </ActionsLayout>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n )\n}\n"],"names":["ContractorBankAccountFormBody","contractorId","dictionary","onSaved","onCancel","LoaderComponent","hookProps","useI18n","useComponentDictionary","bankAccountForm","useContractorBankAccountForm","t","useTranslation","Components","useComponentContext","jsx","BaseLayout","handleSubmit","result","SDKFormProvider","jsxs","Form","ContractorBankAccountFields","ActionsLayout"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractorBankAccountFormBody.js","sources":["../../../../../../src/components/Contractor/PaymentMethod/shared/ContractorBankAccountFormBody/ContractorBankAccountFormBody.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { ContractorBankAccount } from '@gusto/embedded-api/models/components/contractorbankaccount'\nimport { useContractorBankAccountForm } from '../useContractorBankAccountForm'\nimport type { UseContractorBankAccountFormProps } from '../useContractorBankAccountForm'\nimport {\n ContractorBankAccountFields,\n type ContractorBankAccountFieldsDictionary,\n} from '../ContractorBankAccountFields'\nimport { ActionsLayout } from '@/components/Common'\nimport { Form } from '@/components/Common/Form'\nimport { BaseLayout } from '@/components/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { LoaderComponentType } from '@/components/Base'\n\n/** @internal */\nexport interface ContractorBankAccountFormBodyProps extends Omit<\n UseContractorBankAccountFormProps,\n 'contractorId'\n> {\n /** The associated contractor identifier. */\n contractorId: string\n /**\n * Translation overrides for the form's strings. Each consuming surface\n * passes the dictionary it resolved from its own namespace so a partner\n * override on one surface doesn't leak into the other.\n */\n dictionary?: ContractorBankAccountFieldsDictionary\n /** Called with the created bank account after a successful submit. */\n onSaved: (bankAccount: ContractorBankAccount) => void\n onCancel?: () => void\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n/**\n * Shared bank-account form body. Owns the `useContractorBankAccountForm`\n * composition, the shared field set, and the submit/cancel actions. Reads\n * its copy from the internal `Contractor.BankAccountFields` namespace;\n * consuming surfaces inject their own copy via the `dictionary` prop and map\n * the `onSaved`/`onCancel` callbacks onto their surface-specific events.\n *\n * @internal\n */\nexport function ContractorBankAccountFormBody({\n contractorId,\n dictionary,\n onSaved,\n onCancel,\n LoaderComponent,\n ...hookProps\n}: ContractorBankAccountFormBodyProps) {\n useI18n('Contractor.BankAccountFields')\n useComponentDictionary('Contractor.BankAccountFields', dictionary)\n const bankAccountForm = useContractorBankAccountForm({ contractorId, ...hookProps })\n const { t } = useTranslation('Contractor.BankAccountFields')\n const Components = useComponentContext()\n\n if (bankAccountForm.isLoading) {\n return (\n <BaseLayout\n isLoading\n error={bankAccountForm.errorHandling.errors}\n LoaderComponent={LoaderComponent}\n />\n )\n }\n\n const handleSubmit = async () => {\n const result = await bankAccountForm.actions.onSubmit()\n if (result) {\n onSaved(result.data)\n }\n }\n\n return (\n <BaseLayout error={bankAccountForm.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <SDKFormProvider formHookResult={bankAccountForm}>\n <Form onSubmit={handleSubmit}>\n <ContractorBankAccountFields bankAccountForm={bankAccountForm} dictionary={dictionary} />\n <ActionsLayout>\n {onCancel && (\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onCancel}>\n {t('cancelCta')}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={bankAccountForm.status.isPending}>\n {t('saveCta')}\n </Components.Button>\n </ActionsLayout>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n )\n}\n"],"names":["ContractorBankAccountFormBody","contractorId","dictionary","onSaved","onCancel","LoaderComponent","hookProps","useI18n","useComponentDictionary","bankAccountForm","useContractorBankAccountForm","t","useTranslation","Components","useComponentContext","jsx","BaseLayout","handleSubmit","result","SDKFormProvider","jsxs","Form","ContractorBankAccountFields","ActionsLayout"],"mappings":";;;;;;;;;;;AA6CO,SAASA,EAA8B;AAAA,EAC5C,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,GAA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import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { useI18n as D } from "../../../../../i18n/I18n.js";
|
|
3
|
+
import { Loading as h } from "../../../../Common/Loading/Loading.js";
|
|
4
|
+
import { BaseBoundaries as g, BaseLayout as P } from "../../../../Base/Base.js";
|
|
5
|
+
import { useComponentContext as T } from "../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
6
|
+
import { formatDateLongWithYear as X } from "../../../../../helpers/dateFormatting.js";
|
|
7
|
+
import { firstLastName as v } from "../../../../../helpers/formattedStrings.js";
|
|
8
|
+
import { useI18n as y } from "../../../../../i18n/I18n.js";
|
|
9
|
+
import { CONTRACTOR_TYPE as B, componentEvents as D } from "../../../../../shared/constants.js";
|
|
11
10
|
import { useContractorProfileSummary as L } from "../../shared/useContractorProfileSummary/useContractorProfileSummary.js";
|
|
12
|
-
function
|
|
13
|
-
return /* @__PURE__ */
|
|
11
|
+
function U({ LoaderComponent: r, ...s }) {
|
|
12
|
+
return /* @__PURE__ */ e(g, { componentName: "Contractor.Management.Profile", LoaderComponent: r, children: /* @__PURE__ */ e(S, { LoaderComponent: r, ...s }) });
|
|
14
13
|
}
|
|
15
14
|
function S({ contractorId: r, onEvent: s, LoaderComponent: l }) {
|
|
16
|
-
|
|
17
|
-
const { t:
|
|
15
|
+
y("Contractor.Management.Profile");
|
|
16
|
+
const { t: o } = N("Contractor.Management.Profile"), n = T(), a = L({ contractorId: r }), m = a.isLoading, t = a.isLoading ? void 0 : a.data.contractor, c = t?.type === B.BUSINESS, d = t ? c ? t.businessName : v({
|
|
18
17
|
first_name: t.firstName,
|
|
19
18
|
middle_initial: t.middleInitial,
|
|
20
19
|
last_name: t.lastName
|
|
21
|
-
}) : void 0, p = t ?
|
|
22
|
-
{ term:
|
|
23
|
-
{ term:
|
|
20
|
+
}) : void 0, p = t ? X(t.startDate) : void 0, f = t?.hasSsn ? "XXX-XX-XXXX" : void 0, u = t?.hasEin ? t.ein ?? void 0 : void 0, i = /* @__PURE__ */ e("span", { "aria-label": o("listEmptyPlaceholder"), children: "–" }), C = t ? [
|
|
21
|
+
{ term: o("legalName"), description: d || i },
|
|
22
|
+
{ term: o("startDate"), description: p || i },
|
|
24
23
|
c ? {
|
|
25
|
-
term:
|
|
24
|
+
term: o("employerIdentificationNumber"),
|
|
26
25
|
description: u || i
|
|
27
26
|
} : {
|
|
28
|
-
term:
|
|
27
|
+
term: o("socialSecurityNumber"),
|
|
29
28
|
description: f || i
|
|
30
29
|
},
|
|
31
|
-
{ term:
|
|
30
|
+
{ term: o("email"), description: t.email || i }
|
|
32
31
|
] : [], E = () => {
|
|
33
|
-
s(
|
|
32
|
+
s(D.CONTRACTOR_MANAGEMENT_PROFILE_EDIT_REQUESTED, { contractorId: r });
|
|
34
33
|
};
|
|
35
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ e(P, { error: a.errorHandling.errors, LoaderComponent: l, children: /* @__PURE__ */ e(
|
|
36
35
|
n.Box,
|
|
37
36
|
{
|
|
38
|
-
header: /* @__PURE__ */
|
|
37
|
+
header: /* @__PURE__ */ e(
|
|
39
38
|
n.BoxHeader,
|
|
40
39
|
{
|
|
41
|
-
title:
|
|
42
|
-
action: /* @__PURE__ */
|
|
40
|
+
title: o("title"),
|
|
41
|
+
action: /* @__PURE__ */ e(
|
|
43
42
|
n.Button,
|
|
44
43
|
{
|
|
45
44
|
variant: "secondary",
|
|
46
45
|
onClick: E,
|
|
47
46
|
isDisabled: m,
|
|
48
|
-
children:
|
|
47
|
+
children: o("editCta")
|
|
49
48
|
}
|
|
50
49
|
)
|
|
51
50
|
}
|
|
52
51
|
),
|
|
53
|
-
children: m ? /* @__PURE__ */
|
|
52
|
+
children: m ? /* @__PURE__ */ e(h, {}) : t ? /* @__PURE__ */ e(n.DescriptionList, { items: C }) : null
|
|
54
53
|
}
|
|
55
54
|
) });
|
|
56
55
|
}
|
|
57
56
|
export {
|
|
58
|
-
|
|
57
|
+
U as ProfileCard
|
|
59
58
|
};
|
|
60
59
|
//# sourceMappingURL=ProfileCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileCard.js","sources":["../../../../../../src/components/Contractor/Profile/management/ProfileCard/ProfileCard.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useContractorProfileSummary } from '../../shared/useContractorProfileSummary'\nimport { Loading } from '@/components/Common'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { formatDateLongWithYear } from '@/helpers/dateFormatting'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { useI18n } from '@/i18n'\nimport { componentEvents, CONTRACTOR_TYPE, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { LoaderComponentType } from '@/components/Base'\n\n/**\n * Props for {@link ProfileCard}.\n *\n * @public\n */\nexport interface ProfileCardProps {\n /** The associated contractor identifier. */\n contractorId: string\n /** Event handler fired when the user requests to edit the profile. */\n onEvent: OnEventType<EventType, unknown>\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n/**\n * Read-only card showing a contractor's basic profile details with an Edit action.\n *\n * @remarks\n * Standalone card that fetches its own data. Emits an event when the user\n * clicks Edit so the parent can switch to the edit form. The card does not\n * render success or error alerts itself — alert presentation is the\n * surrounding surface's responsibility.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/management/profile/editRequested` | Fired when the user clicks the Edit button | `{ contractorId: string }` |\n *\n * @param props - See {@link ProfileCardProps}.\n * @returns The basic-details profile card.\n * @public\n */\nexport function ProfileCard({ LoaderComponent, ...props }: ProfileCardProps) {\n return (\n <BaseBoundaries componentName=\"Contractor.Management.Profile\" LoaderComponent={LoaderComponent}>\n <ProfileCardContent LoaderComponent={LoaderComponent} {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction ProfileCardContent({ contractorId, onEvent, LoaderComponent }: ProfileCardProps) {\n useI18n('Contractor.Management.Profile')\n const { t } = useTranslation('Contractor.Management.Profile')\n const Components = useComponentContext()\n\n const profile = useContractorProfileSummary({ contractorId })\n\n const isContractorLoading = profile.isLoading\n\n const contractor = profile.isLoading ? undefined : profile.data.contractor\n\n const isBusiness = contractor?.type === CONTRACTOR_TYPE.BUSINESS\n\n const legalName = contractor\n ? isBusiness\n ? contractor.businessName\n : firstLastName({\n first_name: contractor.firstName,\n middle_initial: contractor.middleInitial,\n last_name: contractor.lastName,\n })\n : undefined\n const startDate = contractor ? formatDateLongWithYear(contractor.startDate) : undefined\n const maskedSsn = contractor?.hasSsn ? 'XXX-XX-XXXX' : undefined\n const maskedEin = contractor?.hasEin ? (contractor.ein ?? undefined) : undefined\n\n const emptyPlaceholder = <span aria-label={t('listEmptyPlaceholder')}>–</span>\n const profileItems = contractor\n ? [\n { term: t('legalName'), description: legalName || emptyPlaceholder },\n { term: t('startDate'), description: startDate || emptyPlaceholder },\n isBusiness\n ? {\n term: t('employerIdentificationNumber'),\n description: maskedEin || emptyPlaceholder,\n }\n : {\n term: t('socialSecurityNumber'),\n description: maskedSsn || emptyPlaceholder,\n },\n { term: t('email'), description: contractor.email || emptyPlaceholder },\n ]\n : []\n\n const handleEdit = () => {\n onEvent(componentEvents.CONTRACTOR_MANAGEMENT_PROFILE_EDIT_REQUESTED, { contractorId })\n }\n\n return (\n <BaseLayout error={profile.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <Components.Box\n header={\n <Components.BoxHeader\n title={t('title')}\n action={\n <Components.Button\n variant=\"secondary\"\n onClick={handleEdit}\n isDisabled={isContractorLoading}\n >\n {t('editCta')}\n </Components.Button>\n }\n />\n }\n >\n {isContractorLoading ? (\n <Loading />\n ) : contractor ? (\n <Components.DescriptionList items={profileItems} />\n ) : null}\n </Components.Box>\n </BaseLayout>\n )\n}\n"],"names":["ProfileCard","LoaderComponent","props","jsx","BaseBoundaries","ProfileCardContent","contractorId","onEvent","useI18n","t","useTranslation","Components","useComponentContext","profile","useContractorProfileSummary","isContractorLoading","contractor","isBusiness","CONTRACTOR_TYPE","legalName","firstLastName","startDate","formatDateLongWithYear","maskedSsn","maskedEin","emptyPlaceholder","profileItems","handleEdit","componentEvents","BaseLayout","Loading"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProfileCard.js","sources":["../../../../../../src/components/Contractor/Profile/management/ProfileCard/ProfileCard.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useContractorProfileSummary } from '../../shared/useContractorProfileSummary'\nimport { Loading } from '@/components/Common'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { formatDateLongWithYear } from '@/helpers/dateFormatting'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { useI18n } from '@/i18n'\nimport { componentEvents, CONTRACTOR_TYPE, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { LoaderComponentType } from '@/components/Base'\n\n/**\n * Props for {@link ProfileCard}.\n *\n * @public\n */\nexport interface ProfileCardProps {\n /** The associated contractor identifier. */\n contractorId: string\n /** Event handler fired when the user requests to edit the profile. */\n onEvent: OnEventType<EventType, unknown>\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n/**\n * Read-only card showing a contractor's basic profile details with an Edit action.\n *\n * @remarks\n * Standalone card that fetches its own data. Emits an event when the user\n * clicks Edit so the parent can switch to the edit form. The card does not\n * render success or error alerts itself — alert presentation is the\n * surrounding surface's responsibility.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/management/profile/editRequested` | Fired when the user clicks the Edit button | `{ contractorId: string }` |\n *\n * @param props - See {@link ProfileCardProps}.\n * @returns The basic-details profile card.\n * @public\n */\nexport function ProfileCard({ LoaderComponent, ...props }: ProfileCardProps) {\n return (\n <BaseBoundaries componentName=\"Contractor.Management.Profile\" LoaderComponent={LoaderComponent}>\n <ProfileCardContent LoaderComponent={LoaderComponent} {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction ProfileCardContent({ contractorId, onEvent, LoaderComponent }: ProfileCardProps) {\n useI18n('Contractor.Management.Profile')\n const { t } = useTranslation('Contractor.Management.Profile')\n const Components = useComponentContext()\n\n const profile = useContractorProfileSummary({ contractorId })\n\n const isContractorLoading = profile.isLoading\n\n const contractor = profile.isLoading ? undefined : profile.data.contractor\n\n const isBusiness = contractor?.type === CONTRACTOR_TYPE.BUSINESS\n\n const legalName = contractor\n ? isBusiness\n ? contractor.businessName\n : firstLastName({\n first_name: contractor.firstName,\n middle_initial: contractor.middleInitial,\n last_name: contractor.lastName,\n })\n : undefined\n const startDate = contractor ? formatDateLongWithYear(contractor.startDate) : undefined\n const maskedSsn = contractor?.hasSsn ? 'XXX-XX-XXXX' : undefined\n const maskedEin = contractor?.hasEin ? (contractor.ein ?? undefined) : undefined\n\n const emptyPlaceholder = <span aria-label={t('listEmptyPlaceholder')}>–</span>\n const profileItems = contractor\n ? [\n { term: t('legalName'), description: legalName || emptyPlaceholder },\n { term: t('startDate'), description: startDate || emptyPlaceholder },\n isBusiness\n ? {\n term: t('employerIdentificationNumber'),\n description: maskedEin || emptyPlaceholder,\n }\n : {\n term: t('socialSecurityNumber'),\n description: maskedSsn || emptyPlaceholder,\n },\n { term: t('email'), description: contractor.email || emptyPlaceholder },\n ]\n : []\n\n const handleEdit = () => {\n onEvent(componentEvents.CONTRACTOR_MANAGEMENT_PROFILE_EDIT_REQUESTED, { contractorId })\n }\n\n return (\n <BaseLayout error={profile.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <Components.Box\n header={\n <Components.BoxHeader\n title={t('title')}\n action={\n <Components.Button\n variant=\"secondary\"\n onClick={handleEdit}\n isDisabled={isContractorLoading}\n >\n {t('editCta')}\n </Components.Button>\n }\n />\n }\n >\n {isContractorLoading ? (\n <Loading />\n ) : contractor ? (\n <Components.DescriptionList items={profileItems} />\n ) : null}\n </Components.Box>\n </BaseLayout>\n )\n}\n"],"names":["ProfileCard","LoaderComponent","props","jsx","BaseBoundaries","ProfileCardContent","contractorId","onEvent","useI18n","t","useTranslation","Components","useComponentContext","profile","useContractorProfileSummary","isContractorLoading","contractor","isBusiness","CONTRACTOR_TYPE","legalName","firstLastName","startDate","formatDateLongWithYear","maskedSsn","maskedEin","emptyPlaceholder","profileItems","handleEdit","componentEvents","BaseLayout","Loading"],"mappings":";;;;;;;;;;AA4CO,SAASA,EAAY,EAAE,iBAAAC,GAAiB,GAAGC,KAA2B;AAC3E,SACE,gBAAAC,EAACC,GAAA,EAAe,eAAc,iCAAgC,iBAAAH,GAC5D,4BAACI,GAAA,EAAmB,iBAAAJ,GAAmC,GAAGC,EAAA,CAAO,EAAA,CACnE;AAEJ;AAEA,SAASG,EAAmB,EAAE,cAAAC,GAAc,SAAAC,GAAS,iBAAAN,KAAqC;AACxF,EAAAO,EAAQ,+BAA+B;AACvC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,+BAA+B,GACtDC,IAAaC,EAAA,GAEbC,IAAUC,EAA4B,EAAE,cAAAR,GAAc,GAEtDS,IAAsBF,EAAQ,WAE9BG,IAAaH,EAAQ,YAAY,SAAYA,EAAQ,KAAK,YAE1DI,IAAaD,GAAY,SAASE,EAAgB,UAElDC,IAAYH,IACdC,IACED,EAAW,eACXI,EAAc;AAAA,IACZ,YAAYJ,EAAW;AAAA,IACvB,gBAAgBA,EAAW;AAAA,IAC3B,WAAWA,EAAW;AAAA,EAAA,CACvB,IACH,QACEK,IAAYL,IAAaM,EAAuBN,EAAW,SAAS,IAAI,QACxEO,IAAYP,GAAY,SAAS,gBAAgB,QACjDQ,IAAYR,GAAY,SAAUA,EAAW,OAAO,SAAa,QAEjES,IAAmB,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scss.js";
|
|
7
7
|
import { BaseBoundaries as P, BaseLayout as N } from "../../../Base/Base.js";
|
|
8
8
|
import "../../../Base/useBase.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import { Grid as B } from "../../../Common/Grid/Grid.js";
|
|
10
|
+
import { ActionsLayout as U } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
11
|
+
import { Form as O } from "../../../Common/Form/Form.js";
|
|
12
|
+
import { SDKFormProvider as V } from "../../../../partner-hook-utils/form/SDKFormProvider.js";
|
|
13
|
+
import { useI18n as H, useComponentDictionary as Q } from "../../../../i18n/I18n.js";
|
|
14
|
+
import { CONTRACTOR_TYPE as w, componentEvents as I } from "../../../../shared/constants.js";
|
|
15
15
|
import { useComponentContext as v } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
16
16
|
function se({
|
|
17
17
|
FallbackComponent: o,
|
|
@@ -35,7 +35,7 @@ function x({
|
|
|
35
35
|
onEvent: c,
|
|
36
36
|
LoaderComponent: l
|
|
37
37
|
}) {
|
|
38
|
-
|
|
38
|
+
H("Contractor.Management.Profile"), Q("Contractor.Management.Profile", n);
|
|
39
39
|
const { t: e } = k("Contractor.Management.Profile"), f = v(), t = y({
|
|
40
40
|
contractorId: o,
|
|
41
41
|
withSelfOnboardingField: !1,
|
|
@@ -62,7 +62,7 @@ function x({
|
|
|
62
62
|
LoaderComponent: l
|
|
63
63
|
}
|
|
64
64
|
);
|
|
65
|
-
const L = m.type ===
|
|
65
|
+
const L = m.type === w.BUSINESS, i = t.form.Fields, { setValue: h } = t.form.hookFormInternals.formMethods, S = async () => {
|
|
66
66
|
u(!1);
|
|
67
67
|
const g = await t.actions.onSubmit();
|
|
68
68
|
g && (c(I.CONTRACTOR_MANAGEMENT_PROFILE_UPDATED, g.data), u(!0));
|
|
@@ -78,7 +78,7 @@ function x({
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
) : void 0;
|
|
81
|
-
return /* @__PURE__ */ a("section", { className: _(d.container, r), children: /* @__PURE__ */ a(N, { error: t.errorHandling.errors, LoaderComponent: l, children: /* @__PURE__ */ a(
|
|
81
|
+
return /* @__PURE__ */ a("section", { className: _(d.container, r), children: /* @__PURE__ */ a(N, { error: t.errorHandling.errors, LoaderComponent: l, children: /* @__PURE__ */ a(V, { formHookResult: t, children: /* @__PURE__ */ s(O, { onSubmit: S, children: [
|
|
82
82
|
T,
|
|
83
83
|
/* @__PURE__ */ a(f.Heading, { as: "h1", children: e("form.title") }),
|
|
84
84
|
L ? /* @__PURE__ */ s(p, { children: [
|
|
@@ -119,7 +119,7 @@ function x({
|
|
|
119
119
|
)
|
|
120
120
|
] }) : /* @__PURE__ */ s(p, { children: [
|
|
121
121
|
/* @__PURE__ */ s(
|
|
122
|
-
|
|
122
|
+
B,
|
|
123
123
|
{
|
|
124
124
|
gap: { base: 20, small: 8 },
|
|
125
125
|
gridTemplateColumns: { base: "1fr", small: ["1fr", 200] },
|
|
@@ -188,7 +188,7 @@ function x({
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
),
|
|
191
|
-
/* @__PURE__ */ s(
|
|
191
|
+
/* @__PURE__ */ s(U, { children: [
|
|
192
192
|
/* @__PURE__ */ a(f.Button, { variant: "secondary", onClick: A, type: "button", children: e("form.cancelCta") }),
|
|
193
193
|
/* @__PURE__ */ a(f.Button, { type: "submit", isLoading: t.status.isPending, children: e("form.saveCta") })
|
|
194
194
|
] })
|
|
@@ -4,8 +4,6 @@ import { useDeductionsList as A } from "../../shared/useDeductionsList.js";
|
|
|
4
4
|
import { useDeleteDeduction as P } from "../../shared/useDeleteDeduction.js";
|
|
5
5
|
import { DeleteDeductionDialog as N } from "../../shared/DeleteDeductionDialog.js";
|
|
6
6
|
import { formatDeductionAmount as S } from "../../shared/formatDeductionAmount.js";
|
|
7
|
-
import "classnames";
|
|
8
|
-
import { componentEvents as s } from "../../../../../shared/constants.js";
|
|
9
7
|
import { Loading as b } from "../../../../Common/Loading/Loading.js";
|
|
10
8
|
import { EmptyData as k } from "../../../../Common/EmptyData/EmptyData.js";
|
|
11
9
|
import { HamburgerMenu as x } from "../../../../Common/HamburgerMenu/HamburgerMenu.js";
|
|
@@ -13,33 +11,34 @@ import { BaseBoundaries as B, BaseLayout as U } from "../../../../Base/Base.js";
|
|
|
13
11
|
import { useComponentContext as w } from "../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
12
|
import u from "../../../../../hooks/useNumberFormatter.js";
|
|
15
13
|
import { useI18n as O } from "../../../../../i18n/I18n.js";
|
|
14
|
+
import { componentEvents as s } from "../../../../../shared/constants.js";
|
|
16
15
|
import v from "../../../../../assets/icons/plus-circle.svg.js";
|
|
17
16
|
import G from "../../../../../assets/icons/trashcan.svg.js";
|
|
18
17
|
import R from "../../../../../assets/icons/pencil.svg.js";
|
|
19
18
|
import { useDataView as H } from "../../../../Common/DataView/useDataView.js";
|
|
20
19
|
import { DataView as I } from "../../../../Common/DataView/DataView.js";
|
|
21
|
-
function
|
|
20
|
+
function de({ LoaderComponent: o, ...r }) {
|
|
22
21
|
return /* @__PURE__ */ i(
|
|
23
22
|
B,
|
|
24
23
|
{
|
|
25
24
|
componentName: "Employee.Management.Deductions",
|
|
26
|
-
LoaderComponent:
|
|
27
|
-
children: /* @__PURE__ */ i(j, { LoaderComponent:
|
|
25
|
+
LoaderComponent: o,
|
|
26
|
+
children: /* @__PURE__ */ i(j, { LoaderComponent: o, ...r })
|
|
28
27
|
}
|
|
29
28
|
);
|
|
30
29
|
}
|
|
31
|
-
function j({ employeeId:
|
|
30
|
+
function j({ employeeId: o, onEvent: r, LoaderComponent: D }) {
|
|
32
31
|
O("Employee.Management.Deductions");
|
|
33
|
-
const { t: e } = _("Employee.Management.Deductions"), d = w(), p = u("currency"), f = u("percent"),
|
|
32
|
+
const { t: e } = _("Employee.Management.Deductions"), d = w(), p = u("currency"), f = u("percent"), n = A({ employeeId: o }), {
|
|
34
33
|
pendingDeleteDeduction: c,
|
|
35
34
|
setPendingDeleteDeduction: m,
|
|
36
35
|
handleConfirmDelete: g
|
|
37
36
|
} = P(async (t) => {
|
|
38
|
-
if (
|
|
39
|
-
const a = await
|
|
37
|
+
if (n.isLoading) return;
|
|
38
|
+
const a = await n.actions.onDelete(t);
|
|
40
39
|
a && r(s.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_DELETED, a.data.garnishment);
|
|
41
|
-
}), E =
|
|
42
|
-
r(s.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_ADD_REQUESTED, { employeeId:
|
|
40
|
+
}), E = n.isLoading && n.errorHandling.errors.length === 0, C = n.isLoading ? [] : n.data.deductions, l = n.isLoading ? void 0 : n.status.deletingGarnishmentUuid, h = () => {
|
|
41
|
+
r(s.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_ADD_REQUESTED, { employeeId: o });
|
|
43
42
|
}, y = (t) => {
|
|
44
43
|
r(s.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_EDIT_REQUESTED, t);
|
|
45
44
|
}, L = [
|
|
@@ -91,7 +90,7 @@ function j({ employeeId: n, onEvent: r, LoaderComponent: D }) {
|
|
|
91
90
|
),
|
|
92
91
|
emptyState: () => /* @__PURE__ */ i(k, { title: e("emptyState.title"), description: e("emptyState.description") })
|
|
93
92
|
});
|
|
94
|
-
return /* @__PURE__ */ T(U, { error:
|
|
93
|
+
return /* @__PURE__ */ T(U, { error: n.errorHandling.errors, LoaderComponent: D, children: [
|
|
95
94
|
/* @__PURE__ */ i(
|
|
96
95
|
d.Box,
|
|
97
96
|
{
|
|
@@ -128,6 +127,6 @@ function j({ employeeId: n, onEvent: r, LoaderComponent: D }) {
|
|
|
128
127
|
] });
|
|
129
128
|
}
|
|
130
129
|
export {
|
|
131
|
-
|
|
130
|
+
de as DeductionsCard
|
|
132
131
|
};
|
|
133
132
|
//# sourceMappingURL=DeductionsCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeductionsCard.js","sources":["../../../../../../src/components/Employee/Deductions/management/DeductionsCard/DeductionsCard.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { useDeductionsList } from '../../shared/useDeductionsList'\nimport { useDeleteDeduction } from '../../shared/useDeleteDeduction'\nimport { DeleteDeductionDialog } from '../../shared/DeleteDeductionDialog'\nimport { formatDeductionAmount } from '../../shared/formatDeductionAmount'\nimport { DataView, useDataView, EmptyData, Loading } from '@/components/Common'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport useNumberFormatter from '@/hooks/useNumberFormatter'\nimport { useI18n } from '@/i18n'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { LoaderComponentType } from '@/components/Base'\nimport PlusCircleIcon from '@/assets/icons/plus-circle.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\n\n/**\n * Props for {@link DeductionsCard}.\n *\n * @public\n */\nexport interface DeductionsCardProps {\n /** The associated employee identifier. */\n employeeId: string\n /** Callback invoked when the card emits an event. See the events table on {@link DeductionsCard} for the available event types and payloads. */\n onEvent: OnEventType<EventType, unknown>\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n/**\n * Standalone read-only card listing an employee's active deductions, with affordances to add, edit, or delete a deduction.\n *\n * @remarks\n * Fetches its own data and owns the delete confirm dialog. Has no alert API — alert rendering is the consumer's responsibility. Add and edit affordances do not open a form themselves; emit-then-route is the contract, so the consumer listens for the `addRequested` / `editRequested` events and renders {@link DeductionsEditForm} (or its own equivalent) accordingly. For an orchestrated card-plus-form flow, use {@link Deductions} instead.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/deductions/card/addRequested` | Fired when the \"Add deduction\" CTA is clicked | `{ employeeId: string }` |\n * | `employee/management/deductions/card/editRequested` | Fired when an \"Edit\" CTA is clicked for a deduction | The matching `Garnishment` |\n * | `employee/management/deductions/card/deleted` | Fired after a deduction is deleted via the confirm dialog | The deleted `Garnishment` |\n *\n * @param props - See {@link DeductionsCardProps}.\n * @returns The rendered deductions card.\n * @public\n */\nexport function DeductionsCard({ LoaderComponent, ...props }: DeductionsCardProps) {\n return (\n <BaseBoundaries\n componentName=\"Employee.Management.Deductions\"\n LoaderComponent={LoaderComponent}\n >\n <DeductionsCardContent LoaderComponent={LoaderComponent} {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction DeductionsCardContent({ employeeId, onEvent, LoaderComponent }: DeductionsCardProps) {\n useI18n('Employee.Management.Deductions')\n const { t } = useTranslation('Employee.Management.Deductions')\n const Components = useComponentContext()\n const formatCurrency = useNumberFormatter('currency')\n const formatPercent = useNumberFormatter('percent')\n\n const deductionsList = useDeductionsList({ employeeId })\n\n const {\n pendingDeleteDeduction,\n setPendingDeleteDeduction,\n handleConfirmDelete: handleConfirmDeleteDeduction,\n } = useDeleteDeduction(async garnishment => {\n if (deductionsList.isLoading) return\n const result = await deductionsList.actions.onDelete(garnishment)\n if (result) {\n onEvent(componentEvents.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_DELETED, result.data.garnishment)\n }\n })\n\n // `useDeductionsList` returns `isLoading: true` even when the query has\n // errored and `data` is missing. Treat those rows as \"not loading\" so the\n // section doesn't show a perpetual skeleton while BaseLayout already\n // renders the error alert.\n const isDeductionsLoading =\n deductionsList.isLoading && deductionsList.errorHandling.errors.length === 0\n\n const deductions = deductionsList.isLoading ? [] : deductionsList.data.deductions\n const deletingGarnishmentUuid = deductionsList.isLoading\n ? undefined\n : deductionsList.status.deletingGarnishmentUuid\n\n const handleAdd = () => {\n onEvent(componentEvents.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_ADD_REQUESTED, { employeeId })\n }\n const handleEdit = (garnishment: Garnishment) => {\n onEvent(componentEvents.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_EDIT_REQUESTED, garnishment)\n }\n\n const garnishmentsColumns = [\n {\n key: 'description',\n title: t('columns.deduction'),\n render: (garnishment: Garnishment) => garnishment.description || '-',\n },\n {\n key: 'frequency',\n title: t('columns.frequency'),\n render: (garnishment: Garnishment) => (garnishment.recurring ? t('recurring') : t('oneTime')),\n },\n {\n key: 'amount',\n title: t('columns.withhold'),\n justify: 'end' as const,\n render: (garnishment: Garnishment) =>\n formatDeductionAmount(garnishment, {\n formatCurrency,\n formatPercent,\n formatPerPaycheck: (value: string) => t('amountPerPaycheck', { value }),\n }),\n },\n ]\n\n const garnishmentsDataView = useDataView({\n data: deductions,\n columns: garnishmentsColumns,\n itemMenu: (garnishment: Garnishment) => (\n <HamburgerMenu\n isLoading={deletingGarnishmentUuid === garnishment.uuid}\n items={[\n {\n label: t('editCta'),\n onClick: () => {\n handleEdit(garnishment)\n },\n icon: <PencilSvg aria-hidden />,\n },\n {\n label: t('deleteCta'),\n onClick: () => {\n setPendingDeleteDeduction(garnishment)\n },\n icon: <TrashCanSvg aria-hidden />,\n },\n ]}\n triggerLabel={t('hamburgerTitle')}\n />\n ),\n emptyState: () => (\n <EmptyData title={t('emptyState.title')} description={t('emptyState.description')} />\n ),\n })\n\n return (\n <BaseLayout error={deductionsList.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <Components.Box\n withPadding={false}\n header={\n <Components.BoxHeader\n title={t('title')}\n action={\n <Components.Button variant=\"secondary\" onClick={handleAdd} icon={<PlusCircleIcon />}>\n {t('addDeductionCta')}\n </Components.Button>\n }\n />\n }\n >\n {isDeductionsLoading ? (\n <Loading />\n ) : (\n <DataView label={t('listLabel')} isWithinBox {...garnishmentsDataView} />\n )}\n </Components.Box>\n\n <DeleteDeductionDialog\n pendingDeleteDeduction={pendingDeleteDeduction}\n isPrimaryActionLoading={deletingGarnishmentUuid === pendingDeleteDeduction?.uuid}\n onClose={() => {\n setPendingDeleteDeduction(null)\n }}\n onConfirm={() => {\n void handleConfirmDeleteDeduction()\n }}\n title={t('deleteDeductionDialog.title')}\n description={t('deleteDeductionDialog.description', {\n deduction: pendingDeleteDeduction?.description ?? '',\n })}\n confirmLabel={t('deleteDeductionDialog.confirmCta')}\n cancelLabel={t('deleteDeductionDialog.cancelCta')}\n />\n </BaseLayout>\n )\n}\n"],"names":["DeductionsCard","LoaderComponent","props","jsx","BaseBoundaries","DeductionsCardContent","employeeId","onEvent","useI18n","t","useTranslation","Components","useComponentContext","formatCurrency","useNumberFormatter","formatPercent","deductionsList","useDeductionsList","pendingDeleteDeduction","setPendingDeleteDeduction","handleConfirmDeleteDeduction","useDeleteDeduction","garnishment","result","componentEvents","isDeductionsLoading","deductions","deletingGarnishmentUuid","handleAdd","handleEdit","garnishmentsColumns","formatDeductionAmount","value","garnishmentsDataView","useDataView","HamburgerMenu","PencilSvg","TrashCanSvg","EmptyData","BaseLayout","PlusCircleIcon","Loading","DataView","DeleteDeductionDialog"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkDO,SAASA,GAAe,EAAE,iBAAAC,GAAiB,GAAGC,KAA8B;AACjF,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,eAAc;AAAA,MACd,iBAAAH;AAAA,MAEA,UAAA,gBAAAE,EAACE,GAAA,EAAsB,iBAAAJ,GAAmC,GAAGC,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAG1E;AAEA,SAASG,EAAsB,EAAE,YAAAC,GAAY,SAAAC,GAAS,iBAAAN,KAAwC;AAC5F,EAAAO,EAAQ,gCAAgC;AACxC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,gCAAgC,GACvDC,IAAaC,EAAA,GACbC,IAAiBC,EAAmB,UAA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gBAAAtC,EAACuC,GAAA,EAAS,OAAOjC,EAAE,WAAW,GAAG,aAAW,IAAE,GAAGwB,EAAA,CAAsB;AAAA,MAAA;AAAA,IAAA;AAAA,IAI3E,gBAAA9B;AAAA,MAACwC;AAAA,MAAA;AAAA,QACC,wBAAAzB;AAAA,QACA,wBAAwBS,MAA4BT,GAAwB;AAAA,QAC5E,SAAS,MAAM;AACb,UAAAC,EAA0B,IAAI;AAAA,QAChC;AAAA,QACA,WAAW,MAAM;AACf,UAAKC,EAAA;AAAA,QACP;AAAA,QACA,OAAOX,EAAE,6BAA6B;AAAA,QACtC,aAAaA,EAAE,qCAAqC;AAAA,UAClD,WAAWS,GAAwB,eAAe;AAAA,QAAA,CACnD;AAAA,QACD,cAAcT,EAAE,kCAAkC;AAAA,QAClD,aAAaA,EAAE,iCAAiC;AAAA,MAAA;AAAA,IAAA;AAAA,EAClD,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"DeductionsCard.js","sources":["../../../../../../src/components/Employee/Deductions/management/DeductionsCard/DeductionsCard.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { useDeductionsList } from '../../shared/useDeductionsList'\nimport { useDeleteDeduction } from '../../shared/useDeleteDeduction'\nimport { DeleteDeductionDialog } from '../../shared/DeleteDeductionDialog'\nimport { formatDeductionAmount } from '../../shared/formatDeductionAmount'\nimport { DataView, useDataView, EmptyData, Loading } from '@/components/Common'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport useNumberFormatter from '@/hooks/useNumberFormatter'\nimport { useI18n } from '@/i18n'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { LoaderComponentType } from '@/components/Base'\nimport PlusCircleIcon from '@/assets/icons/plus-circle.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\n\n/**\n * Props for {@link DeductionsCard}.\n *\n * @public\n */\nexport interface DeductionsCardProps {\n /** The associated employee identifier. */\n employeeId: string\n /** Callback invoked when the card emits an event. See the events table on {@link DeductionsCard} for the available event types and payloads. */\n onEvent: OnEventType<EventType, unknown>\n /** Custom loading indicator rendered while this component's async data is fetching. Overrides the indicator configured on `GustoProvider` for this instance only. */\n LoaderComponent?: LoaderComponentType\n}\n\n/**\n * Standalone read-only card listing an employee's active deductions, with affordances to add, edit, or delete a deduction.\n *\n * @remarks\n * Fetches its own data and owns the delete confirm dialog. Has no alert API — alert rendering is the consumer's responsibility. Add and edit affordances do not open a form themselves; emit-then-route is the contract, so the consumer listens for the `addRequested` / `editRequested` events and renders {@link DeductionsEditForm} (or its own equivalent) accordingly. For an orchestrated card-plus-form flow, use {@link Deductions} instead.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/deductions/card/addRequested` | Fired when the \"Add deduction\" CTA is clicked | `{ employeeId: string }` |\n * | `employee/management/deductions/card/editRequested` | Fired when an \"Edit\" CTA is clicked for a deduction | The matching `Garnishment` |\n * | `employee/management/deductions/card/deleted` | Fired after a deduction is deleted via the confirm dialog | The deleted `Garnishment` |\n *\n * @param props - See {@link DeductionsCardProps}.\n * @returns The rendered deductions card.\n * @public\n */\nexport function DeductionsCard({ LoaderComponent, ...props }: DeductionsCardProps) {\n return (\n <BaseBoundaries\n componentName=\"Employee.Management.Deductions\"\n LoaderComponent={LoaderComponent}\n >\n <DeductionsCardContent LoaderComponent={LoaderComponent} {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction DeductionsCardContent({ employeeId, onEvent, LoaderComponent }: DeductionsCardProps) {\n useI18n('Employee.Management.Deductions')\n const { t } = useTranslation('Employee.Management.Deductions')\n const Components = useComponentContext()\n const formatCurrency = useNumberFormatter('currency')\n const formatPercent = useNumberFormatter('percent')\n\n const deductionsList = useDeductionsList({ employeeId })\n\n const {\n pendingDeleteDeduction,\n setPendingDeleteDeduction,\n handleConfirmDelete: handleConfirmDeleteDeduction,\n } = useDeleteDeduction(async garnishment => {\n if (deductionsList.isLoading) return\n const result = await deductionsList.actions.onDelete(garnishment)\n if (result) {\n onEvent(componentEvents.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_DELETED, result.data.garnishment)\n }\n })\n\n // `useDeductionsList` returns `isLoading: true` even when the query has\n // errored and `data` is missing. Treat those rows as \"not loading\" so the\n // section doesn't show a perpetual skeleton while BaseLayout already\n // renders the error alert.\n const isDeductionsLoading =\n deductionsList.isLoading && deductionsList.errorHandling.errors.length === 0\n\n const deductions = deductionsList.isLoading ? [] : deductionsList.data.deductions\n const deletingGarnishmentUuid = deductionsList.isLoading\n ? undefined\n : deductionsList.status.deletingGarnishmentUuid\n\n const handleAdd = () => {\n onEvent(componentEvents.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_ADD_REQUESTED, { employeeId })\n }\n const handleEdit = (garnishment: Garnishment) => {\n onEvent(componentEvents.EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_EDIT_REQUESTED, garnishment)\n }\n\n const garnishmentsColumns = [\n {\n key: 'description',\n title: t('columns.deduction'),\n render: (garnishment: Garnishment) => garnishment.description || '-',\n },\n {\n key: 'frequency',\n title: t('columns.frequency'),\n render: (garnishment: Garnishment) => (garnishment.recurring ? t('recurring') : t('oneTime')),\n },\n {\n key: 'amount',\n title: t('columns.withhold'),\n justify: 'end' as const,\n render: (garnishment: Garnishment) =>\n formatDeductionAmount(garnishment, {\n formatCurrency,\n formatPercent,\n formatPerPaycheck: (value: string) => t('amountPerPaycheck', { value }),\n }),\n },\n ]\n\n const garnishmentsDataView = useDataView({\n data: deductions,\n columns: garnishmentsColumns,\n itemMenu: (garnishment: Garnishment) => (\n <HamburgerMenu\n isLoading={deletingGarnishmentUuid === garnishment.uuid}\n items={[\n {\n label: t('editCta'),\n onClick: () => {\n handleEdit(garnishment)\n },\n icon: <PencilSvg aria-hidden />,\n },\n {\n label: t('deleteCta'),\n onClick: () => {\n setPendingDeleteDeduction(garnishment)\n },\n icon: <TrashCanSvg aria-hidden />,\n },\n ]}\n triggerLabel={t('hamburgerTitle')}\n />\n ),\n emptyState: () => (\n <EmptyData title={t('emptyState.title')} description={t('emptyState.description')} />\n ),\n })\n\n return (\n <BaseLayout error={deductionsList.errorHandling.errors} LoaderComponent={LoaderComponent}>\n <Components.Box\n withPadding={false}\n header={\n <Components.BoxHeader\n title={t('title')}\n action={\n <Components.Button variant=\"secondary\" onClick={handleAdd} icon={<PlusCircleIcon />}>\n {t('addDeductionCta')}\n </Components.Button>\n }\n />\n }\n >\n {isDeductionsLoading ? (\n <Loading />\n ) : (\n <DataView label={t('listLabel')} isWithinBox {...garnishmentsDataView} />\n )}\n </Components.Box>\n\n <DeleteDeductionDialog\n pendingDeleteDeduction={pendingDeleteDeduction}\n isPrimaryActionLoading={deletingGarnishmentUuid === pendingDeleteDeduction?.uuid}\n onClose={() => {\n setPendingDeleteDeduction(null)\n }}\n onConfirm={() => {\n void handleConfirmDeleteDeduction()\n }}\n title={t('deleteDeductionDialog.title')}\n description={t('deleteDeductionDialog.description', {\n deduction: pendingDeleteDeduction?.description ?? '',\n })}\n confirmLabel={t('deleteDeductionDialog.confirmCta')}\n cancelLabel={t('deleteDeductionDialog.cancelCta')}\n />\n </BaseLayout>\n )\n}\n"],"names":["DeductionsCard","LoaderComponent","props","jsx","BaseBoundaries","DeductionsCardContent","employeeId","onEvent","useI18n","t","useTranslation","Components","useComponentContext","formatCurrency","useNumberFormatter","formatPercent","deductionsList","useDeductionsList","pendingDeleteDeduction","setPendingDeleteDeduction","handleConfirmDeleteDeduction","useDeleteDeduction","garnishment","result","componentEvents","isDeductionsLoading","deductions","deletingGarnishmentUuid","handleAdd","handleEdit","garnishmentsColumns","formatDeductionAmount","value","garnishmentsDataView","useDataView","HamburgerMenu","P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|
-
import { componentEvents as l } from "../../../../../shared/constants.js";
|
|
5
|
-
import { Loading as p } from "../../../../Common/Loading/Loading.js";
|
|
3
|
+
import { Loading as l } from "../../../../Common/Loading/Loading.js";
|
|
6
4
|
import { EmptyData as g } from "../../../../Common/EmptyData/EmptyData.js";
|
|
7
|
-
import { BaseBoundaries as
|
|
8
|
-
import { useComponentContext as
|
|
9
|
-
import { useI18n as
|
|
5
|
+
import { BaseBoundaries as p, BaseLayout as f } from "../../../../Base/Base.js";
|
|
6
|
+
import { useComponentContext as y } from "../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
|
+
import { useI18n as E } from "../../../../../i18n/I18n.js";
|
|
8
|
+
import { componentEvents as C } from "../../../../../shared/constants.js";
|
|
10
9
|
import { useDocumentsList as D } from "../../shared/useDocumentsList/useDocumentsList.js";
|
|
11
10
|
import { useDataView as S } from "../../../../Common/DataView/useDataView.js";
|
|
12
11
|
import { DataView as L } from "../../../../Common/DataView/DataView.js";
|
|
13
|
-
function
|
|
12
|
+
function A(o) {
|
|
14
13
|
return /* @__PURE__ */ e(
|
|
15
|
-
|
|
14
|
+
p,
|
|
16
15
|
{
|
|
17
16
|
componentName: "Employee.Management.Documents",
|
|
18
17
|
LoaderComponent: o.LoaderComponent,
|
|
@@ -21,8 +20,8 @@ function b(o) {
|
|
|
21
20
|
);
|
|
22
21
|
}
|
|
23
22
|
function h({ employeeId: o, onEvent: s, LoaderComponent: a }) {
|
|
24
|
-
|
|
25
|
-
const { t } = c("Employee.Management.Documents"), r =
|
|
23
|
+
E("Employee.Management.Documents");
|
|
24
|
+
const { t } = c("Employee.Management.Documents"), r = y(), i = D({ employeeId: o }), m = i.isLoading ? [] : i.data.forms, u = [
|
|
26
25
|
{
|
|
27
26
|
key: "title",
|
|
28
27
|
title: t("columns.title"),
|
|
@@ -51,7 +50,7 @@ function h({ employeeId: o, onEvent: s, LoaderComponent: a }) {
|
|
|
51
50
|
{
|
|
52
51
|
variant: "secondary",
|
|
53
52
|
onClick: () => {
|
|
54
|
-
s(
|
|
53
|
+
s(C.EMPLOYEE_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED, {
|
|
55
54
|
employeeId: o,
|
|
56
55
|
formId: n.uuid
|
|
57
56
|
});
|
|
@@ -61,9 +60,9 @@ function h({ employeeId: o, onEvent: s, LoaderComponent: a }) {
|
|
|
61
60
|
),
|
|
62
61
|
emptyState: () => /* @__PURE__ */ e(g, { title: t("emptyState.title"), description: t("emptyState.description") })
|
|
63
62
|
});
|
|
64
|
-
return /* @__PURE__ */ e(
|
|
63
|
+
return /* @__PURE__ */ e(f, { error: i.errorHandling.errors, LoaderComponent: a, children: /* @__PURE__ */ e(r.Box, { withPadding: !1, header: /* @__PURE__ */ e(r.BoxHeader, { title: t("title") }), children: i.isLoading ? /* @__PURE__ */ e(l, {}) : /* @__PURE__ */ e(L, { label: t("listLabel"), isWithinBox: !0, ...d }) }) });
|
|
65
64
|
}
|
|
66
65
|
export {
|
|
67
|
-
|
|
66
|
+
A as DocumentsCard
|
|
68
67
|
};
|
|
69
68
|
//# sourceMappingURL=DocumentsCard.js.map
|