@cwellt_software/shared-employee 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/AccountingRulesTab-CdYj-dz8.js +84 -0
  2. package/dist/AccountingRulesTab-DQJ7nD71.cjs +1 -0
  3. package/dist/AdditionalInfoTab-DW-S373w.cjs +1 -0
  4. package/dist/AdditionalInfoTab-j-Ixuvog.js +114 -0
  5. package/dist/App.d.ts +3 -0
  6. package/dist/ChangeRequestsTab-CFCWKZkt.js +342 -0
  7. package/dist/ChangeRequestsTab-CY7-qObu.cjs +1 -0
  8. package/dist/CosmicRadiationTab-6fqnDLH3.cjs +1 -0
  9. package/dist/CosmicRadiationTab-CLlfjJNA.js +120 -0
  10. package/dist/DeleteDialog-BqXtjGGi.cjs +1 -0
  11. package/dist/DeleteDialog-CyRsLr_c.js +21 -0
  12. package/dist/DetailsTab-DKFAMvlW.cjs +1 -0
  13. package/dist/DetailsTab-Dh1lfSr2.js +248 -0
  14. package/dist/DivisionsTab--eEVFupH.cjs +1 -0
  15. package/dist/DivisionsTab-BfIIZ_ld.js +86 -0
  16. package/dist/FunctionsTab-BMWoqfK2.js +160 -0
  17. package/dist/FunctionsTab-DQPsK0rq.cjs +1 -0
  18. package/dist/HistoryTab-CViMxBYc.cjs +1 -0
  19. package/dist/HistoryTab-CwCD46f3.js +277 -0
  20. package/dist/LanguagesTab-BKa7nmoT.cjs +1 -0
  21. package/dist/LanguagesTab-BznJDDXK.js +181 -0
  22. package/dist/RelatedPersonsTab-C-6ti_Be.js +260 -0
  23. package/dist/RelatedPersonsTab-DgoBLK21.cjs +1 -0
  24. package/dist/VaccinesTab-BGhy3EgY.cjs +1 -0
  25. package/dist/VaccinesTab-BtdAXAyo.js +171 -0
  26. package/dist/context/DialogShellContext.d.ts +22 -0
  27. package/dist/dateUtils-BULQTXVb.cjs +1 -0
  28. package/dist/dateUtils-CTu1RDq1.js +25 -0
  29. package/dist/domain/model/ChangeRequest.d.ts +23 -0
  30. package/dist/domain/model/Dietary.d.ts +24 -0
  31. package/dist/domain/model/EmployeeDetail.d.ts +89 -0
  32. package/dist/domain/model/EmployeeDropdowns.d.ts +31 -0
  33. package/dist/domain/model/EmployeeListItem.d.ts +15 -0
  34. package/dist/domain/model/EmployeeTabModels.d.ts +91 -0
  35. package/dist/domain/repository/DietaryRepository.d.ts +8 -0
  36. package/dist/domain/repository/EmployeeRepository.d.ts +62 -0
  37. package/dist/index.d.ts +18 -0
  38. package/dist/infrastructure/DietaryRepositoryImpl.d.ts +20 -0
  39. package/dist/infrastructure/EmployeeRepositoryImpl.d.ts +74 -0
  40. package/dist/infrastructure/dto/DietaryDto.d.ts +26 -0
  41. package/dist/main.d.ts +1 -0
  42. package/dist/presentation/EmployeeOverview.d.ts +18 -0
  43. package/dist/presentation/common/DeleteDialog.d.ts +16 -0
  44. package/dist/presentation/common/EmptyState.d.ts +11 -0
  45. package/dist/presentation/common/LazyImage.d.ts +15 -0
  46. package/dist/presentation/common/useLazyTabs.d.ts +14 -0
  47. package/dist/presentation/comps/modals/AddEmployeeModal.d.ts +10 -0
  48. package/dist/presentation/comps/modals/EditEmployeeModal.d.ts +13 -0
  49. package/dist/presentation/comps/tabs/AccountingRulesTab.d.ts +10 -0
  50. package/dist/presentation/comps/tabs/AdditionalInfoTab.d.ts +12 -0
  51. package/dist/presentation/comps/tabs/ChangeRequestsTab.d.ts +16 -0
  52. package/dist/presentation/comps/tabs/CosmicRadiationTab.d.ts +8 -0
  53. package/dist/presentation/comps/tabs/DetailsTab.d.ts +8 -0
  54. package/dist/presentation/comps/tabs/DivisionsTab.d.ts +11 -0
  55. package/dist/presentation/comps/tabs/FunctionsTab.d.ts +13 -0
  56. package/dist/presentation/comps/tabs/HistoryTab.d.ts +15 -0
  57. package/dist/presentation/comps/tabs/LanguagesTab.d.ts +13 -0
  58. package/dist/presentation/comps/tabs/RelatedPersonsTab.d.ts +13 -0
  59. package/dist/presentation/comps/tabs/VaccinesTab.d.ts +12 -0
  60. package/dist/presentation/dietary/DietaryPage.d.ts +9 -0
  61. package/dist/presentation/dietary/comps/DietaryEntryDialog.d.ts +13 -0
  62. package/dist/presentation/dietary/comps/DietarySection.d.ts +8 -0
  63. package/dist/presentation/dietary/hooks/useDietary.d.ts +12 -0
  64. package/dist/presentation/dietary/parsers/catalogSuggestions.d.ts +12 -0
  65. package/dist/presentation/hooks/data/useChangeRequests.d.ts +17 -0
  66. package/dist/presentation/hooks/data/useEmployeeData.d.ts +79 -0
  67. package/dist/presentation/hooks/data/useEmployeeFilters.d.ts +10 -0
  68. package/dist/presentation/hooks/ui/useEmployeeOverviewUI.d.ts +15 -0
  69. package/dist/presentation/parsers/dateUtils.d.ts +12 -0
  70. package/dist/presentation/parsers/employeeParsers.d.ts +3 -0
  71. package/dist/presentation/parsers/imageUtils.d.ts +1 -0
  72. package/dist/shared-employee.cjs.js +1 -0
  73. package/dist/shared-employee.css +2 -0
  74. package/dist/shared-employee.es.js +2592 -0
  75. package/package.json +58 -0
