wcz-layout 8.0.3 → 8.0.4
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.
Potentially problematic release.
This version of wcz-layout might be problematic. Click here for more details.
- package/dist/Approval-BSQHVGsm.js.map +1 -1
- package/dist/components.js +18 -18
- package/dist/components.js.map +1 -1
- package/dist/data/client.d.ts +1 -1
- package/dist/data/client.js +2 -2
- package/dist/data/client.js.map +1 -1
- package/dist/data/server.d.ts +1 -1
- package/dist/data/server.js +6 -4
- package/dist/data/server.js.map +1 -1
- package/dist/{env-szOeLEuD.js → env-Dgbk8SQN.js} +5 -5
- package/dist/env-Dgbk8SQN.js.map +1 -0
- package/dist/{file-DSohGVd1.js → file-BHdm6ob1.js} +6 -4
- package/dist/file-BHdm6ob1.js.map +1 -0
- package/dist/{file-B2VFf-iX.js → file-DNF9kxdN.js} +2 -2
- package/dist/{file-B2VFf-iX.js.map → file-DNF9kxdN.js.map} +1 -1
- package/dist/hooks.js +2 -2
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/middleware.js +2 -2
- package/dist/middleware.js.map +1 -1
- package/dist/models.d.ts +4 -4
- package/dist/{msalServer-DwpEEthz.js → msalServer-coQaBOlr.js} +2 -2
- package/dist/{msalServer-DwpEEthz.js.map → msalServer-coQaBOlr.js.map} +1 -1
- package/dist/{peoplesoft-CzeJCaYK.d.ts → peoplesoft-B9kmi9rI.d.ts} +5 -5
- package/dist/{peoplesoft-COFvPG-L.js → peoplesoft-CYSlmcwI.js} +9 -5
- package/dist/peoplesoft-CYSlmcwI.js.map +1 -0
- package/dist/{useDialogs-DBcNu-LV.js → useDialogs-BQEh6of8.js} +7 -7
- package/dist/useDialogs-BQEh6of8.js.map +1 -0
- package/dist/{utils-CBa4vtgn.js → utils-B7LPctqx.js} +2 -2
- package/dist/utils-B7LPctqx.js.map +1 -0
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/env-szOeLEuD.js.map +0 -1
- package/dist/file-DSohGVd1.js.map +0 -1
- package/dist/peoplesoft-COFvPG-L.js.map +0 -1
- package/dist/useDialogs-DBcNu-LV.js.map +0 -1
- package/dist/utils-CBa4vtgn.js.map +0 -1
package/dist/models.d.ts
CHANGED
|
@@ -256,10 +256,6 @@ declare const ApprovalSchema: z$1.ZodObject<{
|
|
|
256
256
|
type Approval = z$1.infer<typeof ApprovalSchema>;
|
|
257
257
|
declare const CreateApprovalSchema: z$1.ZodObject<{
|
|
258
258
|
number: z$1.ZodOptional<z$1.ZodString>;
|
|
259
|
-
type: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodEnum<{
|
|
260
|
-
Single: "Single";
|
|
261
|
-
Batch: "Batch";
|
|
262
|
-
}>>>;
|
|
263
259
|
status: z$1.ZodEnum<{
|
|
264
260
|
WaitingForApproval: "WaitingForApproval";
|
|
265
261
|
Approved: "Approved";
|
|
@@ -268,6 +264,10 @@ declare const CreateApprovalSchema: z$1.ZodObject<{
|
|
|
268
264
|
Withdrawn: "Withdrawn";
|
|
269
265
|
Cancelled: "Cancelled";
|
|
270
266
|
}>;
|
|
267
|
+
type: z$1.ZodOptional<z$1.ZodDefault<z$1.ZodEnum<{
|
|
268
|
+
Single: "Single";
|
|
269
|
+
Batch: "Batch";
|
|
270
|
+
}>>>;
|
|
271
271
|
id: z$1.ZodUUID;
|
|
272
272
|
applicationName: z$1.ZodString;
|
|
273
273
|
emailBody: z$1.ZodString;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as serverEnv } from "./env-
|
|
1
|
+
import { n as serverEnv } from "./env-Dgbk8SQN.js";
|
|
2
2
|
import { scopes } from "virtual:wcz-layout";
|
|
3
3
|
import { createServerOnlyFn } from "@tanstack/react-start";
|
|
4
4
|
import { ConfidentialClientApplication } from "@azure/msal-node";
|
|
@@ -44,4 +44,4 @@ const getAppToken = createServerOnlyFn(async (scopeKey) => {
|
|
|
44
44
|
//#endregion
|
|
45
45
|
export { getTokenOnBehalfOf as n, getAppToken as t };
|
|
46
46
|
|
|
47
|
-
//# sourceMappingURL=msalServer-
|
|
47
|
+
//# sourceMappingURL=msalServer-coQaBOlr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msalServer-
|
|
1
|
+
{"version":3,"file":"msalServer-coQaBOlr.js","names":["createServerOnlyFn","ConfidentialClientApplication","scopes","definedScopes","serverEnv","ccaInstance","getCCA","auth","clientId","ENTRA_CLIENT_ID","clientSecret","ENTRA_CLIENT_SECRET","authority","ENTRA_TENANT_ID","getTokenOnBehalfOf","userToken","scopeKey","Promise","cca","result","acquireTokenOnBehalfOf","oboAssertion","Error","accessToken","getAppToken","defaultScopes","map","scope","lastSlash","lastIndexOf","baseUri","substring","uniqueScopes","Set","acquireTokenByClientCredential"],"sources":["../src/lib/auth/msalServer.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport { ConfidentialClientApplication } from \"@azure/msal-node\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport { serverEnv } from \"~/env\";\n\n// Singleton instance for server\nlet ccaInstance: ConfidentialClientApplication | null = null;\nfunction getCCA(): ConfidentialClientApplication {\n ccaInstance ??= new ConfidentialClientApplication({\n auth: {\n clientId: serverEnv.ENTRA_CLIENT_ID,\n clientSecret: serverEnv.ENTRA_CLIENT_SECRET,\n authority: `https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}`,\n },\n });\n return ccaInstance;\n}\n\n/**\n * On-Behalf-Of flow: Exchange user token for a token to call downstream API\n * Use when: Server needs to call microservice on behalf of the logged-in user\n */\nexport const getTokenOnBehalfOf = createServerOnlyFn(\n async (userToken: string, scopeKey: keyof typeof definedScopes): Promise<string> => {\n const cca = getCCA();\n const scopes = [...definedScopes[scopeKey]];\n const result = await cca.acquireTokenOnBehalfOf({\n oboAssertion: userToken,\n scopes,\n });\n if (!result) throw new Error(\"Failed to acquire OBO token\");\n return result.accessToken;\n },\n);\n\n/**\n * Client Credentials flow: Get app-only token (no user context)\n * Use when: Background jobs, scheduled tasks, service-to-service calls\n */\nexport const getAppToken = createServerOnlyFn(\n async (scopeKey: keyof typeof definedScopes): Promise<string> => {\n const cca = getCCA();\n const scopes = definedScopes[scopeKey];\n const defaultScopes = scopes.map((scope) => {\n const lastSlash = scope.lastIndexOf(\"/\");\n const baseUri = scope.substring(0, lastSlash);\n return `${baseUri}/.default`;\n });\n const uniqueScopes = [...new Set(defaultScopes)];\n const result = await cca.acquireTokenByClientCredential({ scopes: uniqueScopes });\n if (!result) throw new Error(\"Failed to acquire app token\");\n return result.accessToken;\n },\n);\n"],"mappings":";;;;;AAMA,IAAIK,cAAoD;AACxD,SAASC,SAAwC;AAC/CD,iBAAgB,IAAIJ,8BAA8B,EAChDM,MAAM;EACJC,UAAUJ,UAAUK;EACpBC,cAAcN,UAAUO;EACxBC,WAAW,qCAAqCR,UAAUS;EAC5D,EACD,CAAC;AACF,QAAOR;;;;;;AAOT,MAAaS,qBAAqBd,mBAChC,OAAOe,WAAmBC,aAA0D;CAClF,MAAME,MAAMZ,QAAQ;CACpB,MAAMJ,WAAS,CAAC,GAAGC,OAAca,UAAU;CAC3C,MAAMG,SAAS,MAAMD,IAAIE,uBAAuB;EAC9CC,cAAcN;EACdb,QAAAA;EACD,CAAC;AACF,KAAI,CAACiB,OAAQ,OAAM,IAAIG,MAAM,8BAA8B;AAC3D,QAAOH,OAAOI;EAEjB;;;;;AAMD,MAAaC,cAAcxB,mBACzB,OAAOgB,aAA0D;CAC/D,MAAME,MAAMZ,QAAQ;CAEpB,MAAMmB,gBADStB,OAAca,UACAU,KAAKC,UAAU;EAC1C,MAAMC,YAAYD,MAAME,YAAY,IAAI;AAExC,SAAO,GADSF,MAAMI,UAAU,GAAGH,UAClB,CAAA;GACjB;CACF,MAAMI,eAAe,CAAC,GAAG,IAAIC,IAAIR,cAAc,CAAC;CAChD,MAAMN,SAAS,MAAMD,IAAIgB,+BAA+B,EAAEhC,QAAQ8B,cAAc,CAAC;AACjF,KAAI,CAACb,OAAQ,OAAM,IAAIG,MAAM,8BAA8B;AAC3D,QAAOH,OAAOI;EAEjB"}
|
|
@@ -256,10 +256,6 @@ declare const getApproval: _$_tanstack_start_client_core0.RequiredFetcher<undefi
|
|
|
256
256
|
}>>;
|
|
257
257
|
declare const createApproval: _$_tanstack_start_client_core0.RequiredFetcher<undefined, z.ZodObject<{
|
|
258
258
|
number: z.ZodOptional<z.ZodString>;
|
|
259
|
-
type: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
260
|
-
Single: "Single";
|
|
261
|
-
Batch: "Batch";
|
|
262
|
-
}>>>;
|
|
263
259
|
status: z.ZodEnum<{
|
|
264
260
|
WaitingForApproval: "WaitingForApproval";
|
|
265
261
|
Approved: "Approved";
|
|
@@ -268,6 +264,10 @@ declare const createApproval: _$_tanstack_start_client_core0.RequiredFetcher<und
|
|
|
268
264
|
Withdrawn: "Withdrawn";
|
|
269
265
|
Cancelled: "Cancelled";
|
|
270
266
|
}>;
|
|
267
|
+
type: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
268
|
+
Single: "Single";
|
|
269
|
+
Batch: "Batch";
|
|
270
|
+
}>>>;
|
|
271
271
|
id: z.ZodUUID;
|
|
272
272
|
applicationName: z.ZodString;
|
|
273
273
|
emailBody: z.ZodString;
|
|
@@ -1078,4 +1078,4 @@ declare const getCompanyGeneralManager: _$_tanstack_start_client_core0.RequiredF
|
|
|
1078
1078
|
}>>;
|
|
1079
1079
|
//#endregion
|
|
1080
1080
|
export { UpdateFileMetaSchema as A, uploadFile as B, createApproval as C, withdrawApproval as D, resubmitApproval as E, downloadFile as F, getFile as I, getFileMetas as L, UploadFileResult as M, batchDeleteFiles as N, FileSchema as O, deleteFile as P, getFileThumbnail as R, cancelApproval as S, getApprovals as T, getPreviousEmployeeIds as _, getActiveEmployees as a, GetApprovalsSchema as b, getDepartmentEmployees as c, getEmployeeByEmployeeId as d, getEmployeeGeneralManager as f, getEmployees as g, getEmployeeSupervisor as h, SearchEmployeesSchema as i, UploadFileMetaSchema as j, GetFileMetasSchema as k, getDepartmentManager as l, getEmployeeSubordinates as m, DepartmentIdSchema as n, getCompanyGeneralManager as o, getEmployeeManager as p, EmployeeIdSchema as r, getDepartmentById as s, CompanyCodeSchema as t, getDepartments as u, searchEmployees as v, getApproval as w, approveApproval as x, GetApprovalSchema as y, updateFileMeta as z };
|
|
1081
|
-
//# sourceMappingURL=peoplesoft-
|
|
1081
|
+
//# sourceMappingURL=peoplesoft-B9kmi9rI.d.ts.map
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { n as serverEnv } from "./env-
|
|
2
|
-
import { p as createExternalApi } from "./file-
|
|
1
|
+
import { n as serverEnv } from "./env-Dgbk8SQN.js";
|
|
2
|
+
import { p as createExternalApi } from "./file-BHdm6ob1.js";
|
|
3
3
|
import { a as ResubmitApprovalSchema, i as CreateApprovalSchema, l as ApprovalStepResult, n as ApproveApprovalSchema, o as WithdrawApprovalSchema, r as CancelApprovalSchema, s as ApprovalStatus } from "./Approval-BSQHVGsm.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { createServerFn, createServerOnlyFn } from "@tanstack/react-start";
|
|
6
6
|
//#region src/queries/server/approval.ts
|
|
7
7
|
let approvalApi = null;
|
|
8
8
|
const getApprovalApi = createServerOnlyFn(() => {
|
|
9
|
-
|
|
9
|
+
const baseUrl = serverEnv.APPROVAL_BASE_URL;
|
|
10
|
+
if (!baseUrl) throw new Error("APPROVAL_BASE_URL is not defined in server environment variables.");
|
|
11
|
+
approvalApi ??= createExternalApi(baseUrl, "approval");
|
|
10
12
|
return approvalApi;
|
|
11
13
|
});
|
|
12
14
|
const GetApprovalsSchema = z.object({
|
|
@@ -73,7 +75,9 @@ const cancelApproval = createServerFn({ method: "POST" }).inputValidator(CancelA
|
|
|
73
75
|
//#region src/queries/server/peoplesoft.ts
|
|
74
76
|
let peopleSoftApi = null;
|
|
75
77
|
const getPeopleSoftApi = createServerOnlyFn(() => {
|
|
76
|
-
|
|
78
|
+
const baseUrl = serverEnv.PS_BASE_URL;
|
|
79
|
+
if (!baseUrl) throw new Error("PS_BASE_URL is not defined in server environment variables.");
|
|
80
|
+
peopleSoftApi ??= createExternalApi(baseUrl, "ps");
|
|
77
81
|
return peopleSoftApi;
|
|
78
82
|
});
|
|
79
83
|
const SearchEmployeesSchema = z.object({ searchTerm: z.string().min(1) });
|
|
@@ -167,4 +171,4 @@ const getCompanyGeneralManager = createServerFn({ method: "GET" }).inputValidato
|
|
|
167
171
|
//#endregion
|
|
168
172
|
export { createApproval as C, withdrawApproval as D, resubmitApproval as E, cancelApproval as S, getApprovals as T, getPreviousEmployeeIds as _, getActiveEmployees as a, GetApprovalsSchema as b, getDepartmentEmployees as c, getEmployeeByEmployeeId as d, getEmployeeGeneralManager as f, getEmployees as g, getEmployeeSupervisor as h, SearchEmployeesSchema as i, getDepartmentManager as l, getEmployeeSubordinates as m, DepartmentIdSchema as n, getCompanyGeneralManager as o, getEmployeeManager as p, EmployeeIdSchema as r, getDepartmentById as s, CompanyCodeSchema as t, getDepartments as u, searchEmployees as v, getApproval as w, approveApproval as x, GetApprovalSchema as y };
|
|
169
173
|
|
|
170
|
-
//# sourceMappingURL=peoplesoft-
|
|
174
|
+
//# sourceMappingURL=peoplesoft-CYSlmcwI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peoplesoft-CYSlmcwI.js","names":["createServerFn","createServerOnlyFn","AxiosInstance","z","serverEnv","ApproveApprovalSchema","CancelApprovalSchema","CreateApprovalSchema","ResubmitApprovalSchema","WithdrawApprovalSchema","Approval","ApprovalStatus","ApprovalStepResult","createExternalApi","approvalApi","getApprovalApi","baseUrl","APPROVAL_BASE_URL","Error","GetApprovalsSchema","object","appName","string","min","max","status","optional","approverEmployeeId","stepResult","GetApprovalSchema","id","uuid","getApprovals","method","inputValidator","handler","data","api","queryParams","URLSearchParams","append","toString","request","Array","url","then","r","getApproval","createApproval","approveApproval","resubmitApproval","withdrawApproval","cancelApproval","createServerFn","createServerOnlyFn","AxiosInstance","z","serverEnv","Department","Employee","createExternalApi","peopleSoftApi","getPeopleSoftApi","baseUrl","PS_BASE_URL","Error","SearchEmployeesSchema","object","searchTerm","string","min","EmployeeIdSchema","employeeId","DepartmentIdSchema","departmentId","CompanyCodeSchema","companyCode","searchEmployees","method","inputValidator","handler","data","api","request","Array","url","encodeURIComponent","then","r","getEmployees","getActiveEmployees","getEmployeeByEmployeeId","getPreviousEmployeeIds","getEmployeeSupervisor","getEmployeeSubordinates","getEmployeeManager","getEmployeeGeneralManager","getDepartments","getDepartmentById","getDepartmentManager","getDepartmentEmployees","getCompanyGeneralManager"],"sources":["../src/queries/server/approval.ts","../src/queries/server/peoplesoft.ts"],"sourcesContent":["import { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\nimport type { AxiosInstance } from \"axios\";\nimport { z } from \"zod\";\nimport { serverEnv } from \"~/env\";\nimport {\n ApproveApprovalSchema,\n CancelApprovalSchema,\n CreateApprovalSchema,\n ResubmitApprovalSchema,\n WithdrawApprovalSchema,\n} from \"~/models/approval/Approval\";\nimport type { Approval } from \"~/models/approval/Approval\";\nimport { ApprovalStatus } from \"~/models/approval/ApprovalStatus\";\nimport { ApprovalStepResult } from \"~/models/approval/ApprovalStepResult\";\nimport { createExternalApi } from \"~/queries/server/externalApi\";\n\nlet approvalApi: AxiosInstance | null = null;\nconst getApprovalApi = createServerOnlyFn((): AxiosInstance => {\n const baseUrl = serverEnv.APPROVAL_BASE_URL;\n if (!baseUrl)\n throw new Error(\"APPROVAL_BASE_URL is not defined in server environment variables.\");\n approvalApi ??= createExternalApi(baseUrl, \"approval\");\n return approvalApi;\n});\n\nexport const GetApprovalsSchema = z.object({\n appName: z.string().min(1).max(255),\n status: ApprovalStatus.optional(),\n approverEmployeeId: z.string().min(1).max(20).optional(),\n stepResult: ApprovalStepResult.optional(),\n});\n\nexport const GetApprovalSchema = z.object({\n id: z.uuid(),\n});\n\nexport const getApprovals = createServerFn({ method: \"GET\" })\n .inputValidator(GetApprovalsSchema)\n .handler(async ({ data }) => {\n const api = getApprovalApi();\n const queryParams = new URLSearchParams();\n queryParams.append(\"applicationName\", data.appName);\n if (data.status) queryParams.append(\"status\", data.status.toString());\n if (data.approverEmployeeId) queryParams.append(\"approverEmployeeId\", data.approverEmployeeId);\n if (data.stepResult) queryParams.append(\"stepResult\", data.stepResult.toString());\n\n return api\n .request<Array<Approval>>({\n url: `/Requests/Requests?${queryParams.toString()}`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getApproval = createServerFn({ method: \"GET\" })\n .inputValidator(GetApprovalSchema)\n .handler(async ({ data }) => {\n const api = getApprovalApi();\n return api\n .request<Approval>({\n url: `/Requests/${data.id}`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const createApproval = createServerFn({ method: \"POST\" })\n .inputValidator(CreateApprovalSchema)\n .handler(async ({ data }) => {\n const api = getApprovalApi();\n return api\n .request<Approval>({\n url: `/Requests`,\n method: \"POST\",\n data,\n })\n .then((r) => r.data);\n });\n\nexport const approveApproval = createServerFn({ method: \"POST\" })\n .inputValidator(ApproveApprovalSchema)\n .handler(async ({ data }) => {\n const api = getApprovalApi();\n return api\n .request<Approval>({\n url: `/Requests/${data.id}/single-approval`,\n method: \"POST\",\n data,\n })\n .then((r) => r.data);\n });\n\nexport const resubmitApproval = createServerFn({ method: \"POST\" })\n .inputValidator(ResubmitApprovalSchema)\n .handler(async ({ data }) => {\n const api = getApprovalApi();\n return api\n .request<Approval>({\n url: `/Requests/${data.id}/resubmit`,\n method: \"POST\",\n data,\n })\n .then((r) => r.data);\n });\n\nexport const withdrawApproval = createServerFn({ method: \"POST\" })\n .inputValidator(WithdrawApprovalSchema)\n .handler(async ({ data }) => {\n const api = getApprovalApi();\n return api\n .request<void>({\n url: `/Requests/${data.id}/withdraw`,\n method: \"POST\",\n data,\n })\n .then((r) => r.data);\n });\n\nexport const cancelApproval = createServerFn({ method: \"POST\" })\n .inputValidator(CancelApprovalSchema)\n .handler(async ({ data }) => {\n const api = getApprovalApi();\n return api\n .request<void>({\n url: `/Requests/${data.id}/cancel`,\n method: \"POST\",\n data,\n })\n .then((r) => r.data);\n });\n","import { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\nimport type { AxiosInstance } from \"axios\";\nimport { z } from \"zod\";\nimport { serverEnv } from \"~/env\";\nimport type { Department } from \"~/models/peoplesoft/Department\";\nimport type { Employee } from \"~/models/peoplesoft/Employee\";\nimport { createExternalApi } from \"~/queries/server/externalApi\";\n\nlet peopleSoftApi: AxiosInstance | null = null;\nconst getPeopleSoftApi = createServerOnlyFn((): AxiosInstance => {\n const baseUrl = serverEnv.PS_BASE_URL;\n if (!baseUrl) throw new Error(\"PS_BASE_URL is not defined in server environment variables.\");\n peopleSoftApi ??= createExternalApi(baseUrl, \"ps\");\n return peopleSoftApi;\n});\n\nexport const SearchEmployeesSchema = z.object({\n searchTerm: z.string().min(1),\n});\n\nexport const EmployeeIdSchema = z.object({\n employeeId: z.string().min(1),\n});\n\nexport const DepartmentIdSchema = z.object({\n departmentId: z.string().min(1),\n});\n\nexport const CompanyCodeSchema = z.object({\n companyCode: z.string().min(1),\n});\n\nexport const searchEmployees = createServerFn({ method: \"GET\" })\n .inputValidator(SearchEmployeesSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Array<Employee>>({\n url: `/v1/employee?search=${encodeURIComponent(data.searchTerm)}`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getEmployees = createServerFn({ method: \"GET\" }).handler(async () => {\n const api = getPeopleSoftApi();\n return api\n .request<Array<Employee>>({ url: `/v1/employee/all`, method: \"GET\" })\n .then((r) => r.data);\n});\n\nexport const getActiveEmployees = createServerFn({ method: \"GET\" }).handler(async () => {\n const api = getPeopleSoftApi();\n return api\n .request<Array<Employee>>({ url: `/v1/employee/active`, method: \"GET\" })\n .then((r) => r.data);\n});\n\nexport const getEmployeeByEmployeeId = createServerFn({ method: \"GET\" })\n .inputValidator(EmployeeIdSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Employee>({\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getPreviousEmployeeIds = createServerFn({ method: \"GET\" }).handler(async () => {\n const api = getPeopleSoftApi();\n return api\n .request<Array<Employee>>({ url: `/v1/employee/previousIds`, method: \"GET\" })\n .then((r) => r.data);\n});\n\nexport const getEmployeeSupervisor = createServerFn({ method: \"GET\" })\n .inputValidator(EmployeeIdSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Employee>({\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}/supervisor`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getEmployeeSubordinates = createServerFn({ method: \"GET\" })\n .inputValidator(EmployeeIdSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Array<Employee>>({\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}/subordinates`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getEmployeeManager = createServerFn({ method: \"GET\" })\n .inputValidator(EmployeeIdSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Employee>({\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}/manager`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getEmployeeGeneralManager = createServerFn({ method: \"GET\" })\n .inputValidator(EmployeeIdSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Employee>({\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}/generalManager`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getDepartments = createServerFn({ method: \"GET\" }).handler(async () => {\n const api = getPeopleSoftApi();\n return api\n .request<Array<Department>>({ url: `/v1/department/all`, method: \"GET\" })\n .then((r) => r.data);\n});\n\nexport const getDepartmentById = createServerFn({ method: \"GET\" })\n .inputValidator(DepartmentIdSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Department>({\n url: `/v1/department/${encodeURIComponent(data.departmentId)}`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getDepartmentManager = createServerFn({ method: \"GET\" })\n .inputValidator(DepartmentIdSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Employee>({\n url: `/v1/department/${encodeURIComponent(data.departmentId)}/manager`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getDepartmentEmployees = createServerFn({ method: \"GET\" })\n .inputValidator(DepartmentIdSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Array<Employee>>({\n url: `/v1/department/${encodeURIComponent(data.departmentId)}/employees`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n\nexport const getCompanyGeneralManager = createServerFn({ method: \"GET\" })\n .inputValidator(CompanyCodeSchema)\n .handler(async ({ data }) => {\n const api = getPeopleSoftApi();\n return api\n .request<Employee>({\n url: `/v1/company/${encodeURIComponent(data.companyCode)}/generalManager`,\n method: \"GET\",\n })\n .then((r) => r.data);\n });\n"],"mappings":";;;;;;AAgBA,IAAIc,cAAoC;AACxC,MAAMC,iBAAiBd,yBAAwC;CAC7D,MAAMe,UAAUZ,UAAUa;AAC1B,KAAI,CAACD,QACH,OAAM,IAAIE,MAAM,oEAAoE;AACtFJ,iBAAgBD,kBAAkBG,SAAS,WAAW;AACtD,QAAOF;EACP;AAEF,MAAaK,qBAAqBhB,EAAEiB,OAAO;CACzCC,SAASlB,EAAEmB,QAAQ,CAACC,IAAI,EAAE,CAACC,IAAI,IAAI;CACnCC,QAAQd,eAAee,UAAU;CACjCC,oBAAoBxB,EAAEmB,QAAQ,CAACC,IAAI,EAAE,CAACC,IAAI,GAAG,CAACE,UAAU;CACxDE,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EACxDE,QAAQ;EACT,CAAC,CACDS,MAAMC,MAAMA,EAAEP,KAAK;EACtB"}
|
|
@@ -7,9 +7,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
//#region src/hooks/useDialogs.tsx
|
|
8
8
|
function AlertDialog(t0) {
|
|
9
9
|
const $ = c(23);
|
|
10
|
-
if ($[0] !== "
|
|
10
|
+
if ($[0] !== "40306a49a490b7e6c84c5f6c47439f8c7b6ee1f8cf1389e00101b53c362d1875") {
|
|
11
11
|
for (let $i = 0; $i < 23; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
12
|
-
$[0] = "
|
|
12
|
+
$[0] = "40306a49a490b7e6c84c5f6c47439f8c7b6ee1f8cf1389e00101b53c362d1875";
|
|
13
13
|
}
|
|
14
14
|
const { open, payload, onClose } = t0;
|
|
15
15
|
const { t } = useTranslation();
|
|
@@ -86,9 +86,9 @@ function AlertDialog(t0) {
|
|
|
86
86
|
}
|
|
87
87
|
function ConfirmDialog(t0) {
|
|
88
88
|
const $ = c(34);
|
|
89
|
-
if ($[0] !== "
|
|
89
|
+
if ($[0] !== "40306a49a490b7e6c84c5f6c47439f8c7b6ee1f8cf1389e00101b53c362d1875") {
|
|
90
90
|
for (let $i = 0; $i < 34; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
91
|
-
$[0] = "
|
|
91
|
+
$[0] = "40306a49a490b7e6c84c5f6c47439f8c7b6ee1f8cf1389e00101b53c362d1875";
|
|
92
92
|
}
|
|
93
93
|
const { open, payload, onClose } = t0;
|
|
94
94
|
const { t } = useTranslation();
|
|
@@ -195,9 +195,9 @@ function ConfirmDialog(t0) {
|
|
|
195
195
|
}
|
|
196
196
|
function useDialogs() {
|
|
197
197
|
const $ = c(10);
|
|
198
|
-
if ($[0] !== "
|
|
198
|
+
if ($[0] !== "40306a49a490b7e6c84c5f6c47439f8c7b6ee1f8cf1389e00101b53c362d1875") {
|
|
199
199
|
for (let $i = 0; $i < 10; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
200
|
-
$[0] = "
|
|
200
|
+
$[0] = "40306a49a490b7e6c84c5f6c47439f8c7b6ee1f8cf1389e00101b53c362d1875";
|
|
201
201
|
}
|
|
202
202
|
const { open, close } = useContext(DialogsContext);
|
|
203
203
|
let t0;
|
|
@@ -245,4 +245,4 @@ function useDialogs() {
|
|
|
245
245
|
//#endregion
|
|
246
246
|
export { useDialogs as t };
|
|
247
247
|
|
|
248
|
-
//# sourceMappingURL=useDialogs-
|
|
248
|
+
//# sourceMappingURL=useDialogs-BQEh6of8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDialogs-BQEh6of8.js","names":["Button","Dialog","DialogActions","DialogContent","DialogTitle","useEventCallback","useContext","useTranslation","DialogsContext","ReactNode","OpenDialogOptions","onClose","result","TResult","Promise","AlertOptions","title","ConfirmOptions","cancelText","DialogProps","payload","TPayload","open","OpenAlertDialog","message","options","OpenConfirmDialog","DialogComponent","React","ComponentType","OpenDialog","Component","CloseDialog","dialog","AlertDialogPayload","AlertDialogProps","AlertDialog","t0","$","_c","$i","Symbol","for","t","t1","t2","t3","t4","t5","t6","t7","t8","ConfirmDialogPayload","ConfirmDialogProps","ConfirmDialog","t9","t10","t11","t12","DialogHook","alert","confirm","close","useDialogs","undefined","message_0","options_0"],"sources":["../src/hooks/useDialogs.tsx"],"sourcesContent":["import {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n useEventCallback,\n} from \"@mui/material\";\nimport { useContext } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { DialogsContext } from \"../contexts/DialogsContext\";\nimport type { ReactNode } from \"react\";\n\nexport interface OpenDialogOptions<TResult> {\n onClose?: (result: TResult) => Promise<void>;\n}\n\nexport interface AlertOptions {\n title?: ReactNode;\n}\n\nexport interface ConfirmOptions {\n title?: ReactNode;\n cancelText?: ReactNode;\n}\n\nexport interface DialogProps<TPayload = undefined, TResult = void> {\n payload: TPayload;\n open: boolean;\n onClose: (result: TResult) => Promise<void>;\n}\n\nexport type OpenAlertDialog = (message: ReactNode, options?: AlertOptions) => Promise<void>;\n\nexport type OpenConfirmDialog = (message: ReactNode, options?: ConfirmOptions) => Promise<boolean>;\n\nexport type DialogComponent<TPayload, TResult> = React.ComponentType<\n DialogProps<TPayload, TResult>\n>;\n\nexport interface OpenDialog {\n <TPayload extends undefined, TResult>(\n Component: DialogComponent<TPayload, TResult>,\n payload?: TPayload,\n options?: OpenDialogOptions<TResult>,\n ): Promise<TResult>;\n <TPayload, TResult>(\n Component: DialogComponent<TPayload, TResult>,\n payload: TPayload,\n options?: OpenDialogOptions<TResult>,\n ): Promise<TResult>;\n}\n\nexport type CloseDialog = <TResult>(dialog: Promise<TResult>, result: TResult) => Promise<TResult>;\n\nexport interface AlertDialogPayload extends AlertOptions {\n message: ReactNode;\n}\n\nexport type AlertDialogProps = DialogProps<AlertDialogPayload, void>;\n\nexport function AlertDialog({ open, payload, onClose }: Readonly<AlertDialogProps>) {\n const { t } = useTranslation();\n\n return (\n <Dialog maxWidth=\"xs\" fullWidth open={open} onClose={() => onClose()} disableRestoreFocus>\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Alert\")}</DialogTitle>\n <DialogContent>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose()} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\nexport interface ConfirmDialogPayload extends ConfirmOptions {\n message: ReactNode;\n}\n\nexport type ConfirmDialogProps = DialogProps<ConfirmDialogPayload, boolean>;\n\nexport function ConfirmDialog({ open, payload, onClose }: Readonly<ConfirmDialogProps>) {\n const { t } = useTranslation();\n\n return (\n <Dialog maxWidth=\"xs\" fullWidth open={open} onClose={() => onClose(false)} disableRestoreFocus>\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Confirm\")}</DialogTitle>\n <DialogContent>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose(false)}>\n {payload.cancelText ?? t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button onClick={() => onClose(true)} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\ninterface DialogHook {\n alert: OpenAlertDialog;\n confirm: OpenConfirmDialog;\n open: OpenDialog;\n close: CloseDialog;\n}\n\nexport function useDialogs(): DialogHook {\n const { open, close } = useContext(DialogsContext);\n\n const alert = useEventCallback<OpenAlertDialog>((message, { ...options } = {}) =>\n open(AlertDialog, { ...options, message }),\n );\n\n const confirm = useEventCallback<OpenConfirmDialog>((message, { ...options } = {}) =>\n open(ConfirmDialog, { ...options, message }),\n );\n\n return { alert, confirm, open, close };\n}\n"],"mappings":";;;;;;;AA6DA,SAAOoC,YAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;AAAA,KAAAD,EAAA,OAAA,oEAAA;AAAA,OAAA,IAAAE,KAAA,GAAAA,KAAA,IAAAA,MAAA,EAAAF,GAAAE,MAAAC,OAAAC,IAAA,4BAAA;AAAAJ,IAAA,KAAA;;CAAqB,MAAA,EAAAhB,MAAAF,SAAAT,YAAA0B;CAC1B,MAAA,EAAAM,MAAcpC,gBAAgB;CAAC,IAAAqC;AAAA,KAAAN,EAAA,OAAA3B,SAAA;AAGwBiC,aAAMjC,SAAS;AAAA2B,IAAA,KAAA3B;AAAA2B,IAAA,KAAAM;OAAAA,MAAAN,EAAA;CAAA,IAAAO;AAAA,KAAAP,EAAA,OAAAlB,QAAAJ,SAAAsB,EAAA,OAAAK,GAAA;AACpDE,OAAAzB,QAAOJ,SAAU2B,EAAE,sBAAsB;AAAAL,IAAA,KAAAlB,QAAAJ;AAAAsB,IAAA,KAAAK;AAAAL,IAAA,KAAAO;OAAAA,MAAAP,EAAA;CAAA,IAAAQ;AAAA,KAAAR,EAAA,OAAAO,IAAA;AAAvDC,OAAA,oBAAC,aAAD,EAAA,UAAcD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xB,EAAA,OAAAuB,WAAAvB,EAAA,OAAAhB,MAAA;AAEKuB,OAAA;GAAAe;GAAAC;GAAAvC;GAAAwC;GAA+B;AAAAxB,IAAA,KAAAsB;AAAAtB,IAAA,KAAAwB;AAAAxB,IAAA,KAAAuB;AAAAvB,IAAA,KAAAhB;AAAAgB,IAAA,KAAAO;OAAAA,MAAAP,EAAA;AAAA,QAA/BO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as clientEnv } from "./env-
|
|
1
|
+
import { t as clientEnv } from "./env-Dgbk8SQN.js";
|
|
2
2
|
import { permissions, scopes } from "virtual:wcz-layout";
|
|
3
3
|
import { BrowserAuthError, EventType, InteractionRequiredAuthError, NavigationClient, PublicClientApplication } from "@azure/msal-browser";
|
|
4
4
|
import { createClientOnlyFn, createIsomorphicFn } from "@tanstack/react-start";
|
|
@@ -187,4 +187,4 @@ const buildUser = (payload) => ({
|
|
|
187
187
|
//#endregion
|
|
188
188
|
export { getFieldStatus as a, TanStackNavigationClient as c, pca as d, buildUser as i, getAccessToken as l, WISTRON_PRIMARY_COLOR as n, requirePermission as o, WISTRON_SECONDARY_COLOR as r, rootRouteHead as s, Platform as t, getUser as u };
|
|
189
189
|
|
|
190
|
-
//# sourceMappingURL=utils-
|
|
190
|
+
//# sourceMappingURL=utils-B7LPctqx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-B7LPctqx.js","names":["AuthenticationResult","BrowserAuthError","EventMessage","EventType","InteractionRequiredAuthError","NavigationClient","NavigationOptions","PublicClientApplication","useNavigate","createClientOnlyFn","createIsomorphicFn","scopes","definedScopes","clientEnv","buildUser","decodeJwt","User","pca","auth","clientId","VITE_ENTRA_CLIENT_ID","authority","VITE_ENTRA_TENANT_ID","redirectUri","restoreActiveAccount","getActiveAccount","firstAccount","getAllAccounts","setActiveAccount","initializeMsal","globalThis","window","undefined","initialize","addEventCallback","event","eventType","LOGIN_SUCCESS","payload","account","response","handleRedirectPromise","initializationPromise","msalReady","TanStackNavigationClient","constructor","navigate","ReturnType","navigateInternal","url","options","relative","replace","location","origin","to","noHistory","getUser","server","client","Promise","idToken","getAccessToken","scopeKey","Error","accessToken","acquireTokenSilent","error","acquireTokenRedirect","redirectError","errorCode","AnyFieldApi","permissions","clientEnv","TokenPayload","User","getUser","WISTRON_PRIMARY_COLOR","WISTRON_SECONDARY_COLOR","Platform","isAndroid","test","userAgent","isIOS","isWindows","isMacOS","navigator","RootRouteHeadOptions","manifest","rootRouteHead","options","meta","charSet","name","content","title","VITE_APP_TITLE","links","rel","sizes","href","type","requirePermission","permissionKey","user","hasPermission","Error","FormOmittedProps","getFieldStatus","field","state","isTouched","hasError","errors","length","helperText","message","toKebabCase","str","replaceAll","toLowerCase","decodeJwt","token","base64Payload","split","base64","replace","payload","decodeURIComponent","atob","map","c","charCodeAt","toString","slice","join","JSON","parse","buildUser","id","sub","email","preferred_username","department","toUpperCase","employeeId","companyName","key","allowedGroups","some","k","groups","includes"],"sources":["../src/lib/auth/msalClient.ts","../src/lib/utils.ts"],"sourcesContent":["import {\n AuthenticationResult,\n BrowserAuthError,\n EventMessage,\n EventType,\n InteractionRequiredAuthError,\n NavigationClient,\n NavigationOptions,\n PublicClientApplication,\n} from \"@azure/msal-browser\";\nimport { useNavigate } from \"@tanstack/react-router\";\nimport { createClientOnlyFn, createIsomorphicFn } from \"@tanstack/react-start\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport { clientEnv } from \"~/env\";\nimport { buildUser, decodeJwt } from \"~/lib/utils\";\nimport type { User } from \"~/models/User\";\n\nexport const pca = new PublicClientApplication({\n auth: {\n clientId: clientEnv.VITE_ENTRA_CLIENT_ID,\n authority: `https://login.microsoftonline.com/${clientEnv.VITE_ENTRA_TENANT_ID}`,\n redirectUri: \"/\",\n },\n});\n\nconst restoreActiveAccount = () => {\n if (pca.getActiveAccount()) return;\n const [firstAccount] = pca.getAllAccounts();\n if (firstAccount) pca.setActiveAccount(firstAccount);\n};\n\nconst initializeMsal = async () => {\n if (globalThis.window === undefined) return;\n\n await pca.initialize();\n\n pca.addEventCallback((event: EventMessage) => {\n if (event.eventType === EventType.LOGIN_SUCCESS && event.payload) {\n const payload = event.payload as AuthenticationResult;\n pca.setActiveAccount(payload.account);\n }\n });\n\n const response = await pca.handleRedirectPromise();\n if (response?.account) {\n pca.setActiveAccount(response.account);\n return;\n }\n\n restoreActiveAccount();\n};\n\nconst initializationPromise = initializeMsal();\nawait initializationPromise;\n\nexport const msalReady = () => initializationPromise;\n\nexport class TanStackNavigationClient extends NavigationClient {\n constructor(private readonly navigate: ReturnType<typeof useNavigate>) {\n super();\n }\n async navigateInternal(url: string, options: NavigationOptions) {\n const relative = url.replace(location.origin, \"\");\n this.navigate({ to: relative, replace: options.noHistory });\n return false;\n }\n}\n\nexport const getUser = createIsomorphicFn()\n .server(() => null)\n .client(async (): Promise<User | null> => {\n await initializationPromise;\n restoreActiveAccount();\n\n const account = pca.getActiveAccount();\n if (!account?.idToken) return null;\n\n return buildUser(decodeJwt(account.idToken));\n });\n\n/**\n * Token Acquisition: Get authenticated access token.\n * Use when: Making API calls from the browser to secured endpoints.\n */\nexport const getAccessToken = createClientOnlyFn(async (scopeKey: keyof typeof definedScopes) => {\n await initializationPromise;\n restoreActiveAccount();\n\n const account = pca.getActiveAccount();\n if (!account) throw new Error(\"No active account. User not signed in.\");\n\n const scopes = [...definedScopes[scopeKey]];\n\n try {\n const { accessToken } = await pca.acquireTokenSilent({ scopes, account });\n return accessToken;\n } catch (error) {\n if (error instanceof InteractionRequiredAuthError) {\n try {\n await pca.acquireTokenRedirect({ scopes, account });\n } catch (redirectError) {\n // Another interaction is already in progress — MSAL will handle it.\n if (\n !(redirectError instanceof BrowserAuthError) ||\n redirectError.errorCode !== \"interaction_in_progress\"\n ) {\n throw redirectError;\n }\n }\n\n // Keep the caller suspended until the page navigates away so pending\n // server functions don't fire without an Authorization header.\n await new Promise<never>(() => {});\n }\n\n throw error;\n }\n});\n","import type { AnyFieldApi } from \"@tanstack/react-form\";\nimport { permissions } from \"virtual:wcz-layout\";\nimport { clientEnv } from \"~/env\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { User } from \"~/models/User\";\nimport { getUser } from \"./auth/msalClient\";\n\nexport const WISTRON_PRIMARY_COLOR = \"#00506E\";\nexport const WISTRON_SECONDARY_COLOR = \"#64DC00\";\n\nexport class Platform {\n static get isAndroid() {\n return /android/i.test(this.userAgent);\n }\n static get isIOS() {\n return /iPad|iPhone|iPod/.test(this.userAgent);\n }\n static get isWindows() {\n return /windows/i.test(this.userAgent);\n }\n static get isMacOS() {\n return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);\n }\n\n private static get userAgent() {\n return typeof navigator === \"undefined\" ? \"\" : navigator.userAgent;\n }\n}\n\ninterface RootRouteHeadOptions {\n manifest?: string;\n}\n\nexport const rootRouteHead = (options?: RootRouteHeadOptions) => ({\n meta: [\n { charSet: \"utf-8\" },\n { name: \"viewport\", content: \"width=device-width, initial-scale=1\" },\n { title: clientEnv.VITE_APP_TITLE },\n { name: \"og:type\", content: \"website\" },\n { name: \"og:title\", content: clientEnv.VITE_APP_TITLE },\n { name: \"og:image\", content: \"/favicon-32x32.png\" },\n ],\n links: [\n { rel: \"apple-touch-icon\", sizes: \"180x180\", href: \"/apple-touch-icon.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"32x32\", href: \"/favicon-32x32.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"16x16\", href: \"/favicon-16x16.png\" },\n { rel: \"manifest\", href: options?.manifest || \"/manifest.json\" },\n { rel: \"icon\", href: \"/favicon.ico\" },\n ],\n});\n\nexport const requirePermission = (permissionKey: keyof typeof permissions) => {\n return async () => {\n const user = await getUser();\n\n if (!user?.hasPermission(permissionKey))\n throw new Error(\"You do not have permission to access this page.\");\n\n return { user };\n };\n};\n\n/* Internal Utils */\nexport type FormOmittedProps =\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"renderInput\"\n | \"type\"\n | \"aria-label\";\n\nexport const getFieldStatus = (field: AnyFieldApi) => {\n const { meta } = field.state;\n\n const isTouched = meta.isTouched;\n const hasError = !!meta.errors.length;\n const helperText = meta.errors[0]?.message;\n\n return { isTouched, hasError, helperText };\n};\n\nexport const toKebabCase = (str: string): string => {\n return str\n .replaceAll(/([a-z])([A-Z])/g, \"$1-$2\")\n .replaceAll(/[\\s_]+/g, \"-\")\n .replaceAll(/[^a-zA-Z0-9-]/g, \"\")\n .toLowerCase()\n .replaceAll(/-+/g, \"-\")\n .replaceAll(/(^-|-$)/g, \"\");\n};\n\nexport const decodeJwt = (token: string) => {\n const base64Payload = token.split(\".\")[1];\n const base64 = base64Payload.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const payload = decodeURIComponent(\n atob(base64)\n .split(\"\")\n .map((c) => \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2))\n .join(\"\"),\n );\n return JSON.parse(payload) as TokenPayload;\n};\n\nexport const buildUser = (payload: TokenPayload): User => ({\n id: payload.sub,\n name: payload.name?.split(\"/\")[0],\n email: payload.preferred_username?.toLowerCase(),\n department: payload.department?.toUpperCase() || \"\",\n employeeId: payload.employeeId?.toUpperCase() || \"\",\n companyName: payload.companyName || \"\",\n hasPermission: (key: keyof typeof permissions) => {\n const allowedGroups = permissions[key];\n return allowedGroups.some((k) => (payload.groups ?? []).includes(k));\n },\n});\n"],"mappings":";;;;;AAiBA,MAAaiB,MAAM,IAAIV,wBAAwB,EAC7CW,MAAM;CACJC,UAAUN,UAAUO;CACpBC,WAAW,qCAAqCR,UAAUS;CAC1DC,aAAa;CACf,EACD,CAAC;AAEF,MAAMC,6BAA6B;AACjC,KAAIP,IAAIQ,kBAAkB,CAAE;CAC5B,MAAM,CAACC,gBAAgBT,IAAIU,gBAAgB;AAC3C,KAAID,aAAcT,KAAIW,iBAAiBF,aAAa;;AAGtD,MAAMG,i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AccessToken, o as requirePermission, t as Platform } from "./utils-
|
|
2
|
-
import { n as getTokenOnBehalfOf, t as getAppToken } from "./msalServer-
|
|
1
|
+
import { l as getAccessToken, o as requirePermission, t as Platform } from "./utils-B7LPctqx.js";
|
|
2
|
+
import { n as getTokenOnBehalfOf, t as getAppToken } from "./msalServer-coQaBOlr.js";
|
|
3
3
|
import i18next, { t } from "i18next";
|
|
4
4
|
import { createEnv } from "@t3-oss/env-core";
|
|
5
5
|
import { uuidv7 } from "uuidv7";
|
package/package.json
CHANGED
package/dist/env-szOeLEuD.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-szOeLEuD.js","names":["createEnv","z","clientEnv","clientPrefix","client","VITE_ENTRA_CLIENT_ID","string","VITE_ENTRA_TENANT_ID","VITE_APP_TITLE","VITE_MUI_LICENSE_KEY","runtimeEnv","import","meta","env","emptyStringAsUndefined","serverEnv","server","ENTRA_CLIENT_ID","ENTRA_TENANT_ID","ENTRA_CLIENT_SECRET","FILE_BASE_URL","min","APPROVAL_BASE_URL","PS_BASE_URL","EMAIL_BASE_URL","process"],"sources":["../src/env.ts"],"sourcesContent":["import { createEnv } from \"@t3-oss/env-core\";\nimport { z } from \"zod\";\n\nexport const clientEnv = createEnv({\n clientPrefix: \"VITE_\",\n client: {\n VITE_ENTRA_CLIENT_ID: z.string(),\n VITE_ENTRA_TENANT_ID: z.string(),\n VITE_APP_TITLE: z.string(),\n VITE_MUI_LICENSE_KEY: z.string(),\n },\n runtimeEnv: import.meta.env,\n emptyStringAsUndefined: true,\n});\n\nexport const serverEnv = createEnv({\n server: {\n ENTRA_CLIENT_ID: z.string(),\n ENTRA_TENANT_ID: z.string(),\n ENTRA_CLIENT_SECRET: z.string(),\n FILE_BASE_URL: z.string().min(1),\n APPROVAL_BASE_URL: z.string().min(1),\n PS_BASE_URL: z.string().min(1),\n EMAIL_BASE_URL: z.string().min(1),\n },\n runtimeEnv: process.env,\n emptyStringAsUndefined: true,\n});\n"],"mappings":";;;AAGA,MAAaE,YAAYF,UAAU;CACjCG,cAAc;CACdC,QAAQ;EACNC,sBAAsBJ,EAAEK,QAAQ;EAChCC,sBAAsBN,EAAEK,QAAQ;EAChCE,gBAAgBP,EAAEK,QAAQ;EAC1BG,sBAAsBR,EAAEK,QAAO;EAChC;CACDI,YAAYC,OAAOC,KAAKC;CACxBC,wBAAwB;CACzB,CAAC;AAEF,MAAaC,YAAYf,UAAU;CACjCgB,QAAQ;EACNC,iBAAiBhB,EAAEK,QAAQ;EAC3BY,iBAAiBjB,EAAEK,QAAQ;EAC3Ba,qBAAqBlB,EAAEK,QAAQ;EAC/Bc,eAAenB,EAAEK,QAAQ,CAACe,IAAI,EAAE;EAChCC,mBAAmBrB,EAAEK,QAAQ,CAACe,IAAI,EAAE;EACpCE,aAAatB,EAAEK,QAAQ,CAACe,IAAI,EAAE;EAC9BG,gBAAgBvB,EAAEK,QAAQ,CAACe,IAAI,EAAC;EACjC;CACDX,YAAYe,QAAQZ;CACpBC,wBAAwB;CACzB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-DSohGVd1.js","names":["AxiosInstance","axios","scopes","definedScopes","getAppToken","ScopeKey","createExternalApi","baseURL","scopeKey","api","create","interceptors","request","use","config","accessToken","headers","set","createServerFn","createServerOnlyFn","AxiosInstance","Upload","uuidv7","z","serverEnv","getAppToken","FileMeta","FileMetaSchema","createExternalApi","fileApi","getFileApi","FILE_BASE_URL","GetFileMetasSchema","object","appName","string","min","max","subId","uuid","FileSchema","id","UpdateFileMetaSchema","extend","fileName","DeleteFileSchema","BatchDeleteFilesSchema","UploadFileResult","UploadFileMetaSchema","file","instanceof","File","getFileMetas","method","inputValidator","handler","data","api","queryParams","URLSearchParams","append","request","Array","url","toString","then","r","getFileThumbnail","response","ArrayBuffer","responseType","Response","headers","getFile","downloadFile","updateFileMeta","deleteFile","batchDeleteFiles","uploadFile","Promise","accessToken","buffer","Buffer","from","arrayBuffer","resolve","reject","upload","endpoint","chunkSize","metadata","name","fileExtension","type","Authorization","onError","onSuccess","start"],"sources":["../src/queries/server/externalApi.ts","../src/queries/server/file.ts"],"sourcesContent":["import type { AxiosInstance } from \"axios\";\r\nimport axios from \"axios\";\r\nimport type { scopes as definedScopes } from \"virtual:wcz-layout\";\r\nimport { getAppToken } from \"~/lib/auth/msalServer\";\r\n\r\ntype ScopeKey = keyof typeof definedScopes;\r\n\r\nexport function createExternalApi(baseURL: string, scopeKey: ScopeKey): AxiosInstance {\r\n const api = axios.create({ baseURL });\r\n\r\n api.interceptors.request.use(async (config) => {\r\n const accessToken = await getAppToken(scopeKey);\r\n config.headers.set(\"Authorization\", `Bearer ${accessToken}`);\r\n return config;\r\n });\r\n\r\n return api;\r\n}\r\n","import { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\r\nimport type { AxiosInstance } from \"axios\";\r\nimport { Upload } from \"tus-js-client\";\r\nimport { uuidv7 } from \"uuidv7\";\r\nimport { z } from \"zod\";\r\nimport { serverEnv } from \"~/env\";\r\nimport { getAppToken } from \"~/lib/auth/msalServer\";\r\nimport type { FileMeta } from \"~/models/file/FileMeta\";\r\nimport { FileMetaSchema } from \"~/models/file/FileMeta\";\r\nimport { createExternalApi } from \"~/queries/server/externalApi\";\r\n\r\nlet fileApi: AxiosInstance | null = null;\r\nconst getFileApi = createServerOnlyFn((): AxiosInstance => {\r\n fileApi ??= createExternalApi(serverEnv.FILE_BASE_URL, \"file\");\r\n return fileApi;\r\n});\r\n\r\nexport const GetFileMetasSchema = z.object({\r\n appName: z.string().min(1).max(255),\r\n subId: z.uuid(),\r\n});\r\n\r\nexport const FileSchema = z.object({\r\n appName: z.string().min(1).max(255),\r\n id: z.uuid(),\r\n});\r\n\r\nexport const UpdateFileMetaSchema = FileMetaSchema.extend({\r\n fileName: z.string().min(1).max(255),\r\n});\r\n\r\nconst DeleteFileSchema = FileSchema;\r\n\r\nconst BatchDeleteFilesSchema = GetFileMetasSchema;\r\n\r\nexport interface UploadFileResult {\r\n id: string;\r\n appName: string;\r\n subId: string;\r\n fileName: string;\r\n}\r\n\r\nexport const UploadFileMetaSchema = z.object({\r\n appName: z.string().min(1).max(255),\r\n subId: z.uuid(),\r\n file: z.instanceof(File),\r\n});\r\n\r\nexport const getFileMetas = createServerFn({ method: \"GET\" })\r\n .inputValidator(GetFileMetasSchema)\r\n .handler(async ({ data }) => {\r\n const api = getFileApi();\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", data.appName);\r\n queryParams.append(\"subId\", data.subId);\r\n\r\n return api\r\n .request<Array<FileMeta>>({\r\n url: `/v1/meta?${queryParams.toString()}`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getFileThumbnail = createServerFn({ method: \"GET\" })\r\n .inputValidator(FileSchema)\r\n .handler(async ({ data }) => {\r\n const api = getFileApi();\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", data.appName);\r\n queryParams.append(\"id\", data.id);\r\n\r\n const response = await api.request<ArrayBuffer>({\r\n url: `/v1/thumbnail?${queryParams.toString()}`,\r\n method: \"GET\",\r\n responseType: \"arraybuffer\",\r\n });\r\n\r\n return new Response(response.data, {\r\n headers: {\r\n \"Content-Type\": response.headers[\"content-type\"] as string,\r\n },\r\n });\r\n });\r\n\r\nexport const getFile = createServerFn({ method: \"GET\" })\r\n .inputValidator(FileSchema)\r\n .handler(async ({ data }) => {\r\n const api = getFileApi();\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", data.appName);\r\n queryParams.append(\"id\", data.id);\r\n\r\n const response = await api.request<ArrayBuffer>({\r\n url: `/v1?${queryParams.toString()}`,\r\n method: \"GET\",\r\n responseType: \"arraybuffer\",\r\n });\r\n\r\n return new Response(response.data, {\r\n headers: {\r\n \"Content-Type\": response.headers[\"content-type\"] as string,\r\n },\r\n });\r\n });\r\n\r\nexport const downloadFile = createServerFn({ method: \"GET\" })\r\n .inputValidator(FileSchema)\r\n .handler(async ({ data }) => {\r\n const api = getFileApi();\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", data.appName);\r\n queryParams.append(\"id\", data.id);\r\n\r\n const response = await api.request<ArrayBuffer>({\r\n url: `/v1/download?${queryParams.toString()}`,\r\n method: \"GET\",\r\n responseType: \"arraybuffer\",\r\n });\r\n\r\n return new Response(response.data, {\r\n headers: {\r\n \"Content-Type\": response.headers[\"content-type\"] as string,\r\n },\r\n });\r\n });\r\n\r\nexport const updateFileMeta = createServerFn({ method: \"POST\" })\r\n .inputValidator(UpdateFileMetaSchema)\r\n .handler(async ({ data }) => {\r\n const api = getFileApi();\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", data.appName);\r\n queryParams.append(\"id\", data.id);\r\n\r\n return api\r\n .request({ url: `/v1/meta?${queryParams.toString()}`, method: \"PUT\", data })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const deleteFile = createServerFn({ method: \"POST\" })\r\n .inputValidator(DeleteFileSchema)\r\n .handler(async ({ data }) => {\r\n const api = getFileApi();\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", data.appName);\r\n queryParams.append(\"id\", data.id);\r\n\r\n return api\r\n .request({ url: `/v1?${queryParams.toString()}`, method: \"DELETE\" })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const batchDeleteFiles = createServerFn({ method: \"POST\" })\r\n .inputValidator(BatchDeleteFilesSchema)\r\n .handler(async ({ data }) => {\r\n const api = getFileApi();\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", data.appName);\r\n queryParams.append(\"subId\", data.subId);\r\n\r\n return api\r\n .request({ url: `/v1?${queryParams.toString()}`, method: \"DELETE\" })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const uploadFile = createServerFn({ method: \"POST\" })\r\n .inputValidator(UploadFileMetaSchema)\r\n .handler(async ({ data }): Promise<UploadFileResult> => {\r\n const accessToken = await getAppToken(\"file\");\r\n const buffer = Buffer.from(await data.file.arrayBuffer());\r\n const id = uuidv7();\r\n\r\n await new Promise<void>((resolve, reject) => {\r\n const upload = new Upload(buffer, {\r\n endpoint: `${serverEnv.FILE_BASE_URL}/v1/upload`,\r\n chunkSize: 1_048_576,\r\n metadata: {\r\n id,\r\n appName: data.appName,\r\n subId: data.subId,\r\n fileName: data.file.name,\r\n fileExtension: data.file.type,\r\n },\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n onError: reject,\r\n onSuccess: () => resolve(),\r\n });\r\n upload.start();\r\n });\r\n\r\n return { id, appName: data.appName, subId: data.subId, fileName: data.file.name };\r\n });\r\n"],"mappings":";;;;;;;;;AAOA,SAAgBM,kBAAkBC,SAAiBC,UAAmC;CACpF,MAAMC,MAAMR,MAAMS,OAAO,EAAEH,SAAS,CAAC;AAErCE,KAAIE,aAAaC,QAAQC,IAAI,OAAOC,WAAW;EAC7C,MAAMC,cAAc,MAAMX,YAAYI,SAAS;AAC/CM,SAAOE,QAAQC,IAAI,iBAAiB,UAAUF,cAAc;AAC5D,SAAOD;GACP;AAEF,QAAOL;;;;ACLT,IAAIoB,UAAgC;AACpC,MAAMC,aAAaX,yBAAwC;AACzDU,aAAYD,kBAAkBJ,UAAUO,eAAe,OAAO;AAC9D,QAAOF;EACP;AAEF,MAAaG,qBAAqBT,EAAEU,OAAO;CACzCC,SAASX,EAAEY,QAAQ,CAACC,IAAI,EAAE,CAACC,IAAI,IAAI;CACnCC,OAAOf,EAAEgB,MAAK;CACf,CAAC;AAEF,MAAaC,aAAajB,EAAEU,OAAO;CACjCC,SAASX,EAAEY,QAAQ,CAACC,IAAI,EAAE,CAACC,IAAI,IAAI;CACnCI,IAAIlB,EAAEgB,MAAK;CACZ,CAAC;AAEF,MAAaG,uBAAuBf,eAAegB,OAAO,EACxDC,UAAUrB,EAAEY,QAAQ,CAACC,IAAI,EAAE,CAACC,IAAI,IAAG,EACpC,CAAC;AAEF,MAAMQ,mBAAmBL;AAEzB,MAAMM,yBAAyBd;AAS/B,MAA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AAUY,KAAKP,KAAK0C;IACpBC,eAAepC,KAAKP,KAAK4C;IAC1B;GACDrB,SAAS,EAAEsB,eAAe,UAAUd,eAAe;GACnDe,SAAST;GACTU,iBAAiBX,SAAQ;GAC1B,CACK,CAACY,OAAO;GACd;AAEF,QAAO;EAAExD;EAAIP,SAASsB,KAAKtB;EAASI,OAAOkB,KAAKlB;EAAOM,UAAUY,KAAKP,KAAK0C;EAAM;EACjF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"peoplesoft-COFvPG-L.js","names":["createServerFn","createServerOnlyFn","AxiosInstance","z","serverEnv","ApproveApprovalSchema","CancelApprovalSchema","CreateApprovalSchema","ResubmitApprovalSchema","WithdrawApprovalSchema","Approval","ApprovalStatus","ApprovalStepResult","createExternalApi","approvalApi","getApprovalApi","APPROVAL_BASE_URL","GetApprovalsSchema","object","appName","string","min","max","status","optional","approverEmployeeId","stepResult","GetApprovalSchema","id","uuid","getApprovals","method","inputValidator","handler","data","api","queryParams","URLSearchParams","append","toString","request","Array","url","then","r","getApproval","createApproval","approveApproval","resubmitApproval","withdrawApproval","cancelApproval","createServerFn","createServerOnlyFn","AxiosInstance","z","serverEnv","Department","Employee","createExternalApi","peopleSoftApi","getPeopleSoftApi","PS_BASE_URL","SearchEmployeesSchema","object","searchTerm","string","min","EmployeeIdSchema","employeeId","DepartmentIdSchema","departmentId","CompanyCodeSchema","companyCode","searchEmployees","method","inputValidator","handler","data","api","request","Array","url","encodeURIComponent","then","r","getEmployees","getActiveEmployees","getEmployeeByEmployeeId","getPreviousEmployeeIds","getEmployeeSupervisor","getEmployeeSubordinates","getEmployeeManager","getEmployeeGeneralManager","getDepartments","getDepartmentById","getDepartmentManager","getDepartmentEmployees","getCompanyGeneralManager"],"sources":["../src/queries/server/approval.ts","../src/queries/server/peoplesoft.ts"],"sourcesContent":["import { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\r\nimport type { AxiosInstance } from \"axios\";\r\nimport { z } from \"zod\";\r\nimport { serverEnv } from \"~/env\";\r\nimport {\r\n ApproveApprovalSchema,\r\n CancelApprovalSchema,\r\n CreateApprovalSchema,\r\n ResubmitApprovalSchema,\r\n WithdrawApprovalSchema,\r\n} from \"~/models/approval/Approval\";\r\nimport type { Approval } from \"~/models/approval/Approval\";\r\nimport { ApprovalStatus } from \"~/models/approval/ApprovalStatus\";\r\nimport { ApprovalStepResult } from \"~/models/approval/ApprovalStepResult\";\r\nimport { createExternalApi } from \"~/queries/server/externalApi\";\r\n\r\nlet approvalApi: AxiosInstance | null = null;\r\nconst getApprovalApi = createServerOnlyFn((): AxiosInstance => {\r\n approvalApi ??= createExternalApi(serverEnv.APPROVAL_BASE_URL, \"approval\");\r\n return approvalApi;\r\n});\r\n\r\nexport const GetApprovalsSchema = z.object({\r\n appName: z.string().min(1).max(255),\r\n status: ApprovalStatus.optional(),\r\n approverEmployeeId: z.string().min(1).max(20).optional(),\r\n stepResult: ApprovalStepResult.optional(),\r\n});\r\n\r\nexport const GetApprovalSchema = z.object({\r\n id: z.uuid(),\r\n});\r\n\r\nexport const getApprovals = createServerFn({ method: \"GET\" })\r\n .inputValidator(GetApprovalsSchema)\r\n .handler(async ({ data }) => {\r\n const api = getApprovalApi();\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"applicationName\", data.appName);\r\n if (data.status) queryParams.append(\"status\", data.status.toString());\r\n if (data.approverEmployeeId) queryParams.append(\"approverEmployeeId\", data.approverEmployeeId);\r\n if (data.stepResult) queryParams.append(\"stepResult\", data.stepResult.toString());\r\n\r\n return api\r\n .request<Array<Approval>>({\r\n url: `/Requests/Requests?${queryParams.toString()}`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getApproval = createServerFn({ method: \"GET\" })\r\n .inputValidator(GetApprovalSchema)\r\n .handler(async ({ data }) => {\r\n const api = getApprovalApi();\r\n return api\r\n .request<Approval>({\r\n url: `/Requests/${data.id}`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const createApproval = createServerFn({ method: \"POST\" })\r\n .inputValidator(CreateApprovalSchema)\r\n .handler(async ({ data }) => {\r\n const api = getApprovalApi();\r\n return api\r\n .request<Approval>({\r\n url: `/Requests`,\r\n method: \"POST\",\r\n data,\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const approveApproval = createServerFn({ method: \"POST\" })\r\n .inputValidator(ApproveApprovalSchema)\r\n .handler(async ({ data }) => {\r\n const api = getApprovalApi();\r\n return api\r\n .request<Approval>({\r\n url: `/Requests/${data.id}/single-approval`,\r\n method: \"POST\",\r\n data,\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const resubmitApproval = createServerFn({ method: \"POST\" })\r\n .inputValidator(ResubmitApprovalSchema)\r\n .handler(async ({ data }) => {\r\n const api = getApprovalApi();\r\n return api\r\n .request<Approval>({\r\n url: `/Requests/${data.id}/resubmit`,\r\n method: \"POST\",\r\n data,\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const withdrawApproval = createServerFn({ method: \"POST\" })\r\n .inputValidator(WithdrawApprovalSchema)\r\n .handler(async ({ data }) => {\r\n const api = getApprovalApi();\r\n return api\r\n .request<void>({\r\n url: `/Requests/${data.id}/withdraw`,\r\n method: \"POST\",\r\n data,\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const cancelApproval = createServerFn({ method: \"POST\" })\r\n .inputValidator(CancelApprovalSchema)\r\n .handler(async ({ data }) => {\r\n const api = getApprovalApi();\r\n return api\r\n .request<void>({\r\n url: `/Requests/${data.id}/cancel`,\r\n method: \"POST\",\r\n data,\r\n })\r\n .then((r) => r.data);\r\n });\r\n","import { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\r\nimport type { AxiosInstance } from \"axios\";\r\nimport { z } from \"zod\";\r\nimport { serverEnv } from \"~/env\";\r\nimport type { Department } from \"~/models/peoplesoft/Department\";\r\nimport type { Employee } from \"~/models/peoplesoft/Employee\";\r\nimport { createExternalApi } from \"~/queries/server/externalApi\";\r\n\r\nlet peopleSoftApi: AxiosInstance | null = null;\r\nconst getPeopleSoftApi = createServerOnlyFn((): AxiosInstance => {\r\n peopleSoftApi ??= createExternalApi(serverEnv.PS_BASE_URL, \"ps\");\r\n return peopleSoftApi;\r\n});\r\n\r\nexport const SearchEmployeesSchema = z.object({\r\n searchTerm: z.string().min(1),\r\n});\r\n\r\nexport const EmployeeIdSchema = z.object({\r\n employeeId: z.string().min(1),\r\n});\r\n\r\nexport const DepartmentIdSchema = z.object({\r\n departmentId: z.string().min(1),\r\n});\r\n\r\nexport const CompanyCodeSchema = z.object({\r\n companyCode: z.string().min(1),\r\n});\r\n\r\nexport const searchEmployees = createServerFn({ method: \"GET\" })\r\n .inputValidator(SearchEmployeesSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Array<Employee>>({\r\n url: `/v1/employee?search=${encodeURIComponent(data.searchTerm)}`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getEmployees = createServerFn({ method: \"GET\" }).handler(async () => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Array<Employee>>({ url: `/v1/employee/all`, method: \"GET\" })\r\n .then((r) => r.data);\r\n});\r\n\r\nexport const getActiveEmployees = createServerFn({ method: \"GET\" }).handler(async () => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Array<Employee>>({ url: `/v1/employee/active`, method: \"GET\" })\r\n .then((r) => r.data);\r\n});\r\n\r\nexport const getEmployeeByEmployeeId = createServerFn({ method: \"GET\" })\r\n .inputValidator(EmployeeIdSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Employee>({\r\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getPreviousEmployeeIds = createServerFn({ method: \"GET\" }).handler(async () => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Array<Employee>>({ url: `/v1/employee/previousIds`, method: \"GET\" })\r\n .then((r) => r.data);\r\n});\r\n\r\nexport const getEmployeeSupervisor = createServerFn({ method: \"GET\" })\r\n .inputValidator(EmployeeIdSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Employee>({\r\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}/supervisor`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getEmployeeSubordinates = createServerFn({ method: \"GET\" })\r\n .inputValidator(EmployeeIdSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Array<Employee>>({\r\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}/subordinates`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getEmployeeManager = createServerFn({ method: \"GET\" })\r\n .inputValidator(EmployeeIdSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Employee>({\r\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}/manager`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getEmployeeGeneralManager = createServerFn({ method: \"GET\" })\r\n .inputValidator(EmployeeIdSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Employee>({\r\n url: `/v1/employee/${encodeURIComponent(data.employeeId)}/generalManager`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getDepartments = createServerFn({ method: \"GET\" }).handler(async () => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Array<Department>>({ url: `/v1/department/all`, method: \"GET\" })\r\n .then((r) => r.data);\r\n});\r\n\r\nexport const getDepartmentById = createServerFn({ method: \"GET\" })\r\n .inputValidator(DepartmentIdSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Department>({\r\n url: `/v1/department/${encodeURIComponent(data.departmentId)}`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getDepartmentManager = createServerFn({ method: \"GET\" })\r\n .inputValidator(DepartmentIdSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Employee>({\r\n url: `/v1/department/${encodeURIComponent(data.departmentId)}/manager`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getDepartmentEmployees = createServerFn({ method: \"GET\" })\r\n .inputValidator(DepartmentIdSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Array<Employee>>({\r\n url: `/v1/department/${encodeURIComponent(data.departmentId)}/employees`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n\r\nexport const getCompanyGeneralManager = createServerFn({ method: \"GET\" })\r\n .inputValidator(CompanyCodeSchema)\r\n .handler(async ({ data }) => {\r\n const api = getPeopleSoftApi();\r\n return api\r\n .request<Employee>({\r\n url: `/v1/company/${encodeURIComponent(data.companyCode)}/generalManager`,\r\n method: \"GET\",\r\n })\r\n .then((r) => r.data);\r\n });\r\n"],"mappings":";;;;;;AAgBA,IAAIc,cAAoC;AACxC,MAAMC,iBAAiBd,yBAAwC;AAC7Da,iBAAgBD,kBAAkBT,UAAUY,mBAAmB,WAAW;AAC1E,QAAOF;EACP;AAEF,MAAaG,qBAAqBd,EAAEe,OAAO;CACzCC,SAAShB,EAAEiB,QAAQ,CAACC,IAAI,EAAE,CAACC,IAAI,IAAI;CACnCC,QAAQZ,eAAea,UAAU;CACjCC,oBAAoBtB,EAAEiB,QAAQ,CAACC,IAAI,EAAE,CAACC,IAAI,GAAG,CAACE,UAAU;CACxDE,YAAYd,mBAAmBY,UAAS;CACzC,CAAC;AAEF,MAAaG,oBAAoBxB,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og","DialogActions","DialogContent","DialogTitle","useEventCallback","useContext","useTranslation","DialogsContext","ReactNode","OpenDialogOptions","onClose","result","TResult","Promise","AlertOptions","title","ConfirmOptions","cancelText","DialogProps","payload","TPayload","open","OpenAlertDialog","message","options","OpenConfirmDialog","DialogComponent","React","ComponentType","OpenDialog","Component","CloseDialog","dialog","AlertDialogPayload","AlertDialogProps","AlertDialog","t0","$","_c","$i","Symbol","for","t","t1","t2","t3","t4","t5","t6","t7","t8","ConfirmDialogPayload","ConfirmDialogProps","ConfirmDialog","t9","t10","t11","t12","DialogHook","alert","confirm","close","useDialogs","undefined","message_0","options_0"],"sources":["../src/hooks/useDialogs.tsx"],"sourcesContent":["import {\r\n Button,\r\n Dialog,\r\n DialogActions,\r\n DialogContent,\r\n DialogTitle,\r\n useEventCallback,\r\n} from \"@mui/material\";\r\nimport { useContext } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\nimport { DialogsContext } from \"../contexts/DialogsContext\";\r\nimport type { ReactNode } from \"react\";\r\n\r\nexport interface OpenDialogOptions<TResult> {\r\n onClose?: (result: TResult) => Promise<void>;\r\n}\r\n\r\nexport interface AlertOptions {\r\n title?: ReactNode;\r\n}\r\n\r\nexport interface ConfirmOptions {\r\n title?: ReactNode;\r\n cancelText?: ReactNode;\r\n}\r\n\r\nexport interface DialogProps<TPayload = undefined, TResult = void> {\r\n payload: TPayload;\r\n open: boolean;\r\n onClose: (result: TResult) => Promise<void>;\r\n}\r\n\r\nexport type OpenAlertDialog = (message: ReactNode, options?: AlertOptions) => Promise<void>;\r\n\r\nexport type OpenConfirmDialog = (message: ReactNode, options?: ConfirmOptions) => Promise<boolean>;\r\n\r\nexport type DialogComponent<TPayload, TResult> = React.ComponentType<\r\n DialogProps<TPayload, TResult>\r\n>;\r\n\r\nexport interface OpenDialog {\r\n <TPayload extends undefined, TResult>(\r\n Component: DialogComponent<TPayload, TResult>,\r\n payload?: TPayload,\r\n options?: OpenDialogOptions<TResult>,\r\n ): Promise<TResult>;\r\n <TPayload, TResult>(\r\n Component: DialogComponent<TPayload, TResult>,\r\n payload: TPayload,\r\n options?: OpenDialogOptions<TResult>,\r\n ): Promise<TResult>;\r\n}\r\n\r\nexport type CloseDialog = <TResult>(dialog: Promise<TResult>, result: TResult) => Promise<TResult>;\r\n\r\nexport interface AlertDialogPayload extends AlertOptions {\r\n message: ReactNode;\r\n}\r\n\r\nexport type AlertDialogProps = DialogProps<AlertDialogPayload, void>;\r\n\r\nexport function AlertDialog({ open, payload, onClose }: Readonly<AlertDialogProps>) {\r\n const { t } = useTranslation();\r\n\r\n return (\r\n <Dialog maxWidth=\"xs\" fullWidth open={open} onClose={() => onClose()} disableRestoreFocus>\r\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Alert\")}</DialogTitle>\r\n <DialogContent>{payload.message}</DialogContent>\r\n <DialogActions>\r\n <Button onClick={() => onClose()} autoFocus>\r\n {t(\"Layout.Dialog.Confirm\")}\r\n </Button>\r\n </DialogActions>\r\n </Dialog>\r\n );\r\n}\r\n\r\nexport interface ConfirmDialogPayload extends ConfirmOptions {\r\n message: ReactNode;\r\n}\r\n\r\nexport type ConfirmDialogProps = DialogProps<ConfirmDialogPayload, boolean>;\r\n\r\nexport function ConfirmDialog({ open, payload, onClose }: Readonly<ConfirmDialogProps>) {\r\n const { t } = useTranslation();\r\n\r\n return (\r\n <Dialog maxWidth=\"xs\" fullWidth open={open} onClose={() => onClose(false)} disableRestoreFocus>\r\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Confirm\")}</DialogTitle>\r\n <DialogContent>{payload.message}</DialogContent>\r\n <DialogActions>\r\n <Button onClick={() => onClose(false)}>\r\n {payload.cancelText ?? t(\"Layout.Dialog.Cancel\")}\r\n </Button>\r\n <Button onClick={() => onClose(true)} autoFocus>\r\n {t(\"Layout.Dialog.Confirm\")}\r\n </Button>\r\n </DialogActions>\r\n </Dialog>\r\n );\r\n}\r\n\r\ninterface DialogHook {\r\n alert: OpenAlertDialog;\r\n confirm: OpenConfirmDialog;\r\n open: OpenDialog;\r\n close: CloseDialog;\r\n}\r\n\r\nexport function useDialogs(): DialogHook {\r\n const { open, close } = useContext(DialogsContext);\r\n\r\n const alert = useEventCallback<OpenAlertDialog>((message, { ...options } = {}) =>\r\n open(AlertDialog, { ...options, message }),\r\n );\r\n\r\n const confirm = useEventCallback<OpenConfirmDialog>((message, { ...options } = {}) =>\r\n open(ConfirmDialog, { ...options, message }),\r\n );\r\n\r\n return { alert, confirm, open, close };\r\n}\r\n"],"mappings":";;;;;;;AA6DA,SAAOoC,YAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;AAAA,KAAAD,EAAA,OAAA,oEAAA;AAAA,OAAA,IAAAE,KAAA,GAAAA,KAAA,IAAAA,MAAA,EAAAF,GAAAE,MAAAC,OAAAC,IAAA,4BAAA;AAAAJ,IAAA,KAAA;;CAAqB,MAAA,EAAAhB,MAAAF,SAAAT,YAAA0B;CAC1B,MAAA,EAAAM,MAAcpC,gBAAgB;CAAC,IAAAqC;AAAA,KAAAN,EAAA,OAAA3B,SAAA;AAGwBiC,aAAMjC,SAAS;AAAA2B,IAAA,KAAA3B;AAAA2B,IAAA,KAAAM;OAAAA,MAAAN,EAAA;CAAA,IAAAO;AAAA,KAAAP,EAAA,OAAAlB,QAAAJ,SAAAsB,EAAA,OAAAK,GAAA;AACpDE,OAAAzB,QAAOJ,SAAU2B,EAAE,sBAAsB;AAAAL,IAAA,KAAAlB,QAAAJ;AAAAsB,IAAA,KAAAK;AAAAL,IAAA,KAAAO;OAAAA,MAAAP,EAAA;CAAA,IAAAQ;AAAA,KAAAR,EAAA,OAAAO,IAAA;AAAvDC,OAAA,oBAAC,aAAD,EAAA,UAAcD,IAAwD,CAAA;AAAAP,IAAA,KAAAO;AAAAP,IAAA,KAAAQ;OAAAA,MAAAR,EAAA;CAAA,IAAAS;AAAA,KAAAT,EAAA,OAAAlB,QAAAI,SAAA;AACtEuB,OAAA,oBAAC,eAAD,EAAA,U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B;AAAAvB,IAAA,KAAAhB;AAAAgB,IAAA,KAAAO;OAAAA,MAAAP,EAAA;AAAA,QAA/BO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-CBa4vtgn.js","names":["AuthenticationResult","BrowserAuthError","EventMessage","EventType","InteractionRequiredAuthError","NavigationClient","NavigationOptions","PublicClientApplication","useNavigate","createClientOnlyFn","createIsomorphicFn","scopes","definedScopes","clientEnv","buildUser","decodeJwt","User","pca","auth","clientId","VITE_ENTRA_CLIENT_ID","authority","VITE_ENTRA_TENANT_ID","redirectUri","restoreActiveAccount","getActiveAccount","firstAccount","getAllAccounts","setActiveAccount","initializeMsal","globalThis","window","undefined","initialize","addEventCallback","event","eventType","LOGIN_SUCCESS","payload","account","response","handleRedirectPromise","initializationPromise","msalReady","TanStackNavigationClient","constructor","navigate","ReturnType","navigateInternal","url","options","relative","replace","location","origin","to","noHistory","getUser","server","client","Promise","idToken","getAccessToken","scopeKey","Error","accessToken","acquireTokenSilent","error","acquireTokenRedirect","redirectError","errorCode","AnyFieldApi","permissions","clientEnv","TokenPayload","User","getUser","WISTRON_PRIMARY_COLOR","WISTRON_SECONDARY_COLOR","Platform","isAndroid","test","userAgent","isIOS","isWindows","isMacOS","navigator","RootRouteHeadOptions","manifest","rootRouteHead","options","meta","charSet","name","content","title","VITE_APP_TITLE","links","rel","sizes","href","type","requirePermission","permissionKey","user","hasPermission","Error","FormOmittedProps","getFieldStatus","field","state","isTouched","hasError","errors","length","helperText","message","toKebabCase","str","replaceAll","toLowerCase","decodeJwt","token","base64Payload","split","base64","replace","payload","decodeURIComponent","atob","map","c","charCodeAt","toString","slice","join","JSON","parse","buildUser","id","sub","email","preferred_username","department","toUpperCase","employeeId","companyName","key","allowedGroups","some","k","groups","includes"],"sources":["../src/lib/auth/msalClient.ts","../src/lib/utils.ts"],"sourcesContent":["import {\n AuthenticationResult,\n BrowserAuthError,\n EventMessage,\n EventType,\n InteractionRequiredAuthError,\n NavigationClient,\n NavigationOptions,\n PublicClientApplication,\n} from \"@azure/msal-browser\";\nimport { useNavigate } from \"@tanstack/react-router\";\nimport { createClientOnlyFn, createIsomorphicFn } from \"@tanstack/react-start\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport { clientEnv } from \"~/env\";\nimport { buildUser, decodeJwt } from \"~/lib/utils\";\nimport type { User } from \"~/models/User\";\n\nexport const pca = new PublicClientApplication({\n auth: {\n clientId: clientEnv.VITE_ENTRA_CLIENT_ID,\n authority: `https://login.microsoftonline.com/${clientEnv.VITE_ENTRA_TENANT_ID}`,\n redirectUri: \"/\",\n }\n});\n\nconst restoreActiveAccount = () => {\n if (pca.getActiveAccount()) return;\n const [firstAccount] = pca.getAllAccounts();\n if (firstAccount) pca.setActiveAccount(firstAccount);\n};\n\nconst initializeMsal = async () => {\n if (globalThis.window === undefined) return;\n\n await pca.initialize();\n\n pca.addEventCallback((event: EventMessage) => {\n if (event.eventType === EventType.LOGIN_SUCCESS && event.payload) {\n const payload = event.payload as AuthenticationResult;\n pca.setActiveAccount(payload.account);\n }\n });\n\n const response = await pca.handleRedirectPromise();\n if (response?.account) {\n pca.setActiveAccount(response.account);\n return;\n }\n\n restoreActiveAccount();\n};\n\nconst initializationPromise = initializeMsal();\nawait initializationPromise;\n\nexport const msalReady = () => initializationPromise;\n\nexport class TanStackNavigationClient extends NavigationClient {\n constructor(private readonly navigate: ReturnType<typeof useNavigate>) {\n super();\n }\n async navigateInternal(url: string, options: NavigationOptions) {\n const relative = url.replace(location.origin, \"\");\n this.navigate({ to: relative, replace: options.noHistory });\n return false;\n }\n}\n\nexport const getUser = createIsomorphicFn()\n .server(() => null)\n .client(async (): Promise<User | null> => {\n await initializationPromise;\n restoreActiveAccount();\n\n const account = pca.getActiveAccount();\n if (!account?.idToken) return null;\n\n return buildUser(decodeJwt(account.idToken));\n });\n\n/**\n * Token Acquisition: Get authenticated access token.\n * Use when: Making API calls from the browser to secured endpoints.\n */\nexport const getAccessToken = createClientOnlyFn(async (scopeKey: keyof typeof definedScopes) => {\n await initializationPromise;\n restoreActiveAccount();\n\n const account = pca.getActiveAccount();\n if (!account) throw new Error(\"No active account. User not signed in.\");\n\n const scopes = [...definedScopes[scopeKey]];\n\n try {\n const { accessToken } = await pca.acquireTokenSilent({ scopes, account });\n return accessToken;\n } catch (error) {\n if (error instanceof InteractionRequiredAuthError) {\n try {\n await pca.acquireTokenRedirect({ scopes, account });\n } catch (redirectError) {\n // Another interaction is already in progress — MSAL will handle it.\n if (\n !(redirectError instanceof BrowserAuthError) ||\n redirectError.errorCode !== \"interaction_in_progress\"\n ) {\n throw redirectError;\n }\n }\n\n // Keep the caller suspended until the page navigates away so pending\n // server functions don't fire without an Authorization header.\n await new Promise<never>(() => {});\n }\n\n throw error;\n }\n});\n","import type { AnyFieldApi } from \"@tanstack/react-form\";\nimport { permissions } from \"virtual:wcz-layout\";\nimport { clientEnv } from \"~/env\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { User } from \"~/models/User\";\nimport { getUser } from \"./auth/msalClient\";\n\nexport const WISTRON_PRIMARY_COLOR = \"#00506E\";\nexport const WISTRON_SECONDARY_COLOR = \"#64DC00\";\n\nexport class Platform {\n static get isAndroid() {\n return /android/i.test(this.userAgent);\n }\n static get isIOS() {\n return /iPad|iPhone|iPod/.test(this.userAgent);\n }\n static get isWindows() {\n return /windows/i.test(this.userAgent);\n }\n static get isMacOS() {\n return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);\n }\n\n private static get userAgent() {\n return typeof navigator === \"undefined\" ? \"\" : navigator.userAgent;\n }\n}\n\ninterface RootRouteHeadOptions {\n manifest?: string;\n}\n\nexport const rootRouteHead = (options?: RootRouteHeadOptions) => ({\n meta: [\n { charSet: \"utf-8\" },\n { name: \"viewport\", content: \"width=device-width, initial-scale=1\" },\n { title: clientEnv.VITE_APP_TITLE },\n { name: \"og:type\", content: \"website\" },\n { name: \"og:title\", content: clientEnv.VITE_APP_TITLE },\n { name: \"og:image\", content: \"/favicon-32x32.png\" },\n ],\n links: [\n { rel: \"apple-touch-icon\", sizes: \"180x180\", href: \"/apple-touch-icon.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"32x32\", href: \"/favicon-32x32.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"16x16\", href: \"/favicon-16x16.png\" },\n { rel: \"manifest\", href: options?.manifest || \"/manifest.json\" },\n { rel: \"icon\", href: \"/favicon.ico\" },\n ],\n});\n\nexport const requirePermission = (permissionKey: keyof typeof permissions) => {\n return async () => {\n const user = await getUser();\n\n if (!user?.hasPermission(permissionKey))\n throw new Error(\"You do not have permission to access this page.\");\n\n return { user };\n };\n};\n\n/* Internal Utils */\nexport type FormOmittedProps =\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"renderInput\"\n | \"type\"\n | \"aria-label\";\n\nexport const getFieldStatus = (field: AnyFieldApi) => {\n const { meta } = field.state;\n\n const isTouched = meta.isTouched;\n const hasError = !!meta.errors.length;\n const helperText = meta.errors[0]?.message;\n\n return { isTouched, hasError, helperText };\n};\n\nexport const toKebabCase = (str: string): string => {\n return str\n .replaceAll(/([a-z])([A-Z])/g, \"$1-$2\")\n .replaceAll(/[\\s_]+/g, \"-\")\n .replaceAll(/[^a-zA-Z0-9-]/g, \"\")\n .toLowerCase()\n .replaceAll(/-+/g, \"-\")\n .replaceAll(/(^-|-$)/g, \"\");\n};\n\nexport const decodeJwt = (token: string) => {\n const base64Payload = token.split(\".\")[1];\n const base64 = base64Payload.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const payload = decodeURIComponent(\n atob(base64)\n .split(\"\")\n .map((c) => \"%\" + (\"00\" + c.charCodeAt(0).toString(16)).slice(-2))\n .join(\"\"),\n );\n return JSON.parse(payload) as TokenPayload;\n};\n\nexport const buildUser = (payload: TokenPayload): User => ({\n id: payload.sub,\n name: payload.name?.split(\"/\")[0],\n email: payload.preferred_username?.toLowerCase(),\n department: payload.department?.toUpperCase() || \"\",\n employeeId: payload.employeeId?.toUpperCase() || \"\",\n companyName: payload.companyName || \"\",\n hasPermission: (key: keyof typeof permissions) => {\n const allowedGroups = permissions[key];\n return allowedGroups.some((k) => (payload.groups ?? []).includes(k));\n },\n});\n"],"mappings":";;;;;AAiBA,MAAaiB,MAAM,IAAIV,wBAAwB,EAC7CW,MAAM;CACJC,UAAUN,UAAUO;CACpBC,WAAW,qCAAqCR,UAAUS;CAC1DC,aAAa;CACf,EACD,CAAC;AAEF,MAAMC,6BAA6B;AACjC,KAAIP,IAAIQ,kBAAkB,CAAE;CAC5B,MAAM,CAACC,gBAAgBT,IAAIU,gBAAgB;AAC3C,KAAID,aAAcT,KAAIW,iBAAiBF,aAAa;;AAGtD,MAAMG,iBAAiB,YAAY;AACjC,KAAIC,WAAWC,WAAWC,KAAAA,EAAW;AAErC,OAAMf,IAAIgB,YAAY;AAEtBhB,KAAIiB,kBAAkBC,UAAwB;AAC5C,MAAIA,MAAMC,cAAcjC,UAAUkC,iBAAiBF,MAAMG,SAAS;GAChE,MAAMA,UAAUH,MAAMG;AACtBrB,OAAIW,iBAAiBU,QAAQC,QAAQ;;GAEvC;CAEF,MAAMC,WAAW,MAAMvB,IAAIwB,uBAAuB;AAClD,KAAID,UAAUD,SAAS;AACrBtB,MAAIW,iBAAiBY,SAASD,QAAQ;AACtC;;AAGFf,uBAAsB;;AAGxB,MAAMkB,wBAAwBb,gBAAgB;AAC9C,MAAMa;AAIN,IAAaE,2BAAb,cAA8CvC,iBAAiB;CAC7DwC,YAAY,UAA2D;AACrE,SAAO;AADoBC,OAAAA,WAAAA;;CAG7B,MAAME,iBAAiBC,KAAaC,SAA4B;EAC9D,MAAMC,WAAWF,IAAIG,QAAQC,SAASC,QAAQ,GAAG;AACjD,OAAKR,SAAS;GAAES,IAAIJ;GAAUC,SAASF,QAAQM;GAAW,CAAC;AAC3D,SAAO;;;AAIX,MAAaC,UAAU/C,oBAAoB,CACxCgD,a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