@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.
- package/dist/AccountingRulesTab-CdYj-dz8.js +84 -0
- package/dist/AccountingRulesTab-DQJ7nD71.cjs +1 -0
- package/dist/AdditionalInfoTab-DW-S373w.cjs +1 -0
- package/dist/AdditionalInfoTab-j-Ixuvog.js +114 -0
- package/dist/App.d.ts +3 -0
- package/dist/ChangeRequestsTab-CFCWKZkt.js +342 -0
- package/dist/ChangeRequestsTab-CY7-qObu.cjs +1 -0
- package/dist/CosmicRadiationTab-6fqnDLH3.cjs +1 -0
- package/dist/CosmicRadiationTab-CLlfjJNA.js +120 -0
- package/dist/DeleteDialog-BqXtjGGi.cjs +1 -0
- package/dist/DeleteDialog-CyRsLr_c.js +21 -0
- package/dist/DetailsTab-DKFAMvlW.cjs +1 -0
- package/dist/DetailsTab-Dh1lfSr2.js +248 -0
- package/dist/DivisionsTab--eEVFupH.cjs +1 -0
- package/dist/DivisionsTab-BfIIZ_ld.js +86 -0
- package/dist/FunctionsTab-BMWoqfK2.js +160 -0
- package/dist/FunctionsTab-DQPsK0rq.cjs +1 -0
- package/dist/HistoryTab-CViMxBYc.cjs +1 -0
- package/dist/HistoryTab-CwCD46f3.js +277 -0
- package/dist/LanguagesTab-BKa7nmoT.cjs +1 -0
- package/dist/LanguagesTab-BznJDDXK.js +181 -0
- package/dist/RelatedPersonsTab-C-6ti_Be.js +260 -0
- package/dist/RelatedPersonsTab-DgoBLK21.cjs +1 -0
- package/dist/VaccinesTab-BGhy3EgY.cjs +1 -0
- package/dist/VaccinesTab-BtdAXAyo.js +171 -0
- package/dist/context/DialogShellContext.d.ts +22 -0
- package/dist/dateUtils-BULQTXVb.cjs +1 -0
- package/dist/dateUtils-CTu1RDq1.js +25 -0
- package/dist/domain/model/ChangeRequest.d.ts +23 -0
- package/dist/domain/model/Dietary.d.ts +24 -0
- package/dist/domain/model/EmployeeDetail.d.ts +89 -0
- package/dist/domain/model/EmployeeDropdowns.d.ts +31 -0
- package/dist/domain/model/EmployeeListItem.d.ts +15 -0
- package/dist/domain/model/EmployeeTabModels.d.ts +91 -0
- package/dist/domain/repository/DietaryRepository.d.ts +8 -0
- package/dist/domain/repository/EmployeeRepository.d.ts +62 -0
- package/dist/index.d.ts +18 -0
- package/dist/infrastructure/DietaryRepositoryImpl.d.ts +20 -0
- package/dist/infrastructure/EmployeeRepositoryImpl.d.ts +74 -0
- package/dist/infrastructure/dto/DietaryDto.d.ts +26 -0
- package/dist/main.d.ts +1 -0
- package/dist/presentation/EmployeeOverview.d.ts +18 -0
- package/dist/presentation/common/DeleteDialog.d.ts +16 -0
- package/dist/presentation/common/EmptyState.d.ts +11 -0
- package/dist/presentation/common/LazyImage.d.ts +15 -0
- package/dist/presentation/common/useLazyTabs.d.ts +14 -0
- package/dist/presentation/comps/modals/AddEmployeeModal.d.ts +10 -0
- package/dist/presentation/comps/modals/EditEmployeeModal.d.ts +13 -0
- package/dist/presentation/comps/tabs/AccountingRulesTab.d.ts +10 -0
- package/dist/presentation/comps/tabs/AdditionalInfoTab.d.ts +12 -0
- package/dist/presentation/comps/tabs/ChangeRequestsTab.d.ts +16 -0
- package/dist/presentation/comps/tabs/CosmicRadiationTab.d.ts +8 -0
- package/dist/presentation/comps/tabs/DetailsTab.d.ts +8 -0
- package/dist/presentation/comps/tabs/DivisionsTab.d.ts +11 -0
- package/dist/presentation/comps/tabs/FunctionsTab.d.ts +13 -0
- package/dist/presentation/comps/tabs/HistoryTab.d.ts +15 -0
- package/dist/presentation/comps/tabs/LanguagesTab.d.ts +13 -0
- package/dist/presentation/comps/tabs/RelatedPersonsTab.d.ts +13 -0
- package/dist/presentation/comps/tabs/VaccinesTab.d.ts +12 -0
- package/dist/presentation/dietary/DietaryPage.d.ts +9 -0
- package/dist/presentation/dietary/comps/DietaryEntryDialog.d.ts +13 -0
- package/dist/presentation/dietary/comps/DietarySection.d.ts +8 -0
- package/dist/presentation/dietary/hooks/useDietary.d.ts +12 -0
- package/dist/presentation/dietary/parsers/catalogSuggestions.d.ts +12 -0
- package/dist/presentation/hooks/data/useChangeRequests.d.ts +17 -0
- package/dist/presentation/hooks/data/useEmployeeData.d.ts +79 -0
- package/dist/presentation/hooks/data/useEmployeeFilters.d.ts +10 -0
- package/dist/presentation/hooks/ui/useEmployeeOverviewUI.d.ts +15 -0
- package/dist/presentation/parsers/dateUtils.d.ts +12 -0
- package/dist/presentation/parsers/employeeParsers.d.ts +3 -0
- package/dist/presentation/parsers/imageUtils.d.ts +1 -0
- package/dist/shared-employee.cjs.js +1 -0
- package/dist/shared-employee.css +2 -0
- package/dist/shared-employee.es.js +2592 -0
- package/package.json +58 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { a as e, i as t, n, r } from "./dateUtils-CTu1RDq1.js";
|
|
2
|
+
import { t as i } from "./DeleteDialog-CyRsLr_c.js";
|
|
3
|
+
import { CwButton as a, CwDatePicker as o, CwDialog as s, CwDigit as c, CwDisplayMessage as l, CwFindAirport as u, CwMessageType as d, CwOption as f, CwSelect as p, CwTable as m } from "@cwellt_software/cwellt-reactjs-lib";
|
|
4
|
+
import { useState as h } from "react";
|
|
5
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
6
|
+
//#region src/presentation/comps/tabs/HistoryTab.tsx
|
|
7
|
+
function y({ items: y, employeeId: b, functions: x, contractTypes: S, airportConfig: C, onCreate: w, onUpdate: T, onDelete: E }) {
|
|
8
|
+
let [D, O] = h(!1), [k, A] = h(null), [j, M] = h(null), [N, P] = h({
|
|
9
|
+
startDate: "",
|
|
10
|
+
endDate: "",
|
|
11
|
+
functionId: null,
|
|
12
|
+
homeBaseId: null,
|
|
13
|
+
travelBaseId: null,
|
|
14
|
+
percentage: 100,
|
|
15
|
+
flightPercentage: 100,
|
|
16
|
+
officeDays: 0,
|
|
17
|
+
contractType: "FC"
|
|
18
|
+
}), F = [...y].sort((e, t) => {
|
|
19
|
+
let n = e.endDate ?? "9999";
|
|
20
|
+
return (t.endDate ?? "9999").localeCompare(n);
|
|
21
|
+
}), I = () => {
|
|
22
|
+
let e = y.find((e) => !e.endDate || e.endDate >= "2099");
|
|
23
|
+
A(null), P({
|
|
24
|
+
startDate: "",
|
|
25
|
+
endDate: "",
|
|
26
|
+
functionId: null,
|
|
27
|
+
homeBaseId: e?.homeBaseId ?? null,
|
|
28
|
+
travelBaseId: e?.travelBaseId ?? null,
|
|
29
|
+
percentage: 100,
|
|
30
|
+
flightPercentage: 100,
|
|
31
|
+
officeDays: 0,
|
|
32
|
+
contractType: "FC"
|
|
33
|
+
}), O(!0);
|
|
34
|
+
}, L = (e) => {
|
|
35
|
+
A(e), P({
|
|
36
|
+
startDate: e.startDate ?? "",
|
|
37
|
+
endDate: n(e.endDate),
|
|
38
|
+
functionId: e.functionId,
|
|
39
|
+
homeBaseId: e.homeBaseId,
|
|
40
|
+
travelBaseId: e.travelBaseId,
|
|
41
|
+
percentage: e.percentage ?? 100,
|
|
42
|
+
flightPercentage: e.flightPercentage ?? 100,
|
|
43
|
+
officeDays: e.officeDays ?? 0,
|
|
44
|
+
contractType: e.contractType
|
|
45
|
+
}), O(!0);
|
|
46
|
+
}, R = async () => {
|
|
47
|
+
try {
|
|
48
|
+
k ? await T({
|
|
49
|
+
...k,
|
|
50
|
+
startDate: N.startDate || null,
|
|
51
|
+
endDate: N.endDate || null,
|
|
52
|
+
functionId: N.functionId,
|
|
53
|
+
homeBaseId: N.homeBaseId,
|
|
54
|
+
travelBaseId: N.travelBaseId,
|
|
55
|
+
percentage: N.percentage,
|
|
56
|
+
flightPercentage: N.flightPercentage,
|
|
57
|
+
officeDays: N.officeDays,
|
|
58
|
+
contractType: N.contractType
|
|
59
|
+
}) : await w({
|
|
60
|
+
startDate: N.startDate || null,
|
|
61
|
+
endDate: N.endDate || null,
|
|
62
|
+
functionId: N.functionId,
|
|
63
|
+
homeBaseId: N.homeBaseId,
|
|
64
|
+
travelBaseId: N.travelBaseId,
|
|
65
|
+
percentage: N.percentage,
|
|
66
|
+
flightPercentage: N.flightPercentage,
|
|
67
|
+
officeDays: N.officeDays,
|
|
68
|
+
contractType: N.contractType,
|
|
69
|
+
employeeId: b
|
|
70
|
+
}), O(!1);
|
|
71
|
+
} catch {
|
|
72
|
+
l("Failed to save", d.ERROR, 5e3);
|
|
73
|
+
}
|
|
74
|
+
}, z = e, B = (e) => t(e) ?? "";
|
|
75
|
+
return /* @__PURE__ */ v("section", { children: [
|
|
76
|
+
/* @__PURE__ */ _("header", {
|
|
77
|
+
className: "cw-flex-row cw-margin-bottom-small",
|
|
78
|
+
children: /* @__PURE__ */ _(a, {
|
|
79
|
+
text: "Add",
|
|
80
|
+
icon: "plus",
|
|
81
|
+
onClick: I
|
|
82
|
+
})
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ _(m, {
|
|
85
|
+
columns: [
|
|
86
|
+
{
|
|
87
|
+
key: "actions",
|
|
88
|
+
title: "",
|
|
89
|
+
className: "cw-table-col-action cw-table-col-buttons",
|
|
90
|
+
render: (e) => /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(a, {
|
|
91
|
+
variant: "icon",
|
|
92
|
+
icon: "edit",
|
|
93
|
+
onClick: () => L(e)
|
|
94
|
+
}), /* @__PURE__ */ _(a, {
|
|
95
|
+
variant: "icon",
|
|
96
|
+
icon: "delete",
|
|
97
|
+
color: "danger",
|
|
98
|
+
onClick: () => M(e)
|
|
99
|
+
})] })
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
key: "startDate",
|
|
103
|
+
title: "Start",
|
|
104
|
+
dataIndex: "startDate",
|
|
105
|
+
render: (e) => r(e.startDate)
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
key: "endDate",
|
|
109
|
+
title: "End",
|
|
110
|
+
dataIndex: "endDate",
|
|
111
|
+
render: (e) => e.endDate ? r(e.endDate) : "Current"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: "functionName",
|
|
115
|
+
title: "Function",
|
|
116
|
+
dataIndex: "functionName"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
key: "homeBaseIcao",
|
|
120
|
+
title: "Home Base",
|
|
121
|
+
dataIndex: "homeBaseIcao"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: "travelBaseIcao",
|
|
125
|
+
title: "Travel Base",
|
|
126
|
+
dataIndex: "travelBaseIcao"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
key: "percentage",
|
|
130
|
+
title: "%",
|
|
131
|
+
dataIndex: "percentage",
|
|
132
|
+
render: (e) => e.percentage == null ? "" : `${e.percentage}%`
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
key: "contractType",
|
|
136
|
+
title: "Contract",
|
|
137
|
+
dataIndex: "contractType"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
data: F,
|
|
141
|
+
rowKey: "id"
|
|
142
|
+
}),
|
|
143
|
+
D && /* @__PURE__ */ _(s, {
|
|
144
|
+
open: !0,
|
|
145
|
+
headline: k ? "Edit History" : "Add History",
|
|
146
|
+
onClose: () => O(!1),
|
|
147
|
+
width: "35rem",
|
|
148
|
+
customFooter: [/* @__PURE__ */ _(a, {
|
|
149
|
+
variant: "icon",
|
|
150
|
+
icon: "save",
|
|
151
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
152
|
+
onClick: R
|
|
153
|
+
}, "save")],
|
|
154
|
+
children: /* @__PURE__ */ v("div", {
|
|
155
|
+
className: "cw-flex-column",
|
|
156
|
+
"data-label-width": "10rem",
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ _(o, {
|
|
159
|
+
labelProps: { text: "Start Date" },
|
|
160
|
+
value: z(N.startDate),
|
|
161
|
+
onChange: (e) => P((t) => ({
|
|
162
|
+
...t,
|
|
163
|
+
startDate: B(e)
|
|
164
|
+
}))
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ _(o, {
|
|
167
|
+
labelProps: { text: "End Date" },
|
|
168
|
+
value: z(N.endDate),
|
|
169
|
+
onChange: (e) => P((t) => ({
|
|
170
|
+
...t,
|
|
171
|
+
endDate: B(e)
|
|
172
|
+
}))
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ _(p, {
|
|
175
|
+
labelProps: { text: "Function" },
|
|
176
|
+
value: N.functionId == null ? "" : String(N.functionId),
|
|
177
|
+
onChange: (e) => {
|
|
178
|
+
let t = e.currentTarget.value;
|
|
179
|
+
P((e) => ({
|
|
180
|
+
...e,
|
|
181
|
+
functionId: t ? Number(t) : null
|
|
182
|
+
}));
|
|
183
|
+
},
|
|
184
|
+
placeholder: "Select...",
|
|
185
|
+
children: x.map((e) => /* @__PURE__ */ _(f, {
|
|
186
|
+
value: e.id,
|
|
187
|
+
children: e.name
|
|
188
|
+
}, e.id))
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ _(p, {
|
|
191
|
+
labelProps: { text: "Contract" },
|
|
192
|
+
value: N.contractType,
|
|
193
|
+
onChange: (e) => {
|
|
194
|
+
let t = e.currentTarget.value;
|
|
195
|
+
P((e) => ({
|
|
196
|
+
...e,
|
|
197
|
+
contractType: t
|
|
198
|
+
}));
|
|
199
|
+
},
|
|
200
|
+
children: S.map((e) => /* @__PURE__ */ _(f, {
|
|
201
|
+
value: e.id,
|
|
202
|
+
children: e.name
|
|
203
|
+
}, e.id))
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ _(u, {
|
|
206
|
+
labelProps: { text: "Home Base" },
|
|
207
|
+
value: N.homeBaseId ?? void 0,
|
|
208
|
+
handleChange: (e) => P((t) => ({
|
|
209
|
+
...t,
|
|
210
|
+
homeBaseId: e || null
|
|
211
|
+
})),
|
|
212
|
+
cblConfig: C ?? "",
|
|
213
|
+
searchType: "OnlyDatabase",
|
|
214
|
+
displayMode: "icao-only",
|
|
215
|
+
placeHolder: "Search airport..."
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ _(u, {
|
|
218
|
+
labelProps: { text: "Travel Base" },
|
|
219
|
+
value: N.travelBaseId ?? void 0,
|
|
220
|
+
handleChange: (e) => P((t) => ({
|
|
221
|
+
...t,
|
|
222
|
+
travelBaseId: e || null
|
|
223
|
+
})),
|
|
224
|
+
cblConfig: C ?? "",
|
|
225
|
+
searchType: "OnlyDatabase",
|
|
226
|
+
displayMode: "icao-only",
|
|
227
|
+
placeHolder: "Search airport..."
|
|
228
|
+
}),
|
|
229
|
+
/* @__PURE__ */ _(c, {
|
|
230
|
+
labelProps: { text: "Employment %" },
|
|
231
|
+
value: String(N.percentage),
|
|
232
|
+
onChange: (e) => {
|
|
233
|
+
let t = Number(e.currentTarget.value);
|
|
234
|
+
P((e) => ({
|
|
235
|
+
...e,
|
|
236
|
+
percentage: t
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
}),
|
|
240
|
+
/* @__PURE__ */ _(c, {
|
|
241
|
+
labelProps: { text: "Flight Duty %" },
|
|
242
|
+
value: String(N.flightPercentage),
|
|
243
|
+
onChange: (e) => {
|
|
244
|
+
let t = Number(e.currentTarget.value);
|
|
245
|
+
P((e) => ({
|
|
246
|
+
...e,
|
|
247
|
+
flightPercentage: t
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
}),
|
|
251
|
+
/* @__PURE__ */ _(c, {
|
|
252
|
+
labelProps: { text: "Office Days" },
|
|
253
|
+
value: String(N.officeDays),
|
|
254
|
+
onChange: (e) => {
|
|
255
|
+
let t = Number(e.currentTarget.value);
|
|
256
|
+
P((e) => ({
|
|
257
|
+
...e,
|
|
258
|
+
officeDays: t
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
})
|
|
264
|
+
}),
|
|
265
|
+
j && /* @__PURE__ */ _(i, {
|
|
266
|
+
open: !0,
|
|
267
|
+
headline: "Delete History Entry",
|
|
268
|
+
message: "Delete this history entry?",
|
|
269
|
+
onDelete: async () => {
|
|
270
|
+
await E(j.id), M(null);
|
|
271
|
+
},
|
|
272
|
+
onClose: () => M(null)
|
|
273
|
+
})
|
|
274
|
+
] });
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
export { y as HistoryTab };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./dateUtils-BULQTXVb.cjs"),t=require("./DeleteDialog-BqXtjGGi.cjs");let n=require("@cwellt_software/cwellt-reactjs-lib"),r=require("react"),i=require("react/jsx-runtime");function a(e){switch(e.toLowerCase()){case`native`:return`success`;case`fluent`:return`info`;case`intermediate`:return`warning`;default:return`neutral`}}function o({items:o,employeeId:s,languages:c,levels:l,onCreate:u,onUpdate:d,onDelete:f}){let[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null),[_,v]=(0,r.useState)(null),[y,b]=(0,r.useState)({languageId:null,levelId:null,startDate:void 0}),x=()=>{g(null),b({languageId:null,levelId:null,startDate:void 0}),m(!0)},S=t=>{g(t),b({languageId:t.languageId,levelId:t.levelId,startDate:e.a(t.startDate)}),m(!0)};return(0,i.jsxs)(`section`,{children:[(0,i.jsx)(`header`,{className:`cw-flex-row cw-margin-bottom-small`,children:(0,i.jsx)(n.CwButton,{text:`Add Language`,icon:`plus`,onClick:x,"data-testid":`tab-languages-add-button`})}),(0,i.jsx)(n.CwTable,{columns:[{key:`actions`,title:``,className:`cw-table-col-action cw-table-col-buttons`,render:e=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.CwButton,{variant:`icon`,icon:`edit`,onClick:()=>S(e),"data-testid":`tab-languages-row-${e.languageName}-edit`}),(0,i.jsx)(n.CwButton,{variant:`icon`,icon:`delete`,color:`danger`,onClick:()=>v(e),"data-testid":`tab-languages-row-${e.languageName}-delete`})]})},{key:`languageName`,title:`Language`,dataIndex:`languageName`,render:e=>(0,i.jsx)(`span`,{"data-testid":`tab-languages-row-${e.languageName}`,children:e.languageName})},{key:`levelName`,title:`Level`,dataIndex:`levelName`,render:e=>(0,i.jsx)(n.CwChip,{label:e.levelName,colorScheme:a(e.levelName)})},{key:`startDate`,title:`Start Date`,dataIndex:`startDate`,render:t=>e.r(t.startDate)}],data:o,rowKey:`id`}),p&&(0,i.jsx)(n.CwDialog,{open:!0,headline:h?`Edit Language`:`Add Language`,onClose:()=>m(!1),onSave:async()=>{if(!(!y.languageId||!y.levelId))try{let t=e.i(y.startDate);if(h){let e=c.find(e=>e.id===y.languageId)?.name??h.languageName,n=l.find(e=>e.id===y.levelId)?.name??h.levelName;await d({...h,languageId:y.languageId,levelId:y.levelId,startDate:t,languageName:e,levelName:n})}else await u({languageId:y.languageId,levelId:y.levelId,startDate:t,employeeId:s});m(!1)}catch{(0,n.CwDisplayMessage)(`Failed to save`,n.CwMessageType.ERROR,5e3)}},disableSave:!y.languageId||!y.levelId,width:`30rem`,children:(0,i.jsxs)(`div`,{className:`cw-flex-column`,"data-label-width":`8rem`,children:[(0,i.jsx)(n.CwSelect,{labelProps:{text:`Language`},value:y.languageId??``,onChange:e=>{let t=e.currentTarget.value;b(e=>({...e,languageId:t||null}))},placeholder:`Select...`,"data-testid":`tab-languages-form-language`,children:c.map(e=>(0,i.jsx)(n.CwOption,{value:e.id,children:e.name},e.id))}),(0,i.jsx)(n.CwSelect,{labelProps:{text:`Level`},value:y.levelId??``,onChange:e=>{let t=e.currentTarget.value;b(e=>({...e,levelId:t||null}))},placeholder:`Select...`,"data-testid":`tab-languages-form-level`,children:l.map(e=>(0,i.jsx)(n.CwOption,{value:e.id,children:e.name},e.id))}),(0,i.jsx)(n.CwDatePicker,{labelProps:{text:`Start Date`},value:y.startDate,onChange:e=>b(t=>({...t,startDate:e}))})]})}),_&&(0,i.jsx)(t.t,{open:!0,headline:`Delete Language`,message:`Delete "${_.languageName}"?`,onDelete:async()=>{await f(_.id),v(null)},onClose:()=>v(null)})]})}exports.LanguagesTab=o;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { a as e, i as t, r as n } from "./dateUtils-CTu1RDq1.js";
|
|
2
|
+
import { t as r } from "./DeleteDialog-CyRsLr_c.js";
|
|
3
|
+
import { CwButton as i, CwChip as a, CwDatePicker as o, CwDialog as s, CwDisplayMessage as c, CwMessageType as l, CwOption as u, CwSelect as d, CwTable as f } from "@cwellt_software/cwellt-reactjs-lib";
|
|
4
|
+
import { useState as p } from "react";
|
|
5
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
6
|
+
//#region src/presentation/comps/tabs/LanguagesTab.tsx
|
|
7
|
+
function _(e) {
|
|
8
|
+
switch (e.toLowerCase()) {
|
|
9
|
+
case "native": return "success";
|
|
10
|
+
case "fluent": return "info";
|
|
11
|
+
case "intermediate": return "warning";
|
|
12
|
+
default: return "neutral";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function v({ items: v, employeeId: y, languages: b, levels: x, onCreate: S, onUpdate: C, onDelete: w }) {
|
|
16
|
+
let [T, E] = p(!1), [D, O] = p(null), [k, A] = p(null), [j, M] = p({
|
|
17
|
+
languageId: null,
|
|
18
|
+
levelId: null,
|
|
19
|
+
startDate: void 0
|
|
20
|
+
}), N = () => {
|
|
21
|
+
O(null), M({
|
|
22
|
+
languageId: null,
|
|
23
|
+
levelId: null,
|
|
24
|
+
startDate: void 0
|
|
25
|
+
}), E(!0);
|
|
26
|
+
}, P = (t) => {
|
|
27
|
+
O(t), M({
|
|
28
|
+
languageId: t.languageId,
|
|
29
|
+
levelId: t.levelId,
|
|
30
|
+
startDate: e(t.startDate)
|
|
31
|
+
}), E(!0);
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ g("section", { children: [
|
|
34
|
+
/* @__PURE__ */ h("header", {
|
|
35
|
+
className: "cw-flex-row cw-margin-bottom-small",
|
|
36
|
+
children: /* @__PURE__ */ h(i, {
|
|
37
|
+
text: "Add Language",
|
|
38
|
+
icon: "plus",
|
|
39
|
+
onClick: N,
|
|
40
|
+
"data-testid": "tab-languages-add-button"
|
|
41
|
+
})
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ h(f, {
|
|
44
|
+
columns: [
|
|
45
|
+
{
|
|
46
|
+
key: "actions",
|
|
47
|
+
title: "",
|
|
48
|
+
className: "cw-table-col-action cw-table-col-buttons",
|
|
49
|
+
render: (e) => /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(i, {
|
|
50
|
+
variant: "icon",
|
|
51
|
+
icon: "edit",
|
|
52
|
+
onClick: () => P(e),
|
|
53
|
+
"data-testid": `tab-languages-row-${e.languageName}-edit`
|
|
54
|
+
}), /* @__PURE__ */ h(i, {
|
|
55
|
+
variant: "icon",
|
|
56
|
+
icon: "delete",
|
|
57
|
+
color: "danger",
|
|
58
|
+
onClick: () => A(e),
|
|
59
|
+
"data-testid": `tab-languages-row-${e.languageName}-delete`
|
|
60
|
+
})] })
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "languageName",
|
|
64
|
+
title: "Language",
|
|
65
|
+
dataIndex: "languageName",
|
|
66
|
+
render: (e) => /* @__PURE__ */ h("span", {
|
|
67
|
+
"data-testid": `tab-languages-row-${e.languageName}`,
|
|
68
|
+
children: e.languageName
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: "levelName",
|
|
73
|
+
title: "Level",
|
|
74
|
+
dataIndex: "levelName",
|
|
75
|
+
render: (e) => /* @__PURE__ */ h(a, {
|
|
76
|
+
label: e.levelName,
|
|
77
|
+
colorScheme: _(e.levelName)
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
key: "startDate",
|
|
82
|
+
title: "Start Date",
|
|
83
|
+
dataIndex: "startDate",
|
|
84
|
+
render: (e) => n(e.startDate)
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
data: v,
|
|
88
|
+
rowKey: "id"
|
|
89
|
+
}),
|
|
90
|
+
T && /* @__PURE__ */ h(s, {
|
|
91
|
+
open: !0,
|
|
92
|
+
headline: D ? "Edit Language" : "Add Language",
|
|
93
|
+
onClose: () => E(!1),
|
|
94
|
+
onSave: async () => {
|
|
95
|
+
if (!(!j.languageId || !j.levelId)) try {
|
|
96
|
+
let e = t(j.startDate);
|
|
97
|
+
if (D) {
|
|
98
|
+
let t = b.find((e) => e.id === j.languageId)?.name ?? D.languageName, n = x.find((e) => e.id === j.levelId)?.name ?? D.levelName;
|
|
99
|
+
await C({
|
|
100
|
+
...D,
|
|
101
|
+
languageId: j.languageId,
|
|
102
|
+
levelId: j.levelId,
|
|
103
|
+
startDate: e,
|
|
104
|
+
languageName: t,
|
|
105
|
+
levelName: n
|
|
106
|
+
});
|
|
107
|
+
} else await S({
|
|
108
|
+
languageId: j.languageId,
|
|
109
|
+
levelId: j.levelId,
|
|
110
|
+
startDate: e,
|
|
111
|
+
employeeId: y
|
|
112
|
+
});
|
|
113
|
+
E(!1);
|
|
114
|
+
} catch {
|
|
115
|
+
c("Failed to save", l.ERROR, 5e3);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
disableSave: !j.languageId || !j.levelId,
|
|
119
|
+
width: "30rem",
|
|
120
|
+
children: /* @__PURE__ */ g("div", {
|
|
121
|
+
className: "cw-flex-column",
|
|
122
|
+
"data-label-width": "8rem",
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ h(d, {
|
|
125
|
+
labelProps: { text: "Language" },
|
|
126
|
+
value: j.languageId ?? "",
|
|
127
|
+
onChange: (e) => {
|
|
128
|
+
let t = e.currentTarget.value;
|
|
129
|
+
M((e) => ({
|
|
130
|
+
...e,
|
|
131
|
+
languageId: t || null
|
|
132
|
+
}));
|
|
133
|
+
},
|
|
134
|
+
placeholder: "Select...",
|
|
135
|
+
"data-testid": "tab-languages-form-language",
|
|
136
|
+
children: b.map((e) => /* @__PURE__ */ h(u, {
|
|
137
|
+
value: e.id,
|
|
138
|
+
children: e.name
|
|
139
|
+
}, e.id))
|
|
140
|
+
}),
|
|
141
|
+
/* @__PURE__ */ h(d, {
|
|
142
|
+
labelProps: { text: "Level" },
|
|
143
|
+
value: j.levelId ?? "",
|
|
144
|
+
onChange: (e) => {
|
|
145
|
+
let t = e.currentTarget.value;
|
|
146
|
+
M((e) => ({
|
|
147
|
+
...e,
|
|
148
|
+
levelId: t || null
|
|
149
|
+
}));
|
|
150
|
+
},
|
|
151
|
+
placeholder: "Select...",
|
|
152
|
+
"data-testid": "tab-languages-form-level",
|
|
153
|
+
children: x.map((e) => /* @__PURE__ */ h(u, {
|
|
154
|
+
value: e.id,
|
|
155
|
+
children: e.name
|
|
156
|
+
}, e.id))
|
|
157
|
+
}),
|
|
158
|
+
/* @__PURE__ */ h(o, {
|
|
159
|
+
labelProps: { text: "Start Date" },
|
|
160
|
+
value: j.startDate,
|
|
161
|
+
onChange: (e) => M((t) => ({
|
|
162
|
+
...t,
|
|
163
|
+
startDate: e
|
|
164
|
+
}))
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
}),
|
|
169
|
+
k && /* @__PURE__ */ h(r, {
|
|
170
|
+
open: !0,
|
|
171
|
+
headline: "Delete Language",
|
|
172
|
+
message: `Delete "${k.languageName}"?`,
|
|
173
|
+
onDelete: async () => {
|
|
174
|
+
await w(k.id), A(null);
|
|
175
|
+
},
|
|
176
|
+
onClose: () => A(null)
|
|
177
|
+
})
|
|
178
|
+
] });
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { v as LanguagesTab };
|