@flarehr/superhero-basic-profile 0.1.2214 → 0.1.2217
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/App.jsx +4 -0
- package/dist/Basic.Profile.Domain/AnalyticsEvent.jsx +102 -0
- package/dist/Basic.Profile.Domain/Audit.jsx +149 -0
- package/dist/Basic.Profile.Domain/Commands.jsx +68 -0
- package/dist/Basic.Profile.Domain/CommonTypes.jsx +194 -0
- package/dist/Basic.Profile.Domain/Config/Api/Admin/Read.jsx +58 -0
- package/dist/Basic.Profile.Domain/Config/Api/Admin/Write.jsx +23 -0
- package/dist/Basic.Profile.Domain/Config/Api/FlareAdminShell/Read.jsx +35 -0
- package/dist/Basic.Profile.Domain/Config/Commands.jsx +72 -0
- package/dist/Basic.Profile.Domain/Config/ConfigCommandHandler.jsx +197 -0
- package/dist/Basic.Profile.Domain/Config/Dto.jsx +181 -0
- package/dist/Basic.Profile.Domain/Config/Types.jsx +152 -0
- package/dist/Basic.Profile.Domain/DateTimeProvider.jsx +23 -0
- package/dist/Basic.Profile.Domain/DomainAggregates.jsx +801 -0
- package/dist/Basic.Profile.Domain/DomainPrimitives.jsx +426 -0
- package/dist/Basic.Profile.Domain/Dto/Aggregates.jsx +564 -0
- package/dist/Basic.Profile.Domain/Dto/AnalyticsEvent.jsx +157 -0
- package/dist/Basic.Profile.Domain/Dto/Api/Backend/Common.jsx +102 -0
- package/dist/Basic.Profile.Domain/Dto/Api/Backend/Read.jsx +85 -0
- package/dist/Basic.Profile.Domain/Dto/Api/Backend/Write.jsx +16 -0
- package/dist/Basic.Profile.Domain/Dto/Api/Common.jsx +427 -0
- package/dist/Basic.Profile.Domain/Dto/Api/External/Read.jsx +118 -0
- package/dist/Basic.Profile.Domain/Dto/Api/External/ReadV2.jsx +6 -0
- package/dist/Basic.Profile.Domain/Dto/Api/External/Write.jsx +184 -0
- package/dist/Basic.Profile.Domain/Dto/Api/External/WriteV2.jsx +439 -0
- package/dist/Basic.Profile.Domain/Dto/Api/FlareAdminShell/Read.jsx +38 -0
- package/dist/Basic.Profile.Domain/Dto/Api/FlareAdminShell/Write.jsx +199 -0
- package/dist/Basic.Profile.Domain/Dto/Api/Internal/Read.jsx +125 -0
- package/dist/Basic.Profile.Domain/Dto/Audit.jsx +121 -0
- package/dist/Basic.Profile.Domain/Dto/Commands.jsx +256 -0
- package/dist/Basic.Profile.Domain/Dto/Common.jsx +84 -0
- package/dist/Basic.Profile.Domain/Dto/Events.jsx +220 -0
- package/dist/Basic.Profile.Domain/Dto/Primitives.jsx +580 -0
- package/dist/Basic.Profile.Domain/Dto/ProfileCreationModels.jsx +324 -0
- package/dist/Basic.Profile.Domain/Dto/Validation.jsx +229 -0
- package/dist/Basic.Profile.Domain/Events.jsx +64 -0
- package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Read.jsx +140 -0
- package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Validation.jsx +499 -0
- package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Write.jsx +51 -0
- package/dist/Basic.Profile.Domain/Import/Api/Read.jsx +154 -0
- package/dist/Basic.Profile.Domain/Import/CommonTypes.jsx +187 -0
- package/dist/Basic.Profile.Domain/Import/Dto.jsx +475 -0
- package/dist/Basic.Profile.Domain/Import/ImportCommandHandler.jsx +531 -0
- package/dist/Basic.Profile.Domain/Import/Types.jsx +405 -0
- package/dist/Basic.Profile.Domain/JwtPayload.jsx +44 -0
- package/dist/Basic.Profile.Domain/Metadata.jsx +257 -0
- package/dist/Basic.Profile.Domain/ProfileCommandHandler.jsx +261 -0
- package/dist/Basic.Profile.Domain/ProfileModels.jsx +59 -0
- package/dist/Basic.Profile.Domain/Utils.jsx +372 -0
- package/dist/Common/PreactCustomElement.jsx +8 -0
- package/dist/Common/Resources.jsx +20 -0
- package/dist/Common/Tailwind.jsx +8 -0
- package/dist/Common/Utils.jsx +18 -0
- package/dist/Directory/App.jsx +192 -0
- package/dist/Directory/BackendServices/Common.jsx +115 -0
- package/dist/Directory/BackendServices/ConfigService.jsx +168 -0
- package/dist/Directory/BackendServices/ImportService.jsx +137 -0
- package/dist/Directory/Common.jsx +93 -0
- package/dist/Directory/Config/Components.jsx +173 -0
- package/dist/Directory/Config/Types.jsx +187 -0
- package/dist/Directory/PastImports/PastImports.jsx +81 -0
- package/dist/Directory/ProfileImport/ProfileImport.jsx +284 -0
- package/dist/Directory/ProfileImport/Types.jsx +91 -0
- package/dist/Directory/TabNav.jsx +24 -0
- package/dist/Directory/Types.jsx +101 -0
- package/dist/Directory/User.jsx +117 -0
- package/dist/HeadlessUI/Dialog.jsx +66 -0
- package/dist/HeadlessUI/ModalDialog.jsx +74 -0
- package/dist/HeadlessUI/Switch.jsx +66 -0
- package/dist/HeadlessUI/Transition.jsx +66 -0
- package/package.json +1 -1
- package/dist/assets/delete.dcc7b157.svg +0 -5
- package/dist/assets/dialog-warning.cc77f3ba.svg +0 -5
- package/dist/assets/pencil.05fe6be6.svg +0 -5
- package/dist/index.html +0 -20
- package/dist/superhero-basic-profile.js +0 -50
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import folder_warn from "../../../src/assets/folder-warn.jpg";
|
|
2
|
+
import spinner from "../../../src/assets/spinner.jpg";
|
|
3
|
+
import check from "../../../src/assets/check.jpg";
|
|
4
|
+
import { createElement } from "react";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { reactApi } from "../../fable_modules/Feliz.2.8.0/Interop.fs.js";
|
|
7
|
+
import { int32ToString, createObj } from "../../fable_modules/fable-library-js.4.20.0/Util.js";
|
|
8
|
+
import { map as map_2, collect, empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-js.4.20.0/Seq.js";
|
|
9
|
+
import { Dropzone as Dropzone_1 } from "../../../src/Directory/ProfileImport/Dropzone.jsx";
|
|
10
|
+
import { length, map, singleton as singleton_1, append as append_1, concat, ofArray } from "../../fable_modules/fable-library-js.4.20.0/List.js";
|
|
11
|
+
import { AsyncOperationStatus$2 } from "../../Common/Utils.jsx";
|
|
12
|
+
import { View, StateModule_update, StateModule_init, Msg } from "./Types.jsx";
|
|
13
|
+
import { React_useElmish_Z6C327F2E } from "../../fable_modules/Feliz.UseElmish.2.5.0/UseElmish.fs.js";
|
|
14
|
+
import { ProgramModule_mkProgram } from "../../fable_modules/Fable.Elmish.4.0.0/program.fs.js";
|
|
15
|
+
import { replace, join } from "../../fable_modules/fable-library-js.4.20.0/String.js";
|
|
16
|
+
import { map as map_1 } from "../../fable_modules/fable-library-js.4.20.0/Array.js";
|
|
17
|
+
import { ErrorText, ImportSummary } from "../Common.jsx";
|
|
18
|
+
import { ImportService__GetImport_Z524259A4 } from "../BackendServices/ImportService.jsx";
|
|
19
|
+
|
|
20
|
+
const CsvTemplate = {
|
|
21
|
+
Csv: "First Name,Middle Name,Last Name,Email,Mobile Number,External ID,Title,Gender,DoB,Address Line 1,Address Line 2,City,State,PostCode,CountryCode",
|
|
22
|
+
Filename: "ProfileImportCsvTemplate.csv",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Images_FolderWarn = folder_warn;
|
|
26
|
+
|
|
27
|
+
export const Images_Spinner = spinner;
|
|
28
|
+
|
|
29
|
+
export const Images_Check = check;
|
|
30
|
+
|
|
31
|
+
function csvLink(csv, filename, linkText) {
|
|
32
|
+
let blob_1;
|
|
33
|
+
return createElement("a", {
|
|
34
|
+
className: "font-medium text-blue-600 underline cursor-pointer",
|
|
35
|
+
href: (blob_1 = (new Blob([csv], {
|
|
36
|
+
type: "text/csv;charset=utf-8;",
|
|
37
|
+
})), window.URL.createObjectURL(blob_1)),
|
|
38
|
+
download: filename,
|
|
39
|
+
children: linkText,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function FileSelectionForm(fileSelectionFormInputProps) {
|
|
44
|
+
let elems_5;
|
|
45
|
+
const dispatch = fileSelectionFormInputProps.dispatch;
|
|
46
|
+
const patternInput = reactApi.useState(false);
|
|
47
|
+
const setShowConfirmationModal = patternInput[1];
|
|
48
|
+
const patternInput_1 = reactApi.useState(0);
|
|
49
|
+
const resetCounter = patternInput_1[0] | 0;
|
|
50
|
+
let patternInput_2;
|
|
51
|
+
const initial_2 = new FormData();
|
|
52
|
+
patternInput_2 = reactApi.useState(initial_2);
|
|
53
|
+
const formData = patternInput_2[0];
|
|
54
|
+
return createElement("form", createObj(ofArray([["key", resetCounter], (elems_5 = toList(delay(() => append(singleton(createElement(Dropzone_1, {
|
|
55
|
+
onCancel: () => {
|
|
56
|
+
patternInput_1[1](resetCounter + 1);
|
|
57
|
+
patternInput_2[1](new FormData());
|
|
58
|
+
},
|
|
59
|
+
onSubmit: () => {
|
|
60
|
+
setShowConfirmationModal(true);
|
|
61
|
+
},
|
|
62
|
+
onFileDrop: (blob, filename) => {
|
|
63
|
+
formData.set("file", blob, filename);
|
|
64
|
+
},
|
|
65
|
+
})), delay(() => {
|
|
66
|
+
let children_2, elems_4, elems_3, value_8, elems_2, children, elems, elems_1, value_22, value_28;
|
|
67
|
+
return patternInput[0] ? singleton((children_2 = ofArray([createElement("div", {
|
|
68
|
+
className: "fixed inset-0 bg-gray-500 bg-opacity-75",
|
|
69
|
+
}), createElement("div", createObj(ofArray([["className", "fixed inset-0 z-10 overflow-y-auto"], (elems_4 = [createElement("div", createObj(ofArray([["className", "flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0"], (elems_3 = [createElement("div", createObj(ofArray([(value_8 = "relative overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl sm:my-8 sm:w-full sm:max-w-lg sm:p-6", ["className", value_8]), (elems_2 = [(children = ofArray([createElement("div", createObj(ofArray([["className", "mt-3 text-center sm:mt-5 space-y-6"], (elems = [createElement("img", {
|
|
70
|
+
src: Images_FolderWarn,
|
|
71
|
+
className: "mx-auto",
|
|
72
|
+
}), createElement("p", {
|
|
73
|
+
children: ["Please check and confirm this file is being uploaded to the correct account."],
|
|
74
|
+
}), createElement("p", {
|
|
75
|
+
children: ["Uploading files to the wrong account can cause a security breach."],
|
|
76
|
+
})], ["children", reactApi.Children.toArray(Array.from(elems))])]))), createElement("div", createObj(ofArray([["className", "mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3"], (elems_1 = [createElement("button", createObj(ofArray([["type", "button"], (value_22 = "inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 sm:col-start-2", ["className", value_22]), ["children", "I confirm"], ["onClick", (_arg_1) => {
|
|
77
|
+
dispatch(new Msg(1, [new AsyncOperationStatus$2(0, [formData])]));
|
|
78
|
+
}]]))), createElement("button", createObj(ofArray([["type", "button"], (value_28 = "mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:col-start-1 sm:mt-0", ["className", value_28]), ["children", "Cancel"], ["onClick", (_arg_2) => {
|
|
79
|
+
setShowConfirmationModal(false);
|
|
80
|
+
}]])))], ["children", reactApi.Children.toArray(Array.from(elems_1))])])))]), createElement("div", {
|
|
81
|
+
children: reactApi.Children.toArray(Array.from(children)),
|
|
82
|
+
}))], ["children", reactApi.Children.toArray(Array.from(elems_2))])])))], ["children", reactApi.Children.toArray(Array.from(elems_3))])])))], ["children", reactApi.Children.toArray(Array.from(elems_4))])])))]), createElement("div", {
|
|
83
|
+
children: reactApi.Children.toArray(Array.from(children_2)),
|
|
84
|
+
}))) : empty();
|
|
85
|
+
})))), ["children", reactApi.Children.toArray(Array.from(elems_5))])])));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function Component(componentInputProps) {
|
|
89
|
+
let elems_1, children, value_2, value_4, children_6, elems, children_2, children_4, elems_5, elems_4;
|
|
90
|
+
const onDone = componentInputProps.onDone;
|
|
91
|
+
const importService = componentInputProps.importService;
|
|
92
|
+
const dispatchFetchImports = componentInputProps.dispatchFetchImports;
|
|
93
|
+
const accountImports = componentInputProps.accountImports;
|
|
94
|
+
const accountId = componentInputProps.accountId;
|
|
95
|
+
const patternInput = React_useElmish_Z6C327F2E(() => ProgramModule_mkProgram(StateModule_init, (msg, state) => StateModule_update(dispatchFetchImports, importService, msg, state), (_arg, _arg_1) => {
|
|
96
|
+
}), undefined, undefined);
|
|
97
|
+
const dispatch = patternInput[1];
|
|
98
|
+
const dependencies_2 = [accountImports];
|
|
99
|
+
reactApi.useEffect(() => {
|
|
100
|
+
dispatch(new Msg(2, [new AsyncOperationStatus$2(1, [accountImports])]));
|
|
101
|
+
}, dependencies_2);
|
|
102
|
+
const children_20 = ofArray([createElement("div", createObj(ofArray([["className", "space-y-6"], (elems_1 = [(children = ofArray([(value_2 = "Upload a CSV file with required information (first name, last name, email) to create new partial profiles.\n The file will be validated ", value_2), createElement("b", {
|
|
103
|
+
children: ["before"],
|
|
104
|
+
}), (value_4 = " creating the profiles.\n If validation fails, the file will be rejected, and no profiles created.\n You\'ll get an error report to fix the information before re-uploading.", value_4)]), createElement("p", {
|
|
105
|
+
children: reactApi.Children.toArray(Array.from(children)),
|
|
106
|
+
})), createElement("p", {
|
|
107
|
+
children: "This feature doesn\'t update existing profiles in the account.",
|
|
108
|
+
}), (children_6 = ofArray([createElement("span", {
|
|
109
|
+
children: ["Not sure how to get started?"],
|
|
110
|
+
}), createElement("ul", createObj(ofArray([["className", "ml-6 list-disc list-outside"], (elems = [(children_2 = ofArray([csvLink(CsvTemplate.Csv, CsvTemplate.Filename, "Download"), " a blank CSV template"]), createElement("li", {
|
|
111
|
+
children: reactApi.Children.toArray(Array.from(children_2)),
|
|
112
|
+
})), (children_4 = ofArray([createElement("a", {
|
|
113
|
+
className: "cursor-pointer font-medium text-blue-600 underline",
|
|
114
|
+
children: "Read the guide",
|
|
115
|
+
target: "_blank",
|
|
116
|
+
rel: "noreferrer",
|
|
117
|
+
href: "https://coda.io/d/Network-Partners_duJlEDaJduS/How-to-import-existing-employees_suumX#_lu5Lq",
|
|
118
|
+
}), " to using the CSV importer"]), createElement("li", {
|
|
119
|
+
children: reactApi.Children.toArray(Array.from(children_4)),
|
|
120
|
+
}))], ["children", reactApi.Children.toArray(Array.from(elems))])])))]), createElement("div", {
|
|
121
|
+
children: reactApi.Children.toArray(Array.from(children_6)),
|
|
122
|
+
}))], ["children", reactApi.Children.toArray(Array.from(elems_1))])]))), createElement("div", createObj(ofArray([["className", "px-8 mt-10"], (elems_5 = [createElement("div", createObj(ofArray([["className", "border border-gray-300 w-full py-12 rounded text-center bg-white"], (elems_4 = toList(delay(() => {
|
|
123
|
+
let children_8, children_14, children_16, children_18;
|
|
124
|
+
const matchValue = patternInput[0].View;
|
|
125
|
+
switch (matchValue.tag) {
|
|
126
|
+
case 1:
|
|
127
|
+
return singleton((children_8 = ofArray([createElement("img", {
|
|
128
|
+
src: Images_Spinner,
|
|
129
|
+
className: "mx-auto animate-spin",
|
|
130
|
+
}), createElement("p", {
|
|
131
|
+
className: "mt-2",
|
|
132
|
+
children: "Validating data",
|
|
133
|
+
})]), createElement("div", {
|
|
134
|
+
children: reactApi.Children.toArray(Array.from(children_8)),
|
|
135
|
+
})));
|
|
136
|
+
case 2: {
|
|
137
|
+
const error = matchValue.fields[0];
|
|
138
|
+
return singleton((children_14 = toList(delay(() => {
|
|
139
|
+
const downloadLink = (errorList) => {
|
|
140
|
+
let elems_2;
|
|
141
|
+
return createElement("p", createObj(ofArray([["className", "mt-6"], (elems_2 = ["Download the full error report ", csvLink(join("\r\n", concat(append_1(singleton_1(singleton_1("Row,Column,Error")), map((e) => map((fieldError) => join(",", map_1((s_1) => (`"${s_1}"`), map_1((s) => replace(s, "\"", "\"\""), [int32ToString(e.RowId), fieldError.Column, fieldError.Message]))), e.FieldErrors), errorList)))), `${accountId}_validation_errors.csv`, "here"), "."], ["children", reactApi.Children.toArray(Array.from(elems_2))])])));
|
|
142
|
+
};
|
|
143
|
+
let msg_1;
|
|
144
|
+
switch (error.tag) {
|
|
145
|
+
case 1: {
|
|
146
|
+
msg_1 = createElement("p", {
|
|
147
|
+
children: ["Invalid file name"],
|
|
148
|
+
});
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case 2: {
|
|
152
|
+
msg_1 = createElement("p", {
|
|
153
|
+
children: ["CSV exceeds max row limit"],
|
|
154
|
+
});
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
case 3: {
|
|
158
|
+
msg_1 = createElement("p", {
|
|
159
|
+
children: [error.fields[0]],
|
|
160
|
+
});
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case 4: {
|
|
164
|
+
msg_1 = createElement("p", {
|
|
165
|
+
children: ["CSV does not contain any data"],
|
|
166
|
+
});
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case 5: {
|
|
170
|
+
msg_1 = createElement("p", {
|
|
171
|
+
children: ["File not uploaded, ensure a file is selected"],
|
|
172
|
+
});
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case 6: {
|
|
176
|
+
msg_1 = createElement("p", {
|
|
177
|
+
children: ["Only a single file is allowed"],
|
|
178
|
+
});
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case 8: {
|
|
182
|
+
msg_1 = createElement("p", {
|
|
183
|
+
children: ["Unknown account"],
|
|
184
|
+
});
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case 7: {
|
|
188
|
+
if (length(error.fields[0]) <= 10) {
|
|
189
|
+
const children_10 = toList(delay(() => append(singleton(createElement("p", {
|
|
190
|
+
className: "mb-3",
|
|
191
|
+
children: "The file contains the following validation error(s)",
|
|
192
|
+
})), delay(() => append(collect((err) => map_2((fieldErr) => createElement("li", {
|
|
193
|
+
children: [`Row ${err.RowId}, Column ${fieldErr.Column}: ${fieldErr.Message}`],
|
|
194
|
+
}), err.FieldErrors), error.fields[0]), delay(() => singleton(downloadLink(error.fields[0]))))))));
|
|
195
|
+
msg_1 = createElement("div", {
|
|
196
|
+
children: reactApi.Children.toArray(Array.from(children_10)),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const children_12 = ofArray([createElement("p", {
|
|
201
|
+
children: ["The file contains more than 10 validation errors"],
|
|
202
|
+
}), downloadLink(error.fields[0])]);
|
|
203
|
+
msg_1 = createElement("div", {
|
|
204
|
+
children: reactApi.Children.toArray(Array.from(children_12)),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
case 9: {
|
|
210
|
+
msg_1 = createElement("p", {
|
|
211
|
+
children: ["An import is already in progress"],
|
|
212
|
+
});
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
default:
|
|
216
|
+
msg_1 = createElement("p", {
|
|
217
|
+
children: ["Invalid file type"],
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return append(singleton(createElement("img", {
|
|
221
|
+
src: Images_FolderWarn,
|
|
222
|
+
className: "mx-auto",
|
|
223
|
+
})), delay(() => append(singleton(createElement("div", {
|
|
224
|
+
className: "mt-2",
|
|
225
|
+
children: reactApi.Children.toArray([msg_1]),
|
|
226
|
+
})), delay(() => {
|
|
227
|
+
let value_65;
|
|
228
|
+
return singleton(createElement("button", createObj(ofArray([["type", "button"], ["children", "Upload another file"], (value_65 = "mt-8 rounded-md bg-indigo-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600", ["className", value_65]), ["onClick", (_arg_2) => {
|
|
229
|
+
dispatch(new Msg(0, [new View(0, [])]));
|
|
230
|
+
}]]))));
|
|
231
|
+
}))));
|
|
232
|
+
})), createElement("div", {
|
|
233
|
+
children: reactApi.Children.toArray(Array.from(children_14)),
|
|
234
|
+
})));
|
|
235
|
+
}
|
|
236
|
+
case 3: {
|
|
237
|
+
const import$ = matchValue.fields[0];
|
|
238
|
+
return singleton((children_16 = ofArray([createElement("img", {
|
|
239
|
+
src: Images_Spinner,
|
|
240
|
+
className: "mx-auto animate-spin",
|
|
241
|
+
}), createElement("p", {
|
|
242
|
+
className: "mt-2 mb-6",
|
|
243
|
+
children: "Creating profiles",
|
|
244
|
+
}), createElement("p", {
|
|
245
|
+
children: [`Creator: ${import$.User}`],
|
|
246
|
+
}), createElement("p", {
|
|
247
|
+
children: [`Filename: ${import$.Filename}`],
|
|
248
|
+
}), createElement("p", {
|
|
249
|
+
children: [`Rows processed: ${import$.CompletedSuccessfully + import$.CompletedFailed}`],
|
|
250
|
+
}), createElement("p", {
|
|
251
|
+
children: [`Total rows: ${import$.NumberOfRecords}`],
|
|
252
|
+
})]), createElement("div", {
|
|
253
|
+
children: reactApi.Children.toArray(Array.from(children_16)),
|
|
254
|
+
})));
|
|
255
|
+
}
|
|
256
|
+
case 4: {
|
|
257
|
+
const import$_1 = matchValue.fields[0];
|
|
258
|
+
return singleton((children_18 = ofArray([createElement("img", {
|
|
259
|
+
src: Images_Check,
|
|
260
|
+
className: "mx-auto",
|
|
261
|
+
}), createElement("p", {
|
|
262
|
+
className: "mt-2 mb-6",
|
|
263
|
+
children: `${import$_1.Succeeded} Profiles successfully created`,
|
|
264
|
+
}), createElement(ImportSummary, {
|
|
265
|
+
importId: import$_1.ImportId,
|
|
266
|
+
fetchImport: (importId) => ImportService__GetImport_Z524259A4(importService, importId),
|
|
267
|
+
onDone: onDone,
|
|
268
|
+
})]), createElement("div", {
|
|
269
|
+
children: reactApi.Children.toArray(Array.from(children_18)),
|
|
270
|
+
})));
|
|
271
|
+
}
|
|
272
|
+
case 5:
|
|
273
|
+
return singleton(ErrorText(matchValue.fields[0]));
|
|
274
|
+
default:
|
|
275
|
+
return singleton(createElement(FileSelectionForm, {
|
|
276
|
+
dispatch: dispatch,
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
})), ["children", reactApi.Children.toArray(Array.from(elems_4))])])))], ["children", reactApi.Children.toArray(Array.from(elems_5))])])))]);
|
|
280
|
+
return createElement("div", {
|
|
281
|
+
children: reactApi.Children.toArray(Array.from(children_20)),
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Record, Union } from "../../fable_modules/fable-library-js.4.20.0/Types.js";
|
|
2
|
+
import { AccountImportsDto_$reflection, ImportHistoryDto_$reflection, ActiveImportDto_$reflection, PostImportError_$reflection } from "../../Basic.Profile.Domain/Import/Api/Read.jsx";
|
|
3
|
+
import { unit_type, class_type, record_type, union_type, string_type } from "../../fable_modules/fable-library-js.4.20.0/Reflection.js";
|
|
4
|
+
import { ImportService__CreateImport_D0E9224, ImportServiceModule_Types_CreateImportResult_$reflection } from "../BackendServices/ImportService.jsx";
|
|
5
|
+
import { FSharpResult$2 } from "../../fable_modules/fable-library-js.4.20.0/Result.js";
|
|
6
|
+
import { AsyncOperationStatus$2, AsyncOperationStatus$2_$reflection } from "../../Common/Utils.jsx";
|
|
7
|
+
import { Cmd_OfAsync_start as Cmd_OfAsync_start_1, Cmd_batch, Cmd_none } from "../../fable_modules/Fable.Elmish.4.0.0/cmd.fs.js";
|
|
8
|
+
import { find, ofArray, singleton, map } from "../../fable_modules/fable-library-js.4.20.0/List.js";
|
|
9
|
+
import { Cmd_OfAsync_start, Cmd_OfAsyncWith_perform } from "../../fable_modules/Fable.Elmish.4.0.0/cmd.fs.js";
|
|
10
|
+
import { singleton as singleton_1 } from "../../fable_modules/fable-library-js.4.20.0/AsyncBuilder.js";
|
|
11
|
+
import { sleep } from "../../fable_modules/fable-library-js.4.20.0/Async.js";
|
|
12
|
+
|
|
13
|
+
export class View extends Union {
|
|
14
|
+
constructor(tag, fields) {
|
|
15
|
+
super();
|
|
16
|
+
this.tag = tag;
|
|
17
|
+
this.fields = fields;
|
|
18
|
+
}
|
|
19
|
+
cases() {
|
|
20
|
+
return ["FileSelection", "Validating", "ValidationError", "ImportInProgress", "ImportComplete", "UnexpectedError"];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function View_$reflection() {
|
|
25
|
+
return union_type("Basic.Profile.UI.Superhero.Directory.ProfileImport.Types.View", [], View, () => [[], [], [["Item", PostImportError_$reflection()]], [["Item", ActiveImportDto_$reflection()]], [["Item", ImportHistoryDto_$reflection()]], [["Item", string_type]]]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class State extends Record {
|
|
29
|
+
constructor(View) {
|
|
30
|
+
super();
|
|
31
|
+
this.View = View;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function State_$reflection() {
|
|
36
|
+
return record_type("Basic.Profile.UI.Superhero.Directory.ProfileImport.Types.State", [], State, () => [["View", View_$reflection()]]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class Msg extends Union {
|
|
40
|
+
constructor(tag, fields) {
|
|
41
|
+
super();
|
|
42
|
+
this.tag = tag;
|
|
43
|
+
this.fields = fields;
|
|
44
|
+
}
|
|
45
|
+
cases() {
|
|
46
|
+
return ["SetView", "CreateImport", "FetchImports"];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function Msg_$reflection() {
|
|
51
|
+
return union_type("Basic.Profile.UI.Superhero.Directory.ProfileImport.Types.Msg", [], Msg, () => [[["Item", View_$reflection()]], [["Item", AsyncOperationStatus$2_$reflection(class_type("Browser.Types.FormData"), union_type("Microsoft.FSharp.Core.FSharpResult`2", [ImportServiceModule_Types_CreateImportResult_$reflection(), string_type], FSharpResult$2, () => [[["ResultValue", ImportServiceModule_Types_CreateImportResult_$reflection()]], [["ErrorValue", string_type]]]))]], [["Item", AsyncOperationStatus$2_$reflection(unit_type, AccountImportsDto_$reflection())]]]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function StateModule_init() {
|
|
55
|
+
return [new State(new View(0, [])), Cmd_none()];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function StateModule_update(dispatchFetchImports, importService, msg, state) {
|
|
59
|
+
let activeImport, matchValue, activeImport_1;
|
|
60
|
+
switch (msg.tag) {
|
|
61
|
+
case 1:
|
|
62
|
+
if (msg.fields[0].tag === 1) {
|
|
63
|
+
return [state, Cmd_batch(map((msg_2) => singleton((dispatch_1) => {
|
|
64
|
+
dispatch_1(msg_2);
|
|
65
|
+
}), (msg.fields[0].fields[0].tag === 1) ? singleton(new Msg(0, [new View(5, [msg.fields[0].fields[0].fields[0]])])) : ((msg.fields[0].fields[0].fields[0].tag === 1) ? singleton(new Msg(0, [new View(2, [msg.fields[0].fields[0].fields[0].fields[0]])])) : ((msg.fields[0].fields[0].fields[0].fields[0].ActiveImport == null) ? singleton(new Msg(0, [new View(5, ["New import not active"])])) : ((activeImport = msg.fields[0].fields[0].fields[0].fields[0].ActiveImport, ofArray([new Msg(0, [new View(3, [activeImport])]), new Msg(2, [new AsyncOperationStatus$2(0, [undefined])])])))))))];
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return [state, Cmd_batch(ofArray([singleton((dispatch) => {
|
|
69
|
+
dispatch(new Msg(0, [new View(1, [])]));
|
|
70
|
+
}), Cmd_OfAsyncWith_perform((x) => {
|
|
71
|
+
Cmd_OfAsync_start(x);
|
|
72
|
+
}, (formData_1) => ImportService__CreateImport_D0E9224(importService, formData_1), msg.fields[0].fields[0], (arg) => (new Msg(1, [new AsyncOperationStatus$2(1, [arg])])))]))];
|
|
73
|
+
}
|
|
74
|
+
case 2:
|
|
75
|
+
if (msg.fields[0].tag === 1) {
|
|
76
|
+
return [state, Cmd_batch(map((msg_4) => singleton((dispatch_2) => {
|
|
77
|
+
dispatch_2(msg_4);
|
|
78
|
+
}), (matchValue = state.View, (matchValue.tag === 3) ? ((msg.fields[0].fields[0].ActiveImport != null) ? ((activeImport_1 = msg.fields[0].fields[0].ActiveImport, ofArray([new Msg(0, [new View(3, [activeImport_1])]), new Msg(2, [new AsyncOperationStatus$2(0, [undefined])])]))) : singleton(new Msg(0, [new View(4, [find((h) => (h.ImportId === matchValue.fields[0].ImportId), msg.fields[0].fields[0].ImportHistory)])]))) : ((msg.fields[0].fields[0].ActiveImport != null) ? ((activeImport_1 = msg.fields[0].fields[0].ActiveImport, ofArray([new Msg(0, [new View(3, [activeImport_1])]), new Msg(2, [new AsyncOperationStatus$2(0, [undefined])])]))) : singleton(new Msg(0, [new View(0, [])]))))))];
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
Cmd_OfAsync_start_1(singleton_1.Delay(() => singleton_1.Bind(sleep(10000), () => {
|
|
82
|
+
dispatchFetchImports();
|
|
83
|
+
return singleton_1.Zero();
|
|
84
|
+
})));
|
|
85
|
+
return [state, Cmd_none()];
|
|
86
|
+
}
|
|
87
|
+
default:
|
|
88
|
+
return [new State(msg.fields[0]), Cmd_none()];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { equals, createObj } from "../fable_modules/fable-library-js.4.20.0/Util.js";
|
|
4
|
+
import { singleton, append, map, delay, toList } from "../fable_modules/fable-library-js.4.20.0/Seq.js";
|
|
5
|
+
import { Tab__get_DisplayName } from "./Types.jsx";
|
|
6
|
+
import { join } from "../fable_modules/fable-library-js.4.20.0/String.js";
|
|
7
|
+
import { reactApi } from "../fable_modules/Feliz.2.8.0/Interop.fs.js";
|
|
8
|
+
import { ofArray } from "../fable_modules/fable-library-js.4.20.0/List.js";
|
|
9
|
+
|
|
10
|
+
export function Component(componentInputProps) {
|
|
11
|
+
let elems_1, elems;
|
|
12
|
+
const setCurrentTab = componentInputProps.setCurrentTab;
|
|
13
|
+
const currentTab = componentInputProps.currentTab;
|
|
14
|
+
const tabs = componentInputProps.tabs;
|
|
15
|
+
return createElement("div", createObj(ofArray([["className", "border-b border-gray-200"], (elems_1 = [createElement("nav", createObj(ofArray([["className", "-mb-px flex space-x-8"], (elems = toList(delay(() => map((tab) => createElement("a", {
|
|
16
|
+
key: Tab__get_DisplayName(tab),
|
|
17
|
+
className: join(" ", toList(delay(() => append(equals(currentTab, tab) ? singleton("border-indigo-500 text-indigo-600") : singleton("border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 cursor-pointer"), delay(() => singleton("whitespace-nowrap border-b-2 py-4 px-1 text-sm font-medium")))))),
|
|
18
|
+
onClick: (_arg) => {
|
|
19
|
+
setCurrentTab(tab);
|
|
20
|
+
},
|
|
21
|
+
children: Tab__get_DisplayName(tab),
|
|
22
|
+
}), tabs))), ["children", reactApi.Children.toArray(Array.from(elems))])])))], ["children", reactApi.Children.toArray(Array.from(elems_1))])])));
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Record, Union } from "../fable_modules/fable-library-js.4.20.0/Types.js";
|
|
2
|
+
import { unit_type, record_type, string_type, union_type } from "../fable_modules/fable-library-js.4.20.0/Reflection.js";
|
|
3
|
+
import { AccountImportsDto_$reflection } from "../Basic.Profile.Domain/Import/Api/Read.jsx";
|
|
4
|
+
import { FSharpResult$2 } from "../fable_modules/fable-library-js.4.20.0/Result.js";
|
|
5
|
+
import { Deferred$1, Deferred$1_$reflection } from "../fable_modules/Feliz.UseDeferred.2.0.0/UseDeferred.fs.js";
|
|
6
|
+
import { AsyncOperationStatus$2, AsyncOperationStatus$2_$reflection } from "../Common/Utils.jsx";
|
|
7
|
+
import { singleton } from "../fable_modules/fable-library-js.4.20.0/List.js";
|
|
8
|
+
import { Cmd_none } from "../fable_modules/Fable.Elmish.4.0.0/cmd.fs.js";
|
|
9
|
+
import { Cmd_OfAsync_start, Cmd_OfAsyncWith_perform } from "../fable_modules/Fable.Elmish.4.0.0/cmd.fs.js";
|
|
10
|
+
|
|
11
|
+
export class Tab extends Union {
|
|
12
|
+
constructor(tag, fields) {
|
|
13
|
+
super();
|
|
14
|
+
this.tag = tag;
|
|
15
|
+
this.fields = fields;
|
|
16
|
+
}
|
|
17
|
+
cases() {
|
|
18
|
+
return ["Import", "Configuration"];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function Tab_$reflection() {
|
|
23
|
+
return union_type("Basic.Profile.UI.Superhero.Directory.Types.Tab", [], Tab, () => [[["Item", ImportTabs_$reflection()]], []]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class ImportTabs extends Union {
|
|
27
|
+
constructor(tag, fields) {
|
|
28
|
+
super();
|
|
29
|
+
this.tag = tag;
|
|
30
|
+
this.fields = fields;
|
|
31
|
+
}
|
|
32
|
+
cases() {
|
|
33
|
+
return ["ProfileImport", "PastImports"];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function ImportTabs_$reflection() {
|
|
38
|
+
return union_type("Basic.Profile.UI.Superhero.Directory.Types.ImportTabs", [], ImportTabs, () => [[], []]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function Tab__get_DisplayName(this$) {
|
|
42
|
+
if (this$.tag === 1) {
|
|
43
|
+
return "Configuration";
|
|
44
|
+
}
|
|
45
|
+
else if (this$.fields[0].tag === 1) {
|
|
46
|
+
return "Past Imports";
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return "Profile Import";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class State extends Record {
|
|
54
|
+
constructor(CurrentTab, AccountImports) {
|
|
55
|
+
super();
|
|
56
|
+
this.CurrentTab = CurrentTab;
|
|
57
|
+
this.AccountImports = AccountImports;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function State_$reflection() {
|
|
62
|
+
return record_type("Basic.Profile.UI.Superhero.Directory.Types.State", [], State, () => [["CurrentTab", Tab_$reflection()], ["AccountImports", Deferred$1_$reflection(union_type("Microsoft.FSharp.Core.FSharpResult`2", [AccountImportsDto_$reflection(), string_type], FSharpResult$2, () => [[["ResultValue", AccountImportsDto_$reflection()]], [["ErrorValue", string_type]]]))]]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class Msg extends Union {
|
|
66
|
+
constructor(tag, fields) {
|
|
67
|
+
super();
|
|
68
|
+
this.tag = tag;
|
|
69
|
+
this.fields = fields;
|
|
70
|
+
}
|
|
71
|
+
cases() {
|
|
72
|
+
return ["SetCurrentTab", "FetchImports"];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function Msg_$reflection() {
|
|
77
|
+
return union_type("Basic.Profile.UI.Superhero.Directory.Types.Msg", [], Msg, () => [[["Item", Tab_$reflection()]], [["Item", AsyncOperationStatus$2_$reflection(unit_type, union_type("Microsoft.FSharp.Core.FSharpResult`2", [AccountImportsDto_$reflection(), string_type], FSharpResult$2, () => [[["ResultValue", AccountImportsDto_$reflection()]], [["ErrorValue", string_type]]]))]]]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function StateModule_init() {
|
|
81
|
+
return [new State(new Tab(0, [new ImportTabs(0, [])]), new Deferred$1(0, [])), singleton((dispatch) => {
|
|
82
|
+
dispatch(new Msg(1, [new AsyncOperationStatus$2(0, [undefined])]));
|
|
83
|
+
})];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function StateModule_update(fetchImports, msg, state) {
|
|
87
|
+
if (msg.tag === 1) {
|
|
88
|
+
if (msg.fields[0].tag === 1) {
|
|
89
|
+
return [new State(state.CurrentTab, new Deferred$1(2, [msg.fields[0].fields[0]])), Cmd_none()];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return [state, Cmd_OfAsyncWith_perform((x) => {
|
|
93
|
+
Cmd_OfAsync_start(x);
|
|
94
|
+
}, fetchImports, undefined, (arg) => (new Msg(1, [new AsyncOperationStatus$2(1, [arg])])))];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return [new State(msg.fields[0], state.AccountImports), Cmd_none()];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Record, Union } from "../fable_modules/fable-library-js.4.20.0/Types.js";
|
|
2
|
+
import { anonRecord_type, array_type, record_type, list_type, option_type, union_type, string_type } from "../fable_modules/fable-library-js.4.20.0/Reflection.js";
|
|
3
|
+
import { ofArray, empty, contains } from "../fable_modules/fable-library-js.4.20.0/List.js";
|
|
4
|
+
import { uncurry2, defaultOf, safeHash, equals } from "../fable_modules/fable-library-js.4.20.0/Util.js";
|
|
5
|
+
import { some } from "../fable_modules/fable-library-js.4.20.0/Option.js";
|
|
6
|
+
import { split } from "../fable_modules/fable-library-js.4.20.0/String.js";
|
|
7
|
+
import { map, item, equalsWith } from "../fable_modules/fable-library-js.4.20.0/Array.js";
|
|
8
|
+
import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "../fable_modules/Thoth.Json.10.2.0/Decode.fs.js";
|
|
9
|
+
import { CaseStrategy } from "../fable_modules/Thoth.Json.10.2.0/Types.fs.js";
|
|
10
|
+
import { FSharpResult$2 } from "../fable_modules/fable-library-js.4.20.0/Result.js";
|
|
11
|
+
|
|
12
|
+
export class AccessRole extends Union {
|
|
13
|
+
constructor(Item) {
|
|
14
|
+
super();
|
|
15
|
+
this.tag = 0;
|
|
16
|
+
this.fields = [Item];
|
|
17
|
+
}
|
|
18
|
+
cases() {
|
|
19
|
+
return ["AccessRole"];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function AccessRole_$reflection() {
|
|
24
|
+
return union_type("Basic.Profile.UI.Superhero.Directory.AccessRole", [], AccessRole, () => [[["Item", string_type]]]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function AccessRoleModule_create(str) {
|
|
28
|
+
return new AccessRole(str);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function AccessRoleModule_value(_arg) {
|
|
32
|
+
return _arg.fields[0];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const AccessRoleModule_ImportRole = new AccessRole("BasicProfile.ImportData");
|
|
36
|
+
|
|
37
|
+
const AccessRoleModule_AccessConfigRole = new AccessRole("BasicProfile.AccessConfig");
|
|
38
|
+
|
|
39
|
+
const AccessRoleModule_EditConfigRole = new AccessRole("BasicProfile.EditConfig");
|
|
40
|
+
|
|
41
|
+
export function AccessRoleModule_$007CImport$007C_$007C(roles) {
|
|
42
|
+
if (contains(AccessRoleModule_ImportRole, roles, {
|
|
43
|
+
Equals: equals,
|
|
44
|
+
GetHashCode: safeHash,
|
|
45
|
+
})) {
|
|
46
|
+
return some(undefined);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function AccessRoleModule_$007CAccessConfig$007C_$007C(roles) {
|
|
54
|
+
if (contains(AccessRoleModule_AccessConfigRole, roles, {
|
|
55
|
+
Equals: equals,
|
|
56
|
+
GetHashCode: safeHash,
|
|
57
|
+
})) {
|
|
58
|
+
return some(undefined);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function AccessRoleModule_$007CEditConfig$007C_$007C(roles) {
|
|
66
|
+
if (contains(AccessRoleModule_EditConfigRole, roles, {
|
|
67
|
+
Equals: equals,
|
|
68
|
+
GetHashCode: safeHash,
|
|
69
|
+
})) {
|
|
70
|
+
return some(undefined);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function AccessRoleModule_canEditConfig(roles) {
|
|
78
|
+
if (AccessRoleModule_$007CEditConfig$007C_$007C(roles) != null) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class User extends Record {
|
|
87
|
+
constructor(UserName, Roles) {
|
|
88
|
+
super();
|
|
89
|
+
this.UserName = UserName;
|
|
90
|
+
this.Roles = Roles;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function User_$reflection() {
|
|
95
|
+
return record_type("Basic.Profile.UI.Superhero.Directory.User", [], User, () => [["UserName", option_type(string_type)], ["Roles", list_type(AccessRole_$reflection())]]);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function UserModule_create(accessToken) {
|
|
99
|
+
let userDetails;
|
|
100
|
+
const matchValue = split((accessToken == null) ? "" : accessToken, ["."], undefined, 0);
|
|
101
|
+
if (!equalsWith((x, y) => (x === y), matchValue, defaultOf()) && (matchValue.length === 3)) {
|
|
102
|
+
const arg = item(1, matchValue);
|
|
103
|
+
const s = atob(arg);
|
|
104
|
+
userDetails = fromString(uncurry2(Auto_generateBoxedDecoder_Z6670B51(anonRecord_type(["Name", string_type], ["Roles", array_type(string_type)]), new CaseStrategy(1, []), undefined)), s);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
userDetails = (new FSharpResult$2(1, ["Failed to identify the user"]));
|
|
108
|
+
}
|
|
109
|
+
if (userDetails.tag === 1) {
|
|
110
|
+
return new User(undefined, empty());
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const ud = userDetails.fields[0];
|
|
114
|
+
return new User(ud.Name, ofArray(map(AccessRoleModule_create, ud.Roles)));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|