@@ -0,0 +1,84 @@
1
+ import { t as e } from "./DeleteDialog-CyRsLr_c.js";
2
+ import { CwButton as t, CwChip as n, CwTable as r } from "@cwellt_software/cwellt-reactjs-lib";
3
+ import { useState as i } from "react";
4
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
+ //#region src/presentation/comps/tabs/AccountingRulesTab.tsx
6
+ function s({ items: s, employeeId: c, availableRuleSets: l, onAssign: u, onRemove: d }) {
7
+ let [f, p] = i(null), m = new Set(s.map((e) => e.ruleId));
8
+ return /* @__PURE__ */ o("div", {
9
+ className: "cw-grid-base-auto cw-gap-medium",
10
+ children: [
11
+ /* @__PURE__ */ o("section", { children: [/* @__PURE__ */ a("h4", {
12
+ className: "cw-margin-bottom-small",
13
+ children: "Assigned Rules"
14
+ }), /* @__PURE__ */ a(r, {
15
+ columns: [
16
+ {
17
+ key: "actions",
18
+ title: "",
19
+ className: "cw-table-col-action cw-table-col-buttons",
20
+ render: (e) => /* @__PURE__ */ a(t, {
21
+ variant: "icon",
22
+ icon: "delete",
23
+ color: "danger",
24
+ onClick: () => p(e),
25
+ "data-testid": `tab-accountingRules-row-${e.id}-delete`
26
+ })
27
+ },
28
+ {
29
+ key: "ruleSetName",
30
+ title: "Rule Set",
31
+ dataIndex: "ruleSetName"
32
+ },
33
+ {
34
+ key: "ruleName",
35
+ title: "Rule",
36
+ dataIndex: "ruleName",
37
+ render: (e) => /* @__PURE__ */ a("span", {
38
+ "data-testid": `tab-accountingRules-row-${e.id}`,
39
+ children: e.ruleName
40
+ })
41
+ }
42
+ ],
43
+ data: s,
44
+ rowKey: "id"
45
+ })] }),
46
+ /* @__PURE__ */ o("section", { children: [/* @__PURE__ */ a("h4", {
47
+ className: "cw-margin-bottom-small",
48
+ children: "Available Rules"
49
+ }), l.map((e) => /* @__PURE__ */ o("div", {
50
+ className: "cw-margin-bottom-regular",
51
+ children: [/* @__PURE__ */ a("p", {
52
+ className: "cw-margin-bottom-small",
53
+ children: /* @__PURE__ */ a("strong", { children: e.name })
54
+ }), /* @__PURE__ */ a("div", {
55
+ className: "cw-flex-row cw-gap-tiny cw-flex-wrap",
56
+ children: e.rules.map((e) => m.has(e.id) ? /* @__PURE__ */ a(n, {
57
+ label: e.name,
58
+ colorScheme: "success"
59
+ }, e.id) : /* @__PURE__ */ a("span", {
60
+ role: "button",
61
+ style: { cursor: "pointer" },
62
+ onClick: () => u(c, e.id),
63
+ "data-testid": `tab-accountingRules-available-${e.id}`,
64
+ children: /* @__PURE__ */ a(n, {
65
+ label: e.name,
66
+ colorScheme: "neutral"
67
+ })
68
+ }, e.id))
69
+ })]
70
+ }, e.id))] }),
71
+ f && /* @__PURE__ */ a(e, {
72
+ open: !0,
73
+ headline: "Remove Rule",
74
+ message: `Remove "${f.ruleName}"?`,
75
+ onDelete: async () => {
76
+ await d(c, f.ruleId), p(null);
77
+ },
78
+ onClose: () => p(null)
79
+ })
80
+ ]
81
+ });
82
+ }
83
+ //#endregion
84
+ export { s as AccountingRulesTab };
@@ -0,0 +1 @@
1
+ const e=require("./DeleteDialog-BqXtjGGi.cjs");let t=require("@cwellt_software/cwellt-reactjs-lib"),n=require("react"),r=require("react/jsx-runtime");function i({items:i,employeeId:a,availableRuleSets:o,onAssign:s,onRemove:c}){let[l,u]=(0,n.useState)(null),d=new Set(i.map(e=>e.ruleId));return(0,r.jsxs)(`div`,{className:`cw-grid-base-auto cw-gap-medium`,children:[(0,r.jsxs)(`section`,{children:[(0,r.jsx)(`h4`,{className:`cw-margin-bottom-small`,children:`Assigned Rules`}),(0,r.jsx)(t.CwTable,{columns:[{key:`actions`,title:``,className:`cw-table-col-action cw-table-col-buttons`,render:e=>(0,r.jsx)(t.CwButton,{variant:`icon`,icon:`delete`,color:`danger`,onClick:()=>u(e),"data-testid":`tab-accountingRules-row-${e.id}-delete`})},{key:`ruleSetName`,title:`Rule Set`,dataIndex:`ruleSetName`},{key:`ruleName`,title:`Rule`,dataIndex:`ruleName`,render:e=>(0,r.jsx)(`span`,{"data-testid":`tab-accountingRules-row-${e.id}`,children:e.ruleName})}],data:i,rowKey:`id`})]}),(0,r.jsxs)(`section`,{children:[(0,r.jsx)(`h4`,{className:`cw-margin-bottom-small`,children:`Available Rules`}),o.map(e=>(0,r.jsxs)(`div`,{className:`cw-margin-bottom-regular`,children:[(0,r.jsx)(`p`,{className:`cw-margin-bottom-small`,children:(0,r.jsx)(`strong`,{children:e.name})}),(0,r.jsx)(`div`,{className:`cw-flex-row cw-gap-tiny cw-flex-wrap`,children:e.rules.map(e=>d.has(e.id)?(0,r.jsx)(t.CwChip,{label:e.name,colorScheme:`success`},e.id):(0,r.jsx)(`span`,{role:`button`,style:{cursor:`pointer`},onClick:()=>s(a,e.id),"data-testid":`tab-accountingRules-available-${e.id}`,children:(0,r.jsx)(t.CwChip,{label:e.name,colorScheme:`neutral`})},e.id))})]},e.id))]}),l&&(0,r.jsx)(e.t,{open:!0,headline:`Remove Rule`,message:`Remove "${l.ruleName}"?`,onDelete:async()=>{await c(a,l.ruleId),u(null)},onClose:()=>u(null)})]})}exports.AccountingRulesTab=i;
@@ -0,0 +1 @@
1
+ const e=require("./DeleteDialog-BqXtjGGi.cjs");let t=require("@cwellt_software/cwellt-reactjs-lib"),n=require("react"),r=require("react/jsx-runtime");function i({items:i,employeeId:a,contactTypes:o,onCreate:s,onUpdate:c,onDelete:l}){let[u,d]=(0,n.useState)(!1),[f,p]=(0,n.useState)(null),[m,h]=(0,n.useState)(null),[g,_]=(0,n.useState)(null),[v,y]=(0,n.useState)(``),b=new Set(i.map(e=>e.contactTypeId)),x=f?o:o.filter(e=>!b.has(e.id)),S=()=>{p(null),_(null),y(``),d(!0)},C=e=>{p(e),_(e.contactTypeId),y(e.value),d(!0)};return(0,r.jsxs)(`section`,{children:[(0,r.jsx)(`header`,{className:`cw-flex-row cw-margin-bottom-small`,children:(0,r.jsx)(t.CwButton,{text:`Add`,icon:`plus`,onClick:S,"data-testid":`tab-additionalInfo-add-button`})}),(0,r.jsx)(t.CwTable,{columns:[{key:`actions`,title:``,className:`cw-table-col-action cw-table-col-buttons`,render:e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.CwButton,{variant:`icon`,icon:`edit`,onClick:()=>C(e),"data-testid":`tab-additionalInfo-row-${e.contactTypeName}-edit`}),(0,r.jsx)(t.CwButton,{variant:`icon`,icon:`delete`,color:`danger`,onClick:()=>h(e),"data-testid":`tab-additionalInfo-row-${e.contactTypeName}-delete`})]})},{key:`contactTypeName`,title:`Field`,dataIndex:`contactTypeName`,render:e=>(0,r.jsx)(`span`,{"data-testid":`tab-additionalInfo-row-${e.contactTypeName}`,children:e.contactTypeName})},{key:`value`,title:`Details`,dataIndex:`value`}],data:i,rowKey:`id`}),u&&(0,r.jsx)(t.CwDialog,{open:!0,headline:f?`Edit Contact Info`:`Add Contact Info`,onClose:()=>d(!1),onSave:async()=>{if(g)try{f?await c({...f,contactTypeId:g,value:v}):await s({contactTypeId:g,value:v,employeeId:a}),d(!1)}catch{(0,t.CwDisplayMessage)(`Failed to save`,t.CwMessageType.ERROR,5e3)}},disableSave:!g,width:`30rem`,children:(0,r.jsxs)(`div`,{className:`cw-flex-column`,"data-label-width":`8rem`,children:[(0,r.jsx)(t.CwSelect,{labelProps:{text:`Type`},value:g==null?``:String(g),onChange:e=>_(e.currentTarget.value?Number(e.currentTarget.value):null),disabled:!!f,placeholder:`Select...`,"data-testid":`tab-additionalInfo-form-type`,children:x.map(e=>(0,r.jsx)(t.CwOption,{value:e.id,children:e.name},e.id))}),(0,r.jsx)(t.CwInputText,{labelProps:{text:`Value`},value:v,onChange:e=>y(e.currentTarget.value),"data-testid":`tab-additionalInfo-form-value`})]})}),m&&(0,r.jsx)(e.t,{open:!0,headline:`Delete Contact Info`,message:`Delete "${m.contactTypeName}" from this employee?`,onDelete:async()=>{await l(a,m.contactTypeId),h(null)},onClose:()=>h(null)})]})}exports.AdditionalInfoTab=i;
@@ -0,0 +1,114 @@
1
+ import { t as e } from "./DeleteDialog-CyRsLr_c.js";
2
+ import { CwButton as t, CwDialog as n, CwDisplayMessage as r, CwInputText as i, CwMessageType as a, CwOption as o, CwSelect as s, CwTable as c } from "@cwellt_software/cwellt-reactjs-lib";
3
+ import { useState as l } from "react";
4
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
5
+ //#region src/presentation/comps/tabs/AdditionalInfoTab.tsx
6
+ function p({ items: p, employeeId: m, contactTypes: h, onCreate: g, onUpdate: _, onDelete: v }) {
7
+ let [y, b] = l(!1), [x, S] = l(null), [C, w] = l(null), [T, E] = l(null), [D, O] = l(""), k = new Set(p.map((e) => e.contactTypeId)), A = x ? h : h.filter((e) => !k.has(e.id)), j = () => {
8
+ S(null), E(null), O(""), b(!0);
9
+ }, M = (e) => {
10
+ S(e), E(e.contactTypeId), O(e.value), b(!0);
11
+ };
12
+ return /* @__PURE__ */ f("section", { children: [
13
+ /* @__PURE__ */ d("header", {
14
+ className: "cw-flex-row cw-margin-bottom-small",
15
+ children: /* @__PURE__ */ d(t, {
16
+ text: "Add",
17
+ icon: "plus",
18
+ onClick: j,
19
+ "data-testid": "tab-additionalInfo-add-button"
20
+ })
21
+ }),
22
+ /* @__PURE__ */ d(c, {
23
+ columns: [
24
+ {
25
+ key: "actions",
26
+ title: "",
27
+ className: "cw-table-col-action cw-table-col-buttons",
28
+ render: (e) => /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(t, {
29
+ variant: "icon",
30
+ icon: "edit",
31
+ onClick: () => M(e),
32
+ "data-testid": `tab-additionalInfo-row-${e.contactTypeName}-edit`
33
+ }), /* @__PURE__ */ d(t, {
34
+ variant: "icon",
35
+ icon: "delete",
36
+ color: "danger",
37
+ onClick: () => w(e),
38
+ "data-testid": `tab-additionalInfo-row-${e.contactTypeName}-delete`
39
+ })] })
40
+ },
41
+ {
42
+ key: "contactTypeName",
43
+ title: "Field",
44
+ dataIndex: "contactTypeName",
45
+ render: (e) => /* @__PURE__ */ d("span", {
46
+ "data-testid": `tab-additionalInfo-row-${e.contactTypeName}`,
47
+ children: e.contactTypeName
48
+ })
49
+ },
50
+ {
51
+ key: "value",
52
+ title: "Details",
53
+ dataIndex: "value"
54
+ }
55
+ ],
56
+ data: p,
57
+ rowKey: "id"
58
+ }),
59
+ y && /* @__PURE__ */ d(n, {
60
+ open: !0,
61
+ headline: x ? "Edit Contact Info" : "Add Contact Info",
62
+ onClose: () => b(!1),
63
+ onSave: async () => {
64
+ if (T) try {
65
+ x ? await _({
66
+ ...x,
67
+ contactTypeId: T,
68
+ value: D
69
+ }) : await g({
70
+ contactTypeId: T,
71
+ value: D,
72
+ employeeId: m
73
+ }), b(!1);
74
+ } catch {
75
+ r("Failed to save", a.ERROR, 5e3);
76
+ }
77
+ },
78
+ disableSave: !T,
79
+ width: "30rem",
80
+ children: /* @__PURE__ */ f("div", {
81
+ className: "cw-flex-column",
82
+ "data-label-width": "8rem",
83
+ children: [/* @__PURE__ */ d(s, {
84
+ labelProps: { text: "Type" },
85
+ value: T == null ? "" : String(T),
86
+ onChange: (e) => E(e.currentTarget.value ? Number(e.currentTarget.value) : null),
87
+ disabled: !!x,
88
+ placeholder: "Select...",
89
+ "data-testid": "tab-additionalInfo-form-type",
90
+ children: A.map((e) => /* @__PURE__ */ d(o, {
91
+ value: e.id,
92
+ children: e.name
93
+ }, e.id))
94
+ }), /* @__PURE__ */ d(i, {
95
+ labelProps: { text: "Value" },
96
+ value: D,
97
+ onChange: (e) => O(e.currentTarget.value),
98
+ "data-testid": "tab-additionalInfo-form-value"
99
+ })]
100
+ })
101
+ }),
102
+ C && /* @__PURE__ */ d(e, {
103
+ open: !0,
104
+ headline: "Delete Contact Info",
105
+ message: `Delete "${C.contactTypeName}" from this employee?`,
106
+ onDelete: async () => {
107
+ await v(m, C.contactTypeId), w(null);
108
+ },
109
+ onClose: () => w(null)
110
+ })
111
+ ] });
112
+ }
113
+ //#endregion
114
+ export { p as AdditionalInfoTab };
package/dist/App.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import './App.css';
2
+ declare function App(): import("react").JSX.Element;
3
+ export default App;
@@ -0,0 +1,342 @@
1
+ import { CwButton as e, CwChip as t, CwDisplayMessage as n, CwInputText as r, CwLoading as i, CwMessageType as a, CwTable as o } from "@cwellt_software/cwellt-reactjs-lib";
2
+ import { useState as s } from "react";
3
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
4
+ var d = {
5
+ requestCard: "_requestCard_io5wq_1",
6
+ requestHeader: "_requestHeader_io5wq_9",
7
+ photoCompare: "_photoCompare_io5wq_16",
8
+ photoBox: "_photoBox_io5wq_22",
9
+ placeholder: "_placeholder_io5wq_33",
10
+ rejectInput: "_rejectInput_io5wq_44",
11
+ historySection: "_historySection_io5wq_53",
12
+ historySummary: "_historySummary_io5wq_57"
13
+ };
14
+ //#endregion
15
+ //#region src/presentation/comps/tabs/ChangeRequestsTab.tsx
16
+ function f(e) {
17
+ return /* @__PURE__ */ l(t, {
18
+ label: e,
19
+ colorScheme: e === "Approved" ? "success" : e === "Rejected" ? "danger" : e === "Superseded" ? "neutral" : "warning"
20
+ });
21
+ }
22
+ function p({ request: t, employeeId: i, onReviewFields: p, onApproveAll: m }) {
23
+ let [h, g] = s(null), [_, v] = s(""), [y, b] = s(!1), x = t.fields.filter((e) => e.status === "Pending"), S = x.length > 0, C = async (e) => {
24
+ b(!0);
25
+ try {
26
+ await p(t.id, [{
27
+ changeFieldId: e.changeFieldId,
28
+ approved: !0
29
+ }], i);
30
+ } catch {
31
+ n("Failed to approve field", a.ERROR, 5e3);
32
+ } finally {
33
+ b(!1);
34
+ }
35
+ }, w = async (e) => {
36
+ if (h !== e.changeFieldId) {
37
+ g(e.changeFieldId), v("");
38
+ return;
39
+ }
40
+ b(!0);
41
+ try {
42
+ await p(t.id, [{
43
+ changeFieldId: e.changeFieldId,
44
+ approved: !1,
45
+ comment: _ || void 0
46
+ }], i), g(null), v("");
47
+ } catch {
48
+ n("Failed to reject field", a.ERROR, 5e3);
49
+ } finally {
50
+ b(!1);
51
+ }
52
+ }, T = async () => {
53
+ b(!0);
54
+ try {
55
+ await m(t.id, i);
56
+ } catch {
57
+ n("Failed to approve all fields", a.ERROR, 5e3);
58
+ } finally {
59
+ b(!1);
60
+ }
61
+ }, E = async () => {
62
+ b(!0);
63
+ try {
64
+ await p(t.id, x.map((e) => ({
65
+ changeFieldId: e.changeFieldId,
66
+ approved: !1
67
+ })), i);
68
+ } catch {
69
+ n("Failed to reject all fields", a.ERROR, 5e3);
70
+ } finally {
71
+ b(!1);
72
+ }
73
+ }, D = [
74
+ ...S ? [{
75
+ key: "actions",
76
+ title: "",
77
+ className: "cw-table-col-small",
78
+ render: (t) => t.status === "Pending" ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(e, {
79
+ variant: "icon",
80
+ icon: "check-small",
81
+ color: "primary",
82
+ title: "Approve",
83
+ onClick: () => C(t),
84
+ disabled: y
85
+ }), /* @__PURE__ */ l(e, {
86
+ variant: "icon",
87
+ icon: "close",
88
+ color: "danger",
89
+ title: "Reject",
90
+ onClick: () => w(t),
91
+ disabled: y
92
+ })] }) : null
93
+ }] : [],
94
+ {
95
+ key: "fieldName",
96
+ title: "Field",
97
+ dataIndex: "fieldName",
98
+ className: "cw-table-col-medium"
99
+ },
100
+ {
101
+ key: "oldValue",
102
+ title: "Current",
103
+ dataIndex: "oldValue",
104
+ className: "cw-table-col-grow"
105
+ },
106
+ {
107
+ key: "newValue",
108
+ title: "Requested",
109
+ dataIndex: "newValue",
110
+ className: "cw-table-col-grow"
111
+ },
112
+ {
113
+ key: "status",
114
+ title: "Status",
115
+ className: "cw-table-col-small",
116
+ render: (e) => f(e.status)
117
+ },
118
+ ...S ? [] : [{
119
+ key: "reviewedBy",
120
+ title: "Reviewed By",
121
+ dataIndex: "reviewedBy",
122
+ className: "cw-table-col-medium"
123
+ }, {
124
+ key: "reviewedAt",
125
+ title: "Reviewed At",
126
+ className: "cw-table-col-medium",
127
+ render: (e) => e.reviewedAt ? new Date(e.reviewedAt).toLocaleString() : null
128
+ }]
129
+ ];
130
+ return /* @__PURE__ */ u("div", {
131
+ className: d.requestCard,
132
+ children: [
133
+ /* @__PURE__ */ u("div", {
134
+ className: d.requestHeader,
135
+ children: [/* @__PURE__ */ u("div", {
136
+ className: "cw-flex-column cw-gap-tiny",
137
+ children: [/* @__PURE__ */ u("span", {
138
+ className: "cw-font-size-small cw-color-neutral",
139
+ children: [
140
+ "Submitted by ",
141
+ t.requestedBy,
142
+ " · ",
143
+ new Date(t.requestedAt).toLocaleString()
144
+ ]
145
+ }), f(t.status)]
146
+ }), S && /* @__PURE__ */ u("div", {
147
+ className: "cw-flex-row cw-gap-dense",
148
+ children: [/* @__PURE__ */ l(e, {
149
+ text: "Reject All",
150
+ icon: "close",
151
+ color: "danger",
152
+ onClick: E,
153
+ disabled: y
154
+ }), /* @__PURE__ */ l(e, {
155
+ text: "Approve All",
156
+ icon: "check-small",
157
+ onClick: T,
158
+ disabled: y
159
+ })]
160
+ })]
161
+ }),
162
+ /* @__PURE__ */ l(o, {
163
+ columns: D,
164
+ data: t.fields,
165
+ rowKey: "changeFieldId"
166
+ }),
167
+ h !== null && /* @__PURE__ */ u("div", {
168
+ className: d.rejectInput,
169
+ children: [
170
+ /* @__PURE__ */ l(r, {
171
+ labelProps: { text: "Rejection reason" },
172
+ value: _,
173
+ onChange: (e) => v(e.currentTarget.value),
174
+ placeholder: "Optional comment..."
175
+ }),
176
+ /* @__PURE__ */ l(e, {
177
+ text: "Confirm Reject",
178
+ color: "danger",
179
+ onClick: () => {
180
+ let e = t.fields.find((e) => e.changeFieldId === h);
181
+ e && w(e);
182
+ },
183
+ disabled: y
184
+ }),
185
+ /* @__PURE__ */ l(e, {
186
+ text: "Cancel",
187
+ variant: "outline",
188
+ onClick: () => g(null)
189
+ })
190
+ ]
191
+ })
192
+ ]
193
+ });
194
+ }
195
+ function m({ request: t, employeeId: i, currentImage: o, onReviewPhoto: c }) {
196
+ let [p, m] = s(""), [h, g] = s(!1), [_, v] = s(!1), y = t.status === "Pending", b = async () => {
197
+ v(!0);
198
+ try {
199
+ await c(t.id, !0, i);
200
+ } catch {
201
+ n("Failed to approve photo", a.ERROR, 5e3);
202
+ } finally {
203
+ v(!1);
204
+ }
205
+ }, x = async () => {
206
+ if (!h) {
207
+ g(!0);
208
+ return;
209
+ }
210
+ v(!0);
211
+ try {
212
+ await c(t.id, !1, i, p || void 0), g(!1);
213
+ } catch {
214
+ n("Failed to reject photo", a.ERROR, 5e3);
215
+ } finally {
216
+ v(!1);
217
+ }
218
+ };
219
+ return /* @__PURE__ */ u("div", {
220
+ className: d.requestCard,
221
+ children: [
222
+ /* @__PURE__ */ l("div", {
223
+ className: d.requestHeader,
224
+ children: /* @__PURE__ */ u("div", {
225
+ className: "cw-flex-column cw-gap-tiny",
226
+ children: [/* @__PURE__ */ u("span", {
227
+ className: "cw-font-size-small cw-color-neutral",
228
+ children: [
229
+ "Submitted by ",
230
+ t.requestedBy,
231
+ " · ",
232
+ new Date(t.requestedAt).toLocaleString()
233
+ ]
234
+ }), f(t.status)]
235
+ })
236
+ }),
237
+ /* @__PURE__ */ u("div", {
238
+ className: d.photoCompare,
239
+ children: [/* @__PURE__ */ u("div", {
240
+ className: d.photoBox,
241
+ children: [/* @__PURE__ */ l("h5", { children: "Current" }), o ? /* @__PURE__ */ l("img", {
242
+ src: o,
243
+ alt: "Current"
244
+ }) : /* @__PURE__ */ l("div", {
245
+ className: d.placeholder,
246
+ children: "No photo"
247
+ })]
248
+ }), /* @__PURE__ */ u("div", {
249
+ className: d.photoBox,
250
+ children: [/* @__PURE__ */ l("h5", { children: "Proposed" }), t.photoPreviewBase64 ? /* @__PURE__ */ l("img", {
251
+ src: `data:image/png;base64,${t.photoPreviewBase64}`,
252
+ alt: "Proposed"
253
+ }) : /* @__PURE__ */ l("div", {
254
+ className: d.placeholder,
255
+ children: "No photo"
256
+ })]
257
+ })]
258
+ }),
259
+ y && /* @__PURE__ */ u("div", {
260
+ className: "cw-flex-row cw-gap-small",
261
+ children: [/* @__PURE__ */ l(e, {
262
+ text: "Approve",
263
+ icon: "check",
264
+ onClick: b,
265
+ disabled: _
266
+ }), /* @__PURE__ */ l(e, {
267
+ text: "Reject",
268
+ icon: "close",
269
+ color: "danger",
270
+ variant: "outline",
271
+ onClick: x,
272
+ disabled: _
273
+ })]
274
+ }),
275
+ h && /* @__PURE__ */ u("div", {
276
+ className: d.rejectInput,
277
+ children: [
278
+ /* @__PURE__ */ l(r, {
279
+ labelProps: { text: "Rejection reason" },
280
+ value: p,
281
+ onChange: (e) => m(e.currentTarget.value),
282
+ placeholder: "Optional comment..."
283
+ }),
284
+ /* @__PURE__ */ l(e, {
285
+ text: "Confirm Reject",
286
+ color: "danger",
287
+ onClick: x,
288
+ disabled: _
289
+ }),
290
+ /* @__PURE__ */ l(e, {
291
+ text: "Cancel",
292
+ variant: "outline",
293
+ onClick: () => g(!1)
294
+ })
295
+ ]
296
+ })
297
+ ]
298
+ });
299
+ }
300
+ function h({ requests: e, employeeId: t, loading: n, onReviewFields: r, onApproveAll: a, onReviewPhoto: o, currentImage: s }) {
301
+ if (n) return /* @__PURE__ */ l(i, { size: "small" });
302
+ let c = e.filter((e) => e.status === "Pending" || e.status === "PartiallyApproved"), f = e.filter((e) => e.status !== "Pending" && e.status !== "PartiallyApproved");
303
+ return c.length === 0 && f.length === 0 ? /* @__PURE__ */ l("p", {
304
+ className: "cw-color-neutral",
305
+ children: "No change requests."
306
+ }) : /* @__PURE__ */ u("div", {
307
+ className: "cw-flex-column",
308
+ children: [c.map((e) => e.changeType === "Photo" ? /* @__PURE__ */ l(m, {
309
+ request: e,
310
+ employeeId: t,
311
+ currentImage: s,
312
+ onReviewPhoto: o
313
+ }, e.id) : /* @__PURE__ */ l(p, {
314
+ request: e,
315
+ employeeId: t,
316
+ onReviewFields: r,
317
+ onApproveAll: a
318
+ }, e.id)), f.length > 0 && /* @__PURE__ */ u("details", {
319
+ className: d.historySection,
320
+ children: [/* @__PURE__ */ u("summary", {
321
+ className: d.historySummary,
322
+ children: [
323
+ "History (",
324
+ f.length,
325
+ ")"
326
+ ]
327
+ }), f.map((e) => e.changeType === "Photo" ? /* @__PURE__ */ l(m, {
328
+ request: e,
329
+ employeeId: t,
330
+ currentImage: s,
331
+ onReviewPhoto: o
332
+ }, e.id) : /* @__PURE__ */ l(p, {
333
+ request: e,
334
+ employeeId: t,
335
+ onReviewFields: r,
336
+ onApproveAll: a
337
+ }, e.id))]
338
+ })]
339
+ });
340
+ }
341
+ //#endregion
342
+ export { h as ChangeRequestsTab };
@@ -0,0 +1 @@
1
+ let e=require("@cwellt_software/cwellt-reactjs-lib"),t=require("react"),n=require("react/jsx-runtime");var r={requestCard:`_requestCard_io5wq_1`,requestHeader:`_requestHeader_io5wq_9`,photoCompare:`_photoCompare_io5wq_16`,photoBox:`_photoBox_io5wq_22`,placeholder:`_placeholder_io5wq_33`,rejectInput:`_rejectInput_io5wq_44`,historySection:`_historySection_io5wq_53`,historySummary:`_historySummary_io5wq_57`};function i(t){return(0,n.jsx)(e.CwChip,{label:t,colorScheme:t===`Approved`?`success`:t===`Rejected`?`danger`:t===`Superseded`?`neutral`:`warning`})}function a({request:a,employeeId:o,onReviewFields:s,onApproveAll:c}){let[l,u]=(0,t.useState)(null),[d,f]=(0,t.useState)(``),[p,m]=(0,t.useState)(!1),h=a.fields.filter(e=>e.status===`Pending`),g=h.length>0,_=async t=>{m(!0);try{await s(a.id,[{changeFieldId:t.changeFieldId,approved:!0}],o)}catch{(0,e.CwDisplayMessage)(`Failed to approve field`,e.CwMessageType.ERROR,5e3)}finally{m(!1)}},v=async t=>{if(l!==t.changeFieldId){u(t.changeFieldId),f(``);return}m(!0);try{await s(a.id,[{changeFieldId:t.changeFieldId,approved:!1,comment:d||void 0}],o),u(null),f(``)}catch{(0,e.CwDisplayMessage)(`Failed to reject field`,e.CwMessageType.ERROR,5e3)}finally{m(!1)}},y=async()=>{m(!0);try{await c(a.id,o)}catch{(0,e.CwDisplayMessage)(`Failed to approve all fields`,e.CwMessageType.ERROR,5e3)}finally{m(!1)}},b=async()=>{m(!0);try{await s(a.id,h.map(e=>({changeFieldId:e.changeFieldId,approved:!1})),o)}catch{(0,e.CwDisplayMessage)(`Failed to reject all fields`,e.CwMessageType.ERROR,5e3)}finally{m(!1)}},x=[...g?[{key:`actions`,title:``,className:`cw-table-col-small`,render:t=>t.status===`Pending`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e.CwButton,{variant:`icon`,icon:`check-small`,color:`primary`,title:`Approve`,onClick:()=>_(t),disabled:p}),(0,n.jsx)(e.CwButton,{variant:`icon`,icon:`close`,color:`danger`,title:`Reject`,onClick:()=>v(t),disabled:p})]}):null}]:[],{key:`fieldName`,title:`Field`,dataIndex:`fieldName`,className:`cw-table-col-medium`},{key:`oldValue`,title:`Current`,dataIndex:`oldValue`,className:`cw-table-col-grow`},{key:`newValue`,title:`Requested`,dataIndex:`newValue`,className:`cw-table-col-grow`},{key:`status`,title:`Status`,className:`cw-table-col-small`,render:e=>i(e.status)},...g?[]:[{key:`reviewedBy`,title:`Reviewed By`,dataIndex:`reviewedBy`,className:`cw-table-col-medium`},{key:`reviewedAt`,title:`Reviewed At`,className:`cw-table-col-medium`,render:e=>e.reviewedAt?new Date(e.reviewedAt).toLocaleString():null}]];return(0,n.jsxs)(`div`,{className:r.requestCard,children:[(0,n.jsxs)(`div`,{className:r.requestHeader,children:[(0,n.jsxs)(`div`,{className:`cw-flex-column cw-gap-tiny`,children:[(0,n.jsxs)(`span`,{className:`cw-font-size-small cw-color-neutral`,children:[`Submitted by `,a.requestedBy,` · `,new Date(a.requestedAt).toLocaleString()]}),i(a.status)]}),g&&(0,n.jsxs)(`div`,{className:`cw-flex-row cw-gap-dense`,children:[(0,n.jsx)(e.CwButton,{text:`Reject All`,icon:`close`,color:`danger`,onClick:b,disabled:p}),(0,n.jsx)(e.CwButton,{text:`Approve All`,icon:`check-small`,onClick:y,disabled:p})]})]}),(0,n.jsx)(e.CwTable,{columns:x,data:a.fields,rowKey:`changeFieldId`}),l!==null&&(0,n.jsxs)(`div`,{className:r.rejectInput,children:[(0,n.jsx)(e.CwInputText,{labelProps:{text:`Rejection reason`},value:d,onChange:e=>f(e.currentTarget.value),placeholder:`Optional comment...`}),(0,n.jsx)(e.CwButton,{text:`Confirm Reject`,color:`danger`,onClick:()=>{let e=a.fields.find(e=>e.changeFieldId===l);e&&v(e)},disabled:p}),(0,n.jsx)(e.CwButton,{text:`Cancel`,variant:`outline`,onClick:()=>u(null)})]})]})}function o({request:a,employeeId:o,currentImage:s,onReviewPhoto:c}){let[l,u]=(0,t.useState)(``),[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)(!1),h=a.status===`Pending`,g=async()=>{m(!0);try{await c(a.id,!0,o)}catch{(0,e.CwDisplayMessage)(`Failed to approve photo`,e.CwMessageType.ERROR,5e3)}finally{m(!1)}},_=async()=>{if(!d){f(!0);return}m(!0);try{await c(a.id,!1,o,l||void 0),f(!1)}catch{(0,e.CwDisplayMessage)(`Failed to reject photo`,e.CwMessageType.ERROR,5e3)}finally{m(!1)}};return(0,n.jsxs)(`div`,{className:r.requestCard,children:[(0,n.jsx)(`div`,{className:r.requestHeader,children:(0,n.jsxs)(`div`,{className:`cw-flex-column cw-gap-tiny`,children:[(0,n.jsxs)(`span`,{className:`cw-font-size-small cw-color-neutral`,children:[`Submitted by `,a.requestedBy,` · `,new Date(a.requestedAt).toLocaleString()]}),i(a.status)]})}),(0,n.jsxs)(`div`,{className:r.photoCompare,children:[(0,n.jsxs)(`div`,{className:r.photoBox,children:[(0,n.jsx)(`h5`,{children:`Current`}),s?(0,n.jsx)(`img`,{src:s,alt:`Current`}):(0,n.jsx)(`div`,{className:r.placeholder,children:`No photo`})]}),(0,n.jsxs)(`div`,{className:r.photoBox,children:[(0,n.jsx)(`h5`,{children:`Proposed`}),a.photoPreviewBase64?(0,n.jsx)(`img`,{src:`data:image/png;base64,${a.photoPreviewBase64}`,alt:`Proposed`}):(0,n.jsx)(`div`,{className:r.placeholder,children:`No photo`})]})]}),h&&(0,n.jsxs)(`div`,{className:`cw-flex-row cw-gap-small`,children:[(0,n.jsx)(e.CwButton,{text:`Approve`,icon:`check`,onClick:g,disabled:p}),(0,n.jsx)(e.CwButton,{text:`Reject`,icon:`close`,color:`danger`,variant:`outline`,onClick:_,disabled:p})]}),d&&(0,n.jsxs)(`div`,{className:r.rejectInput,children:[(0,n.jsx)(e.CwInputText,{labelProps:{text:`Rejection reason`},value:l,onChange:e=>u(e.currentTarget.value),placeholder:`Optional comment...`}),(0,n.jsx)(e.CwButton,{text:`Confirm Reject`,color:`danger`,onClick:_,disabled:p}),(0,n.jsx)(e.CwButton,{text:`Cancel`,variant:`outline`,onClick:()=>f(!1)})]})]})}function s({requests:t,employeeId:i,loading:s,onReviewFields:c,onApproveAll:l,onReviewPhoto:u,currentImage:d}){if(s)return(0,n.jsx)(e.CwLoading,{size:`small`});let f=t.filter(e=>e.status===`Pending`||e.status===`PartiallyApproved`),p=t.filter(e=>e.status!==`Pending`&&e.status!==`PartiallyApproved`);return f.length===0&&p.length===0?(0,n.jsx)(`p`,{className:`cw-color-neutral`,children:`No change requests.`}):(0,n.jsxs)(`div`,{className:`cw-flex-column`,children:[f.map(e=>e.changeType===`Photo`?(0,n.jsx)(o,{request:e,employeeId:i,currentImage:d,onReviewPhoto:u},e.id):(0,n.jsx)(a,{request:e,employeeId:i,onReviewFields:c,onApproveAll:l},e.id)),p.length>0&&(0,n.jsxs)(`details`,{className:r.historySection,children:[(0,n.jsxs)(`summary`,{className:r.historySummary,children:[`History (`,p.length,`)`]}),p.map(e=>e.changeType===`Photo`?(0,n.jsx)(o,{request:e,employeeId:i,currentImage:d,onReviewPhoto:u},e.id):(0,n.jsx)(a,{request:e,employeeId:i,onReviewFields:c,onApproveAll:l},e.id))]})]})}exports.ChangeRequestsTab=s;
@@ -0,0 +1 @@
1
+ const e=require("./dateUtils-BULQTXVb.cjs");let t=require("@cwellt_software/cwellt-reactjs-lib"),n=require("react"),r=require("react/jsx-runtime");function i({data:i,employeeId:a,onUpdate:o}){let[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)(i??{maidenName:``,ssrNumber:``,pregnantFrom:null,radiationSincePregnant:null}),d=()=>{u(i??{maidenName:``,ssrNumber:``,pregnantFrom:null,radiationSincePregnant:null}),c(!0)},f=async()=>{try{await o(a,l),c(!1),(0,t.CwDisplayMessage)(`Saved`,t.CwMessageType.SUCCESS,3e3)}catch{(0,t.CwDisplayMessage)(`Failed to save`,t.CwMessageType.ERROR,5e3)}},p=e.a,m=e.i;return(0,r.jsxs)(`section`,{children:[(0,r.jsx)(`header`,{className:`cw-flex-row cw-margin-bottom-small`,children:(0,r.jsx)(t.CwButton,{text:`Edit`,icon:`edit`,onClick:d,"data-testid":`tab-cosmicRadiation-edit-button`})}),(0,r.jsx)(t.CwKeyValueList,{direction:`column`,items:[{key:`maidenName`,label:`Maiden Name`,value:i?.maidenName},{key:`ssrNumber`,label:`SSR Number`,value:i?.ssrNumber},{key:`pregnantFrom`,label:`Pregnant From`,value:(t=>e.r(t,`-`))(i?.pregnantFrom??null)},{key:`radiationSincePregnant`,label:`Radiation Since Pregnant`,value:i?.radiationSincePregnant}]}),s&&(0,r.jsx)(t.CwDialog,{open:!0,headline:`Edit Cosmic Radiation`,onClose:()=>c(!1),onSave:f,width:`30rem`,children:(0,r.jsxs)(`div`,{className:`cw-flex-column`,"data-label-width":`15rem`,children:[(0,r.jsx)(t.CwInputText,{labelProps:{text:`Maiden Name`},value:l.maidenName,onChange:e=>{let t=e.currentTarget.value;u(e=>({...e,maidenName:t}))},"data-testid":`tab-cosmicRadiation-form-maidenName`}),(0,r.jsx)(t.CwInputText,{labelProps:{text:`SSR Number`},value:l.ssrNumber,onChange:e=>{let t=e.currentTarget.value;u(e=>({...e,ssrNumber:t}))}}),(0,r.jsx)(t.CwDatePicker,{labelProps:{text:`Pregnant From`},value:p(l.pregnantFrom),onChange:e=>u(t=>({...t,pregnantFrom:m(e)})),showClear:!0}),(0,r.jsx)(t.CwDigit,{labelProps:{text:`Radiation Since Pregnant`},value:l.radiationSincePregnant==null?``:String(l.radiationSincePregnant),onChange:e=>{let t=e.currentTarget.value;u(e=>({...e,radiationSincePregnant:t?Number(t):null}))}})]})})]})}exports.CosmicRadiationTab=i;