@rytass/bpm-core-react 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +1 -0
- package/dist/chunks/{FormBuilderView-bm8P55hp.cjs → FormBuilderView-Bg9ftYz-.cjs} +2 -2
- package/dist/chunks/{FormBuilderView-bm8P55hp.cjs.map → FormBuilderView-Bg9ftYz-.cjs.map} +1 -1
- package/dist/chunks/{FormBuilderView-D_bN9gzT.js → FormBuilderView-CBvdcg_t.js} +2 -2
- package/dist/chunks/{FormBuilderView-D_bN9gzT.js.map → FormBuilderView-CBvdcg_t.js.map} +1 -1
- package/dist/chunks/FormRendererView-D-p6GDQB.cjs +6 -0
- package/dist/chunks/FormRendererView-D-p6GDQB.cjs.map +1 -0
- package/dist/chunks/FormRendererView-DHXmekC3.js +1319 -0
- package/dist/chunks/FormRendererView-DHXmekC3.js.map +1 -0
- package/dist/chunks/{approval-instance-list-page-Cv5I1YPX.cjs → approval-instance-list-page-BqkG9jiR.cjs} +2 -2
- package/dist/chunks/{approval-instance-list-page-Cv5I1YPX.cjs.map → approval-instance-list-page-BqkG9jiR.cjs.map} +1 -1
- package/dist/chunks/{approval-instance-list-page-BI5fIXc-.js → approval-instance-list-page-CsSpIN4C.js} +2 -2
- package/dist/chunks/{approval-instance-list-page-BI5fIXc-.js.map → approval-instance-list-page-CsSpIN4C.js.map} +1 -1
- package/dist/chunks/{compose-CdKVQfjB.cjs → compose-B43jtdyL.cjs} +2 -2
- package/dist/chunks/{compose-CdKVQfjB.cjs.map → compose-B43jtdyL.cjs.map} +1 -1
- package/dist/chunks/{compose-N9657E5u.js → compose-C7yS6bJm.js} +5 -5
- package/dist/chunks/{compose-N9657E5u.js.map → compose-C7yS6bJm.js.map} +1 -1
- package/dist/chunks/{dashboard-page-BoqNhjT_.js → dashboard-page-DBJCsPya.js} +2 -2
- package/dist/chunks/{dashboard-page-BoqNhjT_.js.map → dashboard-page-DBJCsPya.js.map} +1 -1
- package/dist/chunks/{dashboard-page-D7YJ3udk.cjs → dashboard-page-lqlLELKs.cjs} +2 -2
- package/dist/chunks/{dashboard-page-D7YJ3udk.cjs.map → dashboard-page-lqlLELKs.cjs.map} +1 -1
- package/dist/chunks/{designer-CKwG_vM5.js → designer-B9Ut4xze.js} +1736 -1611
- package/dist/chunks/designer-B9Ut4xze.js.map +1 -0
- package/dist/chunks/designer-eXw7R9ug.cjs +69 -0
- package/dist/chunks/designer-eXw7R9ug.cjs.map +1 -0
- package/dist/chunks/{detail-fW0vJudE.js → detail-BB_uYaoM.js} +7 -6
- package/dist/chunks/detail-BB_uYaoM.js.map +1 -0
- package/dist/chunks/detail-DN8pEzUJ.cjs +5 -0
- package/dist/chunks/detail-DN8pEzUJ.cjs.map +1 -0
- package/dist/chunks/member-profile-resolution-CJlgVdTR.js +44 -0
- package/dist/chunks/member-profile-resolution-CJlgVdTR.js.map +1 -0
- package/dist/chunks/member-profile-resolution-DiH-P-Vh.cjs +2 -0
- package/dist/chunks/member-profile-resolution-DiH-P-Vh.cjs.map +1 -0
- package/dist/chunks/{providers-CQWekD7_.js → providers-D35lBOTd.js} +2 -2
- package/dist/chunks/{providers-CQWekD7_.js.map → providers-D35lBOTd.js.map} +1 -1
- package/dist/chunks/{providers-VUOh6i0i.cjs → providers-Dz4Wqxr6.cjs} +2 -2
- package/dist/chunks/{providers-VUOh6i0i.cjs.map → providers-Dz4Wqxr6.cjs.map} +1 -1
- package/dist/chunks/{routes-config-C1j_vFKo.cjs → routes-config-BWjZDAU3.cjs} +2 -2
- package/dist/chunks/{routes-config-C1j_vFKo.cjs.map → routes-config-BWjZDAU3.cjs.map} +1 -1
- package/dist/chunks/{routes-config-BcNaWJWJ.js → routes-config-DjEOE9eP.js} +3 -2
- package/dist/chunks/{routes-config-BcNaWJWJ.js.map → routes-config-DjEOE9eP.js.map} +1 -1
- package/dist/chunks/users-C_Dtw_sR.cjs +2 -0
- package/dist/chunks/users-C_Dtw_sR.cjs.map +1 -0
- package/dist/chunks/users-wgM3TqU3.js +513 -0
- package/dist/chunks/users-wgM3TqU3.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/lib/routes-config.d.cts +2 -0
- package/dist/lib/routes-config.d.ts +2 -0
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.js +2 -2
- package/dist/pages/admin/stuck-instances/index.cjs +2 -0
- package/dist/pages/admin/stuck-instances/index.cjs.map +1 -0
- package/dist/pages/admin/stuck-instances/index.d.cts +4 -0
- package/dist/pages/admin/stuck-instances/index.d.ts +4 -0
- package/dist/pages/admin/stuck-instances/index.js +13 -0
- package/dist/pages/admin/stuck-instances/index.js.map +1 -0
- package/dist/pages/admin/users/index.cjs +1 -1
- package/dist/pages/admin/users/index.js +1 -1
- package/dist/pages/instances/detail/index.cjs +1 -1
- package/dist/pages/instances/detail/index.js +1 -1
- package/dist/pages/templates/compose/index.cjs +1 -1
- package/dist/pages/templates/compose/index.js +1 -1
- package/dist/pages/templates/designer/index.cjs +1 -1
- package/dist/pages/templates/designer/index.js +1 -1
- package/dist/views/admin/index.cjs +1 -1
- package/dist/views/admin/index.d.cts +1 -0
- package/dist/views/admin/index.d.ts +1 -0
- package/dist/views/admin/index.js +3 -2
- package/dist/views/admin/stuck-instances/AdminStuckInstancesView.d.cts +10 -0
- package/dist/views/admin/stuck-instances/AdminStuckInstancesView.d.ts +10 -0
- package/dist/views/admin/stuck-instances/StuckInstanceCancelModal.d.cts +14 -0
- package/dist/views/admin/stuck-instances/StuckInstanceCancelModal.d.ts +14 -0
- package/dist/views/admin/stuck-instances/index.cjs +2 -0
- package/dist/views/admin/stuck-instances/index.cjs.map +1 -0
- package/dist/views/admin/stuck-instances/index.d.cts +2 -0
- package/dist/views/admin/stuck-instances/index.d.ts +2 -0
- package/dist/views/admin/stuck-instances/index.js +237 -0
- package/dist/views/admin/stuck-instances/index.js.map +1 -0
- package/dist/views/admin/users/index.cjs +1 -1
- package/dist/views/admin/users/index.js +1 -1
- package/dist/views/cc/index.cjs +1 -1
- package/dist/views/cc/index.js +1 -1
- package/dist/views/dashboard/index.cjs +1 -1
- package/dist/views/dashboard/index.js +1 -1
- package/dist/views/forms/builder/index.cjs +1 -1
- package/dist/views/forms/builder/index.js +1 -1
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.js +1 -1
- package/dist/views/inbox/index.cjs +1 -1
- package/dist/views/inbox/index.js +1 -1
- package/dist/views/instances/detail/index.cjs +1 -1
- package/dist/views/instances/detail/index.js +1 -1
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.js +4 -4
- package/dist/views/instances/new/index.js.map +1 -1
- package/dist/views/search/index.cjs +1 -1
- package/dist/views/search/index.js +1 -1
- package/dist/views/sent/index.cjs +1 -1
- package/dist/views/sent/index.js +1 -1
- package/dist/views/templates/compose/index.cjs +1 -1
- package/dist/views/templates/compose/index.js +1 -1
- package/dist/views/templates/designer/approver-resolver-model.d.cts +31 -0
- package/dist/views/templates/designer/approver-resolver-model.d.ts +31 -0
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/designer/node-actor-resolver-options.d.cts +30 -3
- package/dist/views/templates/designer/node-actor-resolver-options.d.ts +30 -3
- package/dist/views/templates/index.cjs +1 -1
- package/dist/views/templates/index.js +1 -1
- package/dist/views/templates/versions/index.cjs +1 -1
- package/dist/views/templates/versions/index.js +1 -1
- package/package.json +23 -3
- package/dist/chunks/FormRendererView-BlQgJOkI.cjs +0 -6
- package/dist/chunks/FormRendererView-BlQgJOkI.cjs.map +0 -1
- package/dist/chunks/FormRendererView-CemHvfAT.js +0 -1359
- package/dist/chunks/FormRendererView-CemHvfAT.js.map +0 -1
- package/dist/chunks/designer-CKwG_vM5.js.map +0 -1
- package/dist/chunks/designer-JPs7EijM.cjs +0 -69
- package/dist/chunks/designer-JPs7EijM.cjs.map +0 -1
- package/dist/chunks/detail-Dqu0K9QM.cjs +0 -5
- package/dist/chunks/detail-Dqu0K9QM.cjs.map +0 -1
- package/dist/chunks/detail-fW0vJudE.js.map +0 -1
- package/dist/chunks/users-BBtiZ9QQ.js +0 -486
- package/dist/chunks/users-BBtiZ9QQ.js.map +0 -1
- package/dist/chunks/users-EqSzDhuj.cjs +0 -2
- package/dist/chunks/users-EqSzDhuj.cjs.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
async function e(e, t, r = {}) {
|
|
2
|
+
let i = r.maxPerIdRequests ?? 20, a = Math.max(1, r.concurrency ?? 4);
|
|
3
|
+
try {
|
|
4
|
+
return {
|
|
5
|
+
failedIds: [],
|
|
6
|
+
profiles: await t(e),
|
|
7
|
+
skippedIds: []
|
|
8
|
+
};
|
|
9
|
+
} catch {
|
|
10
|
+
if (e.length <= 1) return {
|
|
11
|
+
failedIds: e,
|
|
12
|
+
profiles: [],
|
|
13
|
+
skippedIds: []
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
let o = e.slice(0, i), s = await n(o, a, (e) => t([e]));
|
|
17
|
+
return {
|
|
18
|
+
failedIds: o.filter((e, t) => s[t].status === "rejected"),
|
|
19
|
+
profiles: s.flatMap((e) => e.status === "fulfilled" ? e.value : []),
|
|
20
|
+
skippedIds: e.slice(i)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function t(e, t) {
|
|
24
|
+
return e.filter((e) => !t.has(e));
|
|
25
|
+
}
|
|
26
|
+
async function n(e, t, n) {
|
|
27
|
+
let r = [], i = 0;
|
|
28
|
+
async function a() {
|
|
29
|
+
for (; i < e.length;) {
|
|
30
|
+
let t = i;
|
|
31
|
+
i += 1, r[t] = await n(e[t]).then((e) => ({
|
|
32
|
+
status: "fulfilled",
|
|
33
|
+
value: e
|
|
34
|
+
}), (e) => ({
|
|
35
|
+
reason: e,
|
|
36
|
+
status: "rejected"
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return await Promise.all(Array.from({ length: Math.min(t, e.length) }, a)), r;
|
|
41
|
+
}
|
|
42
|
+
export { e as n, t };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=member-profile-resolution-CJlgVdTR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"member-profile-resolution-CJlgVdTR.js","names":["resolveMemberProfilesPerIdOnFailure","maxPerIdRequests","limits","concurrency","resolveMembers","memberIds","askedIds","settled","settleWithConcurrency","memberId","index","result","excludeFailedMemberIds","failedMemberIds","results","nextIndex","worker","items","run"],"sources":["../../src/lib/member-profile-resolution.ts"],"sourcesContent":["import type { MemberProfileRecord } from '@rytass/bpm-core-client/template';\n\n/** Most ids asked for on their own after a failed batch, per round. */\nexport const MAX_PER_ID_REQUESTS = 20;\n\n/** Most per-id requests in flight at once. */\nexport const PER_ID_CONCURRENCY = 4;\n\nexport type MemberProfileResolution = Readonly<{\n /** Ids whose lookup failed even when asked for on their own. */\n failedIds: readonly string[];\n profiles: readonly MemberProfileRecord[];\n /**\n * Ids left unasked because a failed batch held more than the per-id budget.\n * They were not tried, so a later round may ask for them again.\n */\n skippedIds: readonly string[];\n}>;\n\nexport type MemberProfileResolutionLimits = Readonly<{\n concurrency?: number;\n maxPerIdRequests?: number;\n}>;\n\n/**\n * Looks up member profiles in one batch, and degrades per id when the batch\n * request fails.\n *\n * The host fails a whole lookup when it contains an id it cannot handle (a\n * foreign id stored in a template, say). Treating that as \"nobody resolved\"\n * labels every approver of the template 「未知會員」 for the sake of one bad\n * id, so a failed batch is retried one id at a time and only the ids that fail\n * on their own are reported back in `failedIds`.\n *\n * The retry is bounded: at most `maxPerIdRequests` ids are asked for on their\n * own (the rest come back in `skippedIds` without a request), and at most\n * `concurrency` of those requests run at once, so one bad id in a large\n * template cannot turn into a burst of requests.\n *\n * A single-id batch is not retried: it already is the per-id request.\n */\nexport async function resolveMemberProfilesPerIdOnFailure(\n memberIds: readonly string[],\n resolveMembers: (\n memberIds: readonly string[],\n ) => Promise<readonly MemberProfileRecord[]>,\n limits: MemberProfileResolutionLimits = {},\n): Promise<MemberProfileResolution> {\n const maxPerIdRequests = limits.maxPerIdRequests ?? MAX_PER_ID_REQUESTS;\n const concurrency = Math.max(1, limits.concurrency ?? PER_ID_CONCURRENCY);\n\n try {\n return {\n failedIds: [],\n profiles: await resolveMembers(memberIds),\n skippedIds: [],\n };\n } catch {\n if (memberIds.length <= 1) {\n return { failedIds: memberIds, profiles: [], skippedIds: [] };\n }\n }\n\n const askedIds = memberIds.slice(0, maxPerIdRequests);\n const settled = await settleWithConcurrency(\n askedIds,\n concurrency,\n (memberId) => resolveMembers([memberId]),\n );\n\n return {\n failedIds: askedIds.filter(\n (_, index) => settled[index].status === 'rejected',\n ),\n profiles: settled.flatMap((result) =>\n result.status === 'fulfilled' ? result.value : [],\n ),\n skippedIds: memberIds.slice(maxPerIdRequests),\n };\n}\n\n/**\n * The ids still worth asking the directory for: those that already failed on\n * their own in this session are left out, so they stay 「未知會員」 instead of\n * being re-requested every time the option list changes.\n *\n * A failed id stays 「未知會員」 for the rest of the session, even when the\n * failure was transient (a network blip, say), unless a later member search\n * returns it and replaces the placeholder. Ids skipped over the per-id cap\n * were never asked and must not be added to `failedMemberIds`.\n */\nexport function excludeFailedMemberIds(\n memberIds: readonly string[],\n failedMemberIds: ReadonlySet<string>,\n): readonly string[] {\n return memberIds.filter((memberId) => !failedMemberIds.has(memberId));\n}\n\nasync function settleWithConcurrency<TItem, TResult>(\n items: readonly TItem[],\n concurrency: number,\n run: (item: TItem) => Promise<TResult>,\n): Promise<readonly PromiseSettledResult<TResult>[]> {\n const results: PromiseSettledResult<TResult>[] = [];\n let nextIndex = 0;\n\n async function worker(): Promise<void> {\n while (nextIndex < items.length) {\n const index = nextIndex;\n\n nextIndex += 1;\n results[index] = await run(items[index]).then(\n (value): PromiseSettledResult<TResult> => ({\n status: 'fulfilled',\n value,\n }),\n (reason: unknown): PromiseSettledResult<TResult> => ({\n reason,\n status: 'rejected',\n }),\n );\n }\n }\n\n await Promise.all(\n Array.from({ length: Math.min(concurrency, items.length) }, worker),\n );\n\n return results;\n}\n"],"mappings":"AAyCA,eAAsBA,EACpB,GACA,GAGA,IAAwC,CAAC,GACP;CAClC,IAAMC,IAAmBC,EAAO,oBAAA,IAC1BC,IAAc,KAAK,IAAI,GAAGD,EAAO,eAAA,CAAiC;CAExE,IAAI;EACF,OAAO;GACL,WAAW,CAAC;GACZ,UAAU,MAAME,EAAeC,CAAS;GACxC,YAAY,CAAC;EACf;CACF,QAAQ;EACN,IAAIA,EAAU,UAAU,GACtB,OAAO;GAAE,WAAWA;GAAW,UAAU,CAAC;GAAG,YAAY,CAAC;EAAE;CAEhE;CAEA,IAAMC,IAAWD,EAAU,MAAM,GAAGJ,CAAgB,GAC9CM,IAAU,MAAMC,EACpBF,GACAH,IACC,MAAaC,EAAe,CAACK,CAAQ,CAAC,CACzC;CAEA,OAAO;EACL,WAAWH,EAAS,QACjB,GAAG,MAAUC,EAAQG,EAAM,CAAC,WAAW,UAC1C;EACA,UAAUH,EAAQ,SAAS,MACzBI,EAAO,WAAW,cAAcA,EAAO,QAAQ,CAAC,CAClD;EACA,YAAYN,EAAU,MAAMJ,CAAgB;CAC9C;AACF;AAYA,SAAgBW,EACd,GACA,GACmB;CACnB,OAAOP,EAAU,QAAQ,MAAa,CAACQ,EAAgB,IAAIJ,CAAQ,CAAC;AACtE;AAEA,eAAeD,EACb,GACA,GACA,GACmD;CACnD,IAAMM,IAA2C,CAAC,GAC9CC,IAAY;CAEhB,eAAeC,IAAwB;EACrC,OAAOD,IAAYE,EAAM,SAAQ;GAC/B,IAAMP,IAAQK;GAGd,AADA,KAAa,GACb,EAAQL,KAAS,MAAMQ,EAAID,EAAMP,EAAM,CAAC,CAAC,MACtC,OAA0C;IACzC,QAAQ;IACR;GACF,KACC,OAAoD;IACnD;IACA,QAAQ;GACV,EACF;EACF;CACF;CAMA,OAJA,MAAM,QAAQ,IACZ,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAIP,GAAac,EAAM,MAAM,EAAE,GAAGD,CAAM,CACpE,GAEOF;AACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function e(e,t,r={}){let i=r.maxPerIdRequests??20,a=Math.max(1,r.concurrency??4);try{return{failedIds:[],profiles:await t(e),skippedIds:[]}}catch{if(e.length<=1)return{failedIds:e,profiles:[],skippedIds:[]}}let o=e.slice(0,i),s=await n(o,a,e=>t([e]));return{failedIds:o.filter((e,t)=>s[t].status===`rejected`),profiles:s.flatMap(e=>e.status===`fulfilled`?e.value:[]),skippedIds:e.slice(i)}}function t(e,t){return e.filter(e=>!t.has(e))}async function n(e,t,n){let r=[],i=0;async function a(){for(;i<e.length;){let t=i;i+=1,r[t]=await n(e[t]).then(e=>({status:`fulfilled`,value:e}),e=>({reason:e,status:`rejected`}))}}return await Promise.all(Array.from({length:Math.min(t,e.length)},a)),r}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=member-profile-resolution-DiH-P-Vh.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"member-profile-resolution-DiH-P-Vh.cjs","names":["resolveMemberProfilesPerIdOnFailure","maxPerIdRequests","limits","concurrency","resolveMembers","memberIds","askedIds","settled","settleWithConcurrency","memberId","index","result","excludeFailedMemberIds","failedMemberIds","results","nextIndex","worker","items","run"],"sources":["../../src/lib/member-profile-resolution.ts"],"sourcesContent":["import type { MemberProfileRecord } from '@rytass/bpm-core-client/template';\n\n/** Most ids asked for on their own after a failed batch, per round. */\nexport const MAX_PER_ID_REQUESTS = 20;\n\n/** Most per-id requests in flight at once. */\nexport const PER_ID_CONCURRENCY = 4;\n\nexport type MemberProfileResolution = Readonly<{\n /** Ids whose lookup failed even when asked for on their own. */\n failedIds: readonly string[];\n profiles: readonly MemberProfileRecord[];\n /**\n * Ids left unasked because a failed batch held more than the per-id budget.\n * They were not tried, so a later round may ask for them again.\n */\n skippedIds: readonly string[];\n}>;\n\nexport type MemberProfileResolutionLimits = Readonly<{\n concurrency?: number;\n maxPerIdRequests?: number;\n}>;\n\n/**\n * Looks up member profiles in one batch, and degrades per id when the batch\n * request fails.\n *\n * The host fails a whole lookup when it contains an id it cannot handle (a\n * foreign id stored in a template, say). Treating that as \"nobody resolved\"\n * labels every approver of the template 「未知會員」 for the sake of one bad\n * id, so a failed batch is retried one id at a time and only the ids that fail\n * on their own are reported back in `failedIds`.\n *\n * The retry is bounded: at most `maxPerIdRequests` ids are asked for on their\n * own (the rest come back in `skippedIds` without a request), and at most\n * `concurrency` of those requests run at once, so one bad id in a large\n * template cannot turn into a burst of requests.\n *\n * A single-id batch is not retried: it already is the per-id request.\n */\nexport async function resolveMemberProfilesPerIdOnFailure(\n memberIds: readonly string[],\n resolveMembers: (\n memberIds: readonly string[],\n ) => Promise<readonly MemberProfileRecord[]>,\n limits: MemberProfileResolutionLimits = {},\n): Promise<MemberProfileResolution> {\n const maxPerIdRequests = limits.maxPerIdRequests ?? MAX_PER_ID_REQUESTS;\n const concurrency = Math.max(1, limits.concurrency ?? PER_ID_CONCURRENCY);\n\n try {\n return {\n failedIds: [],\n profiles: await resolveMembers(memberIds),\n skippedIds: [],\n };\n } catch {\n if (memberIds.length <= 1) {\n return { failedIds: memberIds, profiles: [], skippedIds: [] };\n }\n }\n\n const askedIds = memberIds.slice(0, maxPerIdRequests);\n const settled = await settleWithConcurrency(\n askedIds,\n concurrency,\n (memberId) => resolveMembers([memberId]),\n );\n\n return {\n failedIds: askedIds.filter(\n (_, index) => settled[index].status === 'rejected',\n ),\n profiles: settled.flatMap((result) =>\n result.status === 'fulfilled' ? result.value : [],\n ),\n skippedIds: memberIds.slice(maxPerIdRequests),\n };\n}\n\n/**\n * The ids still worth asking the directory for: those that already failed on\n * their own in this session are left out, so they stay 「未知會員」 instead of\n * being re-requested every time the option list changes.\n *\n * A failed id stays 「未知會員」 for the rest of the session, even when the\n * failure was transient (a network blip, say), unless a later member search\n * returns it and replaces the placeholder. Ids skipped over the per-id cap\n * were never asked and must not be added to `failedMemberIds`.\n */\nexport function excludeFailedMemberIds(\n memberIds: readonly string[],\n failedMemberIds: ReadonlySet<string>,\n): readonly string[] {\n return memberIds.filter((memberId) => !failedMemberIds.has(memberId));\n}\n\nasync function settleWithConcurrency<TItem, TResult>(\n items: readonly TItem[],\n concurrency: number,\n run: (item: TItem) => Promise<TResult>,\n): Promise<readonly PromiseSettledResult<TResult>[]> {\n const results: PromiseSettledResult<TResult>[] = [];\n let nextIndex = 0;\n\n async function worker(): Promise<void> {\n while (nextIndex < items.length) {\n const index = nextIndex;\n\n nextIndex += 1;\n results[index] = await run(items[index]).then(\n (value): PromiseSettledResult<TResult> => ({\n status: 'fulfilled',\n value,\n }),\n (reason: unknown): PromiseSettledResult<TResult> => ({\n reason,\n status: 'rejected',\n }),\n );\n }\n }\n\n await Promise.all(\n Array.from({ length: Math.min(concurrency, items.length) }, worker),\n );\n\n return results;\n}\n"],"mappings":"AAyCA,eAAsBA,EACpB,EACA,EAGA,EAAwC,CAAC,EACP,CAClC,IAAMC,EAAmBC,EAAO,kBAAA,GAC1BC,EAAc,KAAK,IAAI,EAAGD,EAAO,aAAA,CAAiC,EAExE,GAAI,CACF,MAAO,CACL,UAAW,CAAC,EACZ,SAAU,MAAME,EAAeC,CAAS,EACxC,WAAY,CAAC,CACf,CACF,MAAQ,CACN,GAAIA,EAAU,QAAU,EACtB,MAAO,CAAE,UAAWA,EAAW,SAAU,CAAC,EAAG,WAAY,CAAC,CAAE,CAEhE,CAEA,IAAMC,EAAWD,EAAU,MAAM,EAAGJ,CAAgB,EAC9CM,EAAU,MAAMC,EACpBF,EACAH,EACC,GAAaC,EAAe,CAACK,CAAQ,CAAC,CACzC,EAEA,MAAO,CACL,UAAWH,EAAS,QACjB,EAAG,IAAUC,EAAQG,EAAM,CAAC,SAAW,UAC1C,EACA,SAAUH,EAAQ,QAAS,GACzBI,EAAO,SAAW,YAAcA,EAAO,MAAQ,CAAC,CAClD,EACA,WAAYN,EAAU,MAAMJ,CAAgB,CAC9C,CACF,CAYA,SAAgBW,EACd,EACA,EACmB,CACnB,OAAOP,EAAU,OAAQ,GAAa,CAACQ,EAAgB,IAAIJ,CAAQ,CAAC,CACtE,CAEA,eAAeD,EACb,EACA,EACA,EACmD,CACnD,IAAMM,EAA2C,CAAC,EAC9CC,EAAY,EAEhB,eAAeC,GAAwB,CACrC,KAAOD,EAAYE,EAAM,QAAQ,CAC/B,IAAMP,EAAQK,EAEd,GAAa,EACb,EAAQL,GAAS,MAAMQ,EAAID,EAAMP,EAAM,CAAC,CAAC,KACtC,IAA0C,CACzC,OAAQ,YACR,OACF,GACC,IAAoD,CACnD,SACA,OAAQ,UACV,EACF,CACF,CACF,CAMA,OAJA,MAAM,QAAQ,IACZ,MAAM,KAAK,CAAE,OAAQ,KAAK,IAAIP,EAAac,EAAM,MAAM,CAAE,EAAGD,CAAM,CACpE,EAEOF,CACT,C"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { n as e, t } from "./auth-provider-C2b-5mGt.js";
|
|
3
3
|
import { a as n, r, t as i } from "./organization-time-zone-provider-DNL8yo4-.js";
|
|
4
4
|
import { r as a } from "./router-adapter-CkxCyzf5.js";
|
|
5
|
-
import { r as o } from "./routes-config-
|
|
5
|
+
import { r as o } from "./routes-config-DjEOE9eP.js";
|
|
6
6
|
import { t as s } from "./bpm-form-field-9B-Det0u.js";
|
|
7
7
|
import { Fragment as c, createContext as l, useCallback as u, useContext as d, useEffect as f, useMemo as p, useState as m } from "react";
|
|
8
8
|
import { Typography as ee } from "@mezzanine-ui/react";
|
|
@@ -515,4 +515,4 @@ function I({ children: e, locale: a = y.ZH_TW, language: o = n, organizationTime
|
|
|
515
515
|
}
|
|
516
516
|
export { C as a, ue as i, N as n, w as o, E as r, I as t };
|
|
517
517
|
|
|
518
|
-
//# sourceMappingURL=providers-
|
|
518
|
+
//# sourceMappingURL=providers-D35lBOTd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers-CQWekD7_.js","names":["_Fragment","Modal","Textarea","useAuth","DEFAULT_BPM_LANGUAGE","BPMOrganizationTimeZoneProvider","useRouterAdapter","useBPMRoutes","BPMFormField","Fragment$1","Drawer","Modal$1","NotificationCenter","Textarea$1","NotificationDrawerContext","createContext","NotificationDrawerProvider","isOpen","setIsOpen","useState","open","useCallback","close","toggle","current","value","useMemo","useNotificationDrawer","useContext","NotificationUnreadContext","NotificationUnreadProvider","currentMemberId","member","unreadCount","setUnreadCount","refreshUnreadCount","next","readUnreadNotificationCount","active","useNotificationUnread","buildNotificationOptions","payload","readNotificationPayload","record","canReject","readNotificationAllowReject","opensToFill","readPayloadFlag","isRecord","key","TIME_GROUP_ORDER","TIME_GROUP_LABEL","PAGE_SIZE","TOGGLE_ARCHIVED_OPTION_ID","RESOLVED_TITLE","resolveDisplayTitle","resolveSeverity","toSeverity","NotificationDrawer","router","routes","rows","setRows","totalCount","setTotalCount","page","setPage","loading","setLoading","bulkLoading","setBulkLoading","error","setError","notice","setNotice","filter","setFilter","includeArchived","setIncludeArchived","approveTarget","setApproveTarget","approveComment","setApproveComment","rejectTarget","setRejectTarget","rejectReason","setRejectReason","deciding","setDeciding","trimmedApproveComment","trimmedRejectReason","loadPage","result","listNotifications","nextPage","append","readErrorMessage","handleFilterChange","event","handleMarkAllRead","markAllNotificationsRead","handleLoadMore","handleMarkRead","markNotificationRead","handleArchive","label","unarchiveNotifications","archiveNotifications","handleFilterAreaSelect","option","handleOpenInstance","openApproveModal","closeApproveModal","handleApproveConfirm","target","decideTask","openRejectModal","closeRejectModal","handleRejectConfirm","handleBadgeSelect","action","isCardActivation","card","handleCardActivate","handleCardKeyDown","filteredRows","row","groupedRows","now","buckets","group","accumulator","resolveTimeGroup","items","hasMore","Fragment","openable","itemIndex","Typography","type","notificationDate","nowStartOfDay","notificationStartOfDay","yesterdayStartOfDay","Providers","CalendarLocale","CalendarConfigProviderMoment","BPMLanguageProvider","organizationTimeZone","AuthProvider","children"],"sources":["../../src/lib/notification-drawer-provider.tsx","../../src/lib/notification-unread-provider.tsx","../../src/components/notification-drawer-options.ts","../../src/components/notification-drawer.tsx","../../src/lib/providers.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\ninterface NotificationDrawerContextValue {\n readonly close: () => void;\n readonly isOpen: boolean;\n readonly open: () => void;\n readonly toggle: () => void;\n}\n\nconst NotificationDrawerContext =\n createContext<NotificationDrawerContextValue | null>(null);\n\ninterface NotificationDrawerProviderProps {\n readonly children: ReactNode;\n}\n\n/**\n * Controls the open/closed state of the BPM notification drawer. Wraps\n * children with a context that `<NotificationDrawer />` reads to mount /\n * hide itself, and that the host navigation reads (via\n * `<BPMNotificationBellButton />` or `useNotificationDrawer().open`) to\n * open the drawer when the bell icon is clicked.\n *\n * When used outside this provider, the returned hook is a safe no-op so\n * components don't crash in test or storybook environments.\n */\nexport function NotificationDrawerProvider({\n children,\n}: NotificationDrawerProviderProps): ReactElement {\n const [isOpen, setIsOpen] = useState(false);\n\n const open = useCallback((): void => {\n setIsOpen(true);\n }, []);\n const close = useCallback((): void => {\n setIsOpen(false);\n }, []);\n const toggle = useCallback((): void => {\n setIsOpen((current) => !current);\n }, []);\n\n const value = useMemo<NotificationDrawerContextValue>(\n () => ({ close, isOpen, open, toggle }),\n [close, isOpen, open, toggle],\n );\n\n return (\n <NotificationDrawerContext.Provider value={value}>\n {children}\n </NotificationDrawerContext.Provider>\n );\n}\n\n/**\n * Read the BPM notification drawer's open state and control helpers.\n * Returns a no-op stub when used outside `<NotificationDrawerProvider>`.\n */\nexport function useNotificationDrawer(): NotificationDrawerContextValue {\n const context = useContext(NotificationDrawerContext);\n if (!context) {\n return {\n close: (): void => undefined,\n isOpen: false,\n open: (): void => undefined,\n toggle: (): void => undefined,\n };\n }\n return context;\n}\n","'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { readUnreadNotificationCount } from '@rytass/bpm-core-client/workflow';\nimport { useAuth } from './auth-provider';\n\ninterface NotificationUnreadContextValue {\n readonly refreshUnreadCount: () => Promise<number>;\n readonly unreadCount: number;\n}\n\nconst NotificationUnreadContext =\n createContext<NotificationUnreadContextValue | null>(null);\n\ninterface NotificationUnreadProviderProps {\n readonly children: ReactNode;\n}\n\n/**\n * Polls BPM for the current member's unread notification count via\n * `readUnreadNotificationCount` and exposes it through context for the\n * host navigation (`<BPMNotificationBellButton />` badge or any custom\n * trigger using `useNotificationUnread().unreadCount`) and the BPM\n * `<NotificationDrawer />` (header count). Refresh is triggered on\n * mount and whenever the auth member id changes; consumers can call\n * `refreshUnreadCount()` after acknowledging a notification.\n */\nexport function NotificationUnreadProvider({\n children,\n}: NotificationUnreadProviderProps): ReactElement {\n const { member } = useAuth();\n const currentMemberId = member?.memberId ?? null;\n const [unreadCount, setUnreadCount] = useState(0);\n\n const refreshUnreadCount = useCallback(async (): Promise<number> => {\n if (!currentMemberId) {\n setUnreadCount(0);\n return 0;\n }\n const next = await readUnreadNotificationCount(currentMemberId);\n setUnreadCount(next);\n return next;\n }, [currentMemberId]);\n\n useEffect((): (() => void) => {\n let active = true;\n void (async () => {\n try {\n const next = await refreshUnreadCount();\n if (active) setUnreadCount(next);\n } catch {\n if (active) setUnreadCount(0);\n }\n })();\n return (): void => {\n active = false;\n };\n }, [refreshUnreadCount]);\n\n const value = useMemo<NotificationUnreadContextValue>(\n () => ({ refreshUnreadCount, unreadCount }),\n [refreshUnreadCount, unreadCount],\n );\n\n return (\n <NotificationUnreadContext.Provider value={value}>\n {children}\n </NotificationUnreadContext.Provider>\n );\n}\n\n/**\n * Read the current unread-notification count and a manual refresh helper.\n * Returns a zero/no-op stub when used outside\n * `<NotificationUnreadProvider>`.\n */\nexport function useNotificationUnread(): NotificationUnreadContextValue {\n const context = useContext(NotificationUnreadContext);\n if (!context) {\n return {\n refreshUnreadCount: async (): Promise<number> => 0,\n unreadCount: 0,\n };\n }\n return context;\n}\n","import type { DropdownOption } from '@mezzanine-ui/core/dropdown/dropdown';\nimport type { NotificationRecord } from '@rytass/bpm-core-client/workflow';\n\nexport type NotificationAction =\n 'approve' | 'archive' | 'reject' | 'unarchive' | 'view' | 'read';\n\n/**\n * Build the `...` dropdown options for one notification. Approve / reject are\n * offered only while the server still reports the notification as `actionable`\n * (an unresolved task assignment) — once the task is decided / cancelled the\n * backend flips `actionable` to false, so a stale \"同意\" can never appear.\n * A task that fills in form fields (`hasFillableFields`) cannot be approved\n * from here — the fill has to be entered on the case page — so its \"同意\"\n * becomes \"開啟案件\". So does a task at a node that requires an approval\n * comment (`requireApprovalComment`): the drawer has no comment dialog of its\n * own for that, the case page does.\n * \"查看案件\" needs an `instanceId`; \"標為已讀\" only shows while unread.\n * Archiving is independent of read state, so the entry flips between\n * \"封存\" / \"取消封存\" for every notification.\n */\nexport function buildNotificationOptions(\n record: NotificationRecord,\n): readonly DropdownOption[] {\n const payload = readNotificationPayload(record);\n const canReject = readNotificationAllowReject(record, payload) !== false;\n const opensToFill =\n record.actionable &&\n Boolean(record.instanceId) &&\n (readPayloadFlag(payload, 'hasFillableFields') ||\n readPayloadFlag(payload, 'requireApprovalComment'));\n\n return [\n ...(record.actionable\n ? ([\n opensToFill\n ? { id: 'view', name: '開啟案件' }\n : { id: 'approve', name: '同意' },\n ...(canReject ? [{ id: 'reject', name: '拒絕' }] : []),\n ] satisfies DropdownOption[])\n : []),\n ...(record.instanceId && !opensToFill\n ? ([{ id: 'view', name: '查看案件' }] satisfies DropdownOption[])\n : []),\n ...(record.status !== 'READ'\n ? ([{ id: 'read', name: '標為已讀' }] satisfies DropdownOption[])\n : []),\n record.archivedAt\n ? { id: 'unarchive', name: '取消封存' }\n : { id: 'archive', name: '封存' },\n ];\n}\n\n/**\n * The notification's `payloadJson`, parsed once. `null` when it is not a JSON\n * object; every reader below takes this one result.\n */\nfunction readNotificationPayload(\n record: NotificationRecord,\n): Readonly<Record<string, unknown>> | null {\n try {\n const payload: unknown = JSON.parse(record.payloadJson);\n\n return isRecord(payload) ? payload : null;\n } catch {\n return null;\n }\n}\n\nfunction readNotificationAllowReject(\n record: NotificationRecord,\n payload: Readonly<Record<string, unknown>> | null,\n): boolean | null {\n if (payload && typeof payload.allowReject === 'boolean') {\n return payload.allowReject;\n }\n\n return record.allowReject;\n}\n\n/**\n * `true` only when the payload sets the flag to `true`. A missing key, a\n * `false`, or an unparsable payload all read as `false`.\n *\n * `TASK_ASSIGNED` / `TASK_TRANSFERRED` payloads carry `hasFillableFields`, and\n * `requireApprovalComment: true` only when the node asks for a comment on\n * approval. Notifications created before those keys existed read as `false`.\n */\nfunction readPayloadFlag(\n payload: Readonly<Record<string, unknown>> | null,\n key: string,\n): boolean {\n return payload !== null && payload[key] === true;\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","'use client';\n\nimport {\n Fragment,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n} from 'react';\nimport Drawer from '@mezzanine-ui/react/Drawer';\nimport Modal from '@mezzanine-ui/react/Modal';\nimport NotificationCenter from '@mezzanine-ui/react/NotificationCenter';\nimport Textarea from '@mezzanine-ui/react/Textarea';\nimport { Typography } from '@mezzanine-ui/react';\nimport type { NotificationSeverity } from '@mezzanine-ui/core/notification-center';\nimport type { DropdownOption } from '@mezzanine-ui/core/dropdown/dropdown';\nimport {\n archiveNotifications,\n decideTask,\n listNotifications,\n markAllNotificationsRead,\n markNotificationRead,\n unarchiveNotifications,\n type NotificationRecord,\n type NotificationResolution,\n type NotificationType,\n} from '@rytass/bpm-core-client/workflow';\nimport { useAuth } from '../lib/auth-provider';\nimport { useNotificationDrawer } from '../lib/notification-drawer-provider';\nimport { useNotificationUnread } from '../lib/notification-unread-provider';\nimport { useRouterAdapter } from '../lib/router-adapter';\nimport { useBPMRoutes } from '../lib/routes-config';\nimport { BPMFormField } from './bpm-form-field';\nimport {\n buildNotificationOptions,\n type NotificationAction,\n} from './notification-drawer-options';\n\ntype FilterValue = 'all' | 'read' | 'unread';\n\ntype TimeGroup = 'today' | 'yesterday' | 'past7Days' | 'earlier';\n\nconst TIME_GROUP_ORDER: readonly TimeGroup[] = [\n 'today',\n 'yesterday',\n 'past7Days',\n 'earlier',\n];\n\nconst TIME_GROUP_LABEL: Readonly<Record<TimeGroup, string>> = {\n earlier: '更早',\n past7Days: '過去七天',\n today: '今天',\n yesterday: '昨天',\n};\n\nconst PAGE_SIZE = 50;\n\n/** Identifier for the filter-bar dropdown entry toggling the archived view. */\nconst TOGGLE_ARCHIVED_OPTION_ID = 'toggleArchived';\n\n/**\n * Title shown for a resolved task-assignment notification, replacing the\n * stored \"新的待簽任務\" wording so a decided card no longer reads as pending.\n * The stored `body` is kept as historical context (which case / node).\n */\nconst RESOLVED_TITLE: Readonly<Record<NotificationResolution, string>> = {\n APPROVED: '簽核任務已同意',\n REJECTED: '簽核任務已拒絕',\n RETURNED: '簽核任務已退回',\n SUPERSEDED: '簽核任務已結束',\n TRANSFERRED: '簽核任務已轉派',\n};\n\nfunction resolveDisplayTitle(record: NotificationRecord): string {\n return record.resolution ? RESOLVED_TITLE[record.resolution] : record.title;\n}\n\n/**\n * Severity (icon colour) for a notification. Once resolved, it reflects the\n * outcome — green for approved, red for rejected, neutral otherwise — instead\n * of the original by-type colour.\n */\nfunction resolveSeverity(record: NotificationRecord): NotificationSeverity {\n if (record.resolution === 'APPROVED') return 'success';\n if (record.resolution === 'REJECTED') return 'error';\n if (record.resolution) return 'info';\n return toSeverity(record.type);\n}\n\n/**\n * Right-side notification drawer mounted at the root by `<Providers>`.\n * Opens / closes via `useNotificationDrawer()`, polls\n * `listNotifications()` for the current member, supports filter\n * (`all` / `read` / `unread`), per-row mark-read, per-row archive / unarchive,\n * bulk mark-all-read, and load-more pagination. Archived notifications are\n * hidden until the filter-bar menu turns \"顯示已封存\" on. Clicking a row with an\n * `instanceId` navigates to `/instances/<id>` via the host's router adapter.\n */\nexport function NotificationDrawer(): ReactElement | null {\n const router = useRouterAdapter();\n const routes = useBPMRoutes();\n const { member } = useAuth();\n const { close, isOpen } = useNotificationDrawer();\n const { refreshUnreadCount } = useNotificationUnread();\n const currentMemberId = member?.memberId ?? null;\n const [rows, setRows] = useState<readonly NotificationRecord[]>([]);\n const [totalCount, setTotalCount] = useState(0);\n const [page, setPage] = useState(1);\n const [loading, setLoading] = useState(false);\n const [bulkLoading, setBulkLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [notice, setNotice] = useState<string | null>(null);\n const [filter, setFilter] = useState<FilterValue>('all');\n const [includeArchived, setIncludeArchived] = useState(false);\n const [approveTarget, setApproveTarget] = useState<NotificationRecord | null>(\n null,\n );\n const [approveComment, setApproveComment] = useState('');\n const [rejectTarget, setRejectTarget] = useState<NotificationRecord | null>(\n null,\n );\n const [rejectReason, setRejectReason] = useState('');\n const [deciding, setDeciding] = useState(false);\n\n const trimmedApproveComment = approveComment.trim();\n const trimmedRejectReason = rejectReason.trim();\n\n const loadPage = useCallback(\n async (nextPage: number, append: boolean): Promise<boolean> => {\n if (!currentMemberId) return false;\n setLoading(true);\n setError(null);\n try {\n const result = await listNotifications({\n includeArchived,\n includeRead: true,\n page: nextPage,\n pageSize: PAGE_SIZE,\n recipientMemberId: currentMemberId,\n });\n setRows((current): readonly NotificationRecord[] =>\n append ? [...current, ...result.notifications] : result.notifications,\n );\n setTotalCount(result.totalCount);\n setPage(nextPage);\n await refreshUnreadCount();\n return true;\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n return false;\n } finally {\n setLoading(false);\n }\n },\n [currentMemberId, includeArchived, refreshUnreadCount],\n );\n\n useEffect((): void => {\n if (!isOpen || !currentMemberId) return;\n setError(null);\n setNotice(null);\n void loadPage(1, false);\n }, [isOpen, currentMemberId, loadPage]);\n\n const handleFilterChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>): void => {\n const next = event.target.value;\n if (next === 'all' || next === 'read' || next === 'unread') setFilter(next);\n },\n [],\n );\n\n const handleMarkAllRead = useCallback(async (): Promise<void> => {\n if (!currentMemberId || bulkLoading) return;\n setBulkLoading(true);\n setError(null);\n try {\n await markAllNotificationsRead({ recipientMemberId: currentMemberId });\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setBulkLoading(false);\n }\n }, [bulkLoading, currentMemberId, loadPage]);\n\n const handleLoadMore = useCallback((): void => {\n if (loading) return;\n void loadPage(page + 1, true);\n }, [loading, loadPage, page]);\n\n const handleMarkRead = useCallback(\n async (id: string): Promise<void> => {\n if (!currentMemberId) return;\n try {\n await markNotificationRead({ id, readerMemberId: currentMemberId });\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [currentMemberId, loadPage],\n );\n\n const handleArchive = useCallback(\n async (record: NotificationRecord): Promise<void> => {\n if (!currentMemberId) return;\n setError(null);\n setNotice(null);\n try {\n // Name the notification the way the row does — `title` is the raw\n // stored title, which can differ from the rendered one.\n const label = resolveDisplayTitle(record);\n\n if (record.archivedAt) {\n await unarchiveNotifications({ ids: [record.id] });\n setNotice(`已將「${label}」移出封存。`);\n } else {\n await archiveNotifications({ ids: [record.id] });\n setNotice(`已封存「${label}」。`);\n }\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [currentMemberId, loadPage],\n );\n\n const handleFilterAreaSelect = useCallback((option: DropdownOption): void => {\n if (option.id !== TOGGLE_ARCHIVED_OPTION_ID) return;\n setNotice(null);\n setIncludeArchived((current): boolean => !current);\n }, []);\n\n const handleOpenInstance = useCallback(\n async (record: NotificationRecord): Promise<void> => {\n if (!record.instanceId || !currentMemberId) return;\n try {\n if (record.status !== 'READ') {\n await markNotificationRead({\n id: record.id,\n readerMemberId: currentMemberId,\n });\n await refreshUnreadCount();\n }\n close();\n router.push(routes.caseDetail(record.instanceId));\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [close, currentMemberId, refreshUnreadCount, router, routes],\n );\n\n const openApproveModal = useCallback((record: NotificationRecord): void => {\n setError(null);\n setApproveTarget(record);\n setApproveComment('');\n }, []);\n\n const closeApproveModal = useCallback((): void => {\n if (deciding) return;\n setApproveTarget(null);\n setApproveComment('');\n }, [deciding]);\n\n const handleApproveConfirm = useCallback(async (): Promise<void> => {\n const target = approveTarget;\n if (!target?.taskId || !currentMemberId || deciding) return;\n setDeciding(true);\n setError(null);\n setNotice(null);\n try {\n await decideTask({\n action: 'APPROVED',\n comment: trimmedApproveComment || null,\n decidedByMemberId: currentMemberId,\n taskId: target.taskId,\n });\n const refreshed = await loadPage(1, false);\n if (!refreshed) return;\n setApproveTarget(null);\n setApproveComment('');\n setNotice(`已同意「${target.title}」。`);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setDeciding(false);\n }\n }, [\n approveTarget,\n currentMemberId,\n deciding,\n loadPage,\n trimmedApproveComment,\n ]);\n\n const openRejectModal = useCallback((record: NotificationRecord): void => {\n setRejectTarget(record);\n setRejectReason('');\n }, []);\n\n const closeRejectModal = useCallback((): void => {\n setRejectTarget(null);\n setRejectReason('');\n }, []);\n\n const handleRejectConfirm = useCallback(async (): Promise<void> => {\n const target = rejectTarget;\n if (!target?.taskId || !currentMemberId || !trimmedRejectReason || deciding)\n return;\n setDeciding(true);\n setError(null);\n setNotice(null);\n try {\n await decideTask({\n action: 'REJECTED',\n comment: trimmedRejectReason,\n decidedByMemberId: currentMemberId,\n taskId: target.taskId,\n });\n setRejectTarget(null);\n setRejectReason('');\n setNotice(`已拒絕「${target.title}」。`);\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setDeciding(false);\n }\n }, [currentMemberId, deciding, loadPage, rejectTarget, trimmedRejectReason]);\n\n const handleBadgeSelect = useCallback(\n (record: NotificationRecord, option: DropdownOption): void => {\n const action = option.id as NotificationAction;\n if (action === 'approve') openApproveModal(record);\n else if (action === 'reject') openRejectModal(record);\n else if (action === 'view') void handleOpenInstance(record);\n else if (action === 'read') void handleMarkRead(record.id);\n else if (action === 'archive' || action === 'unarchive')\n void handleArchive(record);\n },\n [\n handleArchive,\n handleMarkRead,\n handleOpenInstance,\n openApproveModal,\n openRejectModal,\n ],\n );\n\n /**\n * Whether an event that reached the card wrapper actually happened inside the\n * card, and not on one of its action controls.\n *\n * Two escape hatches are needed. The `...` menu button (and its `<svg>` icon —\n * hence the `Element` check, SVG nodes are not HTMLElements) sits inside the\n * card and must open the dropdown rather than navigate. The dropdown itself\n * renders into a portal, and React replays events along the component tree\n * rather than the DOM tree, so picking \"封存\" also reaches this handler even\n * though the `<li role=\"option\">` lives outside the card's DOM — and it is not\n * a `<button>`, so the first guard alone misses it.\n */\n const isCardActivation = useCallback(\n (target: EventTarget | null, card: HTMLDivElement): boolean => {\n if (!(target instanceof Node) || !card.contains(target)) return false;\n\n return !(target instanceof Element && target.closest('button'));\n },\n [],\n );\n\n const handleCardActivate = useCallback(\n (record: NotificationRecord, event: ReactMouseEvent<HTMLDivElement>): void => {\n if (!isCardActivation(event.target, event.currentTarget)) return;\n void handleOpenInstance(record);\n },\n [handleOpenInstance, isCardActivation],\n );\n\n const handleCardKeyDown = useCallback(\n (\n record: NotificationRecord,\n event: ReactKeyboardEvent<HTMLDivElement>,\n ): void => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (!isCardActivation(event.target, event.currentTarget)) return;\n event.preventDefault();\n void handleOpenInstance(record);\n },\n [handleOpenInstance, isCardActivation],\n );\n\n const filteredRows = useMemo(\n (): readonly NotificationRecord[] =>\n rows.filter((row): boolean => {\n if (filter === 'all') return true;\n if (filter === 'read') return row.status === 'READ';\n return row.status !== 'READ';\n }),\n [filter, rows],\n );\n\n const groupedRows = useMemo(\n (): ReadonlyArray<readonly [TimeGroup, readonly NotificationRecord[]]> => {\n const now = new Date();\n const buckets = TIME_GROUP_ORDER.reduce<\n Record<TimeGroup, NotificationRecord[]>\n >(\n (accumulator, group) => {\n accumulator[group] = [];\n return accumulator;\n },\n { earlier: [], past7Days: [], today: [], yesterday: [] },\n );\n filteredRows.forEach((row): void => {\n buckets[resolveTimeGroup(row.createdAt, now)].push(row);\n });\n return TIME_GROUP_ORDER.map(\n (group) => [group, buckets[group]] as const,\n ).filter(([, items]) => items.length > 0);\n },\n [filteredRows],\n );\n\n const hasMore = rows.length < totalCount;\n\n if (!currentMemberId) return null;\n\n return (\n <>\n <Drawer\n bottomGhostActionDisabled={bulkLoading || loading}\n bottomGhostActionLoading={bulkLoading}\n bottomGhostActionText=\"全部標為已讀\"\n bottomOnGhostActionClick={(): void => {\n void handleMarkAllRead();\n }}\n bottomOnPrimaryActionClick={(): void => {\n handleLoadMore();\n }}\n bottomPrimaryActionDisabled={!hasMore || loading}\n bottomPrimaryActionLoading={loading && hasMore}\n bottomPrimaryActionText={hasMore ? '載入更多' : '已顯示全部'}\n contentKey={`${filter}:${includeArchived}:${rows.length}`}\n filterAreaAllRadioLabel=\"全部\"\n filterAreaOnRadioChange={handleFilterChange}\n filterAreaOnSelect={handleFilterAreaSelect}\n filterAreaOptions={[\n {\n id: TOGGLE_ARCHIVED_OPTION_ID,\n name: includeArchived ? '隱藏已封存' : '顯示已封存',\n },\n ]}\n filterAreaReadRadioLabel=\"已讀\"\n filterAreaShow\n filterAreaUnreadRadioLabel=\"未讀\"\n filterAreaValue={filter}\n headerTitle=\"通知中心\"\n isBottomDisplay\n isHeaderDisplay\n onClose={close}\n open={isOpen}\n size=\"medium\"\n >\n <div role=\"list\">\n {error ? (\n <p\n role=\"alert\"\n style={{\n color: 'var(--mzn-color-text-error, #d92d20)',\n padding: '12px 16px',\n }}\n >\n {error}\n </p>\n ) : null}\n {notice ? (\n <p\n role=\"status\"\n style={{\n color: 'var(--mzn-color-text-success, #079455)',\n padding: '12px 16px',\n }}\n >\n {notice}\n </p>\n ) : null}\n {groupedRows.length === 0 ? (\n <p\n style={{\n color: 'var(--mzn-color-text-secondary, #6b7280)',\n padding: '24px 16px',\n textAlign: 'center',\n }}\n >\n {loading ? '載入中…' : '目前沒有通知'}\n </p>\n ) : null}\n {groupedRows.map(([group, items]) => (\n <Fragment key={group}>\n {items.map((record, itemIndex) => {\n const openable = record.instanceId !== null;\n\n return (\n <div\n key={record.id}\n onClick={\n openable\n ? (event: ReactMouseEvent<HTMLDivElement>): void => {\n handleCardActivate(record, event);\n }\n : undefined\n }\n onKeyDown={\n openable\n ? (event: ReactKeyboardEvent<HTMLDivElement>): void => {\n handleCardKeyDown(record, event);\n }\n : undefined\n }\n role={openable ? 'button' : undefined}\n style={openable ? { cursor: 'pointer' } : undefined}\n tabIndex={openable ? 0 : undefined}\n >\n <NotificationCenter\n appendTips={record.archivedAt ? '已封存' : undefined}\n description={record.body}\n onBadgeSelect={(option: DropdownOption): void => {\n handleBadgeSelect(record, option);\n }}\n options={[...buildNotificationOptions(record)]}\n prependTips={\n itemIndex === 0 ? TIME_GROUP_LABEL[group] : undefined\n }\n reference={record.id}\n severity={resolveSeverity(record)}\n showBadge={record.status !== 'READ'}\n timeStamp={record.createdAt}\n title={resolveDisplayTitle(record)}\n type=\"drawer\"\n />\n </div>\n );\n })}\n </Fragment>\n ))}\n </div>\n </Drawer>\n <Modal\n cancelText=\"取消\"\n confirmText=\"送出同意\"\n loading={deciding}\n modalType=\"standard\"\n onCancel={closeApproveModal}\n onClose={closeApproveModal}\n onConfirm={(): void => {\n void handleApproveConfirm();\n }}\n open={approveTarget !== null}\n showModalFooter\n showModalHeader\n size=\"regular\"\n supportingText=\"可以留下同意說明,內容會記錄在簽核歷程;不填也可以直接送出。\"\n title=\"簽核意見\"\n >\n {error ? (\n <Typography color=\"text-error\" role=\"alert\" variant=\"body\">\n {error}\n </Typography>\n ) : null}\n <BPMFormField label=\"簽核意見\" name=\"notificationApproveComment\">\n <Textarea\n autoFocus\n onChange={(event: ChangeEvent<HTMLTextAreaElement>): void => {\n setApproveComment(event.target.value);\n }}\n placeholder=\"選填,例如補充核准條件或提醒事項\"\n rows={4}\n value={approveComment}\n />\n </BPMFormField>\n </Modal>\n <Modal\n cancelText=\"取消\"\n confirmButtonProps={{\n disabled: !trimmedRejectReason,\n variant: 'destructive-primary',\n }}\n confirmText=\"送出拒絕\"\n loading={deciding}\n modalStatusType=\"error\"\n modalType=\"standard\"\n onCancel={closeRejectModal}\n onClose={closeRejectModal}\n onConfirm={(): void => {\n void handleRejectConfirm();\n }}\n open={rejectTarget !== null}\n showModalFooter\n showModalHeader\n size=\"regular\"\n supportingText=\"拒絕案件時必須留下原因,供發起人與後續追蹤查看。\"\n title=\"拒絕原因\"\n >\n <Textarea\n autoFocus\n onChange={(event: ChangeEvent<HTMLTextAreaElement>): void => {\n setRejectReason(event.target.value);\n }}\n placeholder=\"請輸入拒絕原因\"\n rows={4}\n value={rejectReason}\n />\n </Modal>\n </>\n );\n}\n\nfunction toSeverity(type: NotificationType): NotificationSeverity {\n if (type === 'SLA_OVERDUE') return 'error';\n if (type === 'SLA_WARNING') return 'warning';\n if (type === 'INSTANCE_COMPLETED') return 'success';\n return 'info';\n}\n\nfunction resolveTimeGroup(value: string, now: Date): TimeGroup {\n const notificationDate = new Date(value);\n if (Number.isNaN(notificationDate.getTime())) return 'earlier';\n const nowStartOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n const notificationStartOfDay = new Date(\n notificationDate.getFullYear(),\n notificationDate.getMonth(),\n notificationDate.getDate(),\n );\n if (notificationStartOfDay.getTime() === nowStartOfDay.getTime()) return 'today';\n const yesterdayStartOfDay = new Date(nowStartOfDay);\n yesterdayStartOfDay.setDate(yesterdayStartOfDay.getDate() - 1);\n if (notificationStartOfDay.getTime() === yesterdayStartOfDay.getTime())\n return 'yesterday';\n const diffInDays =\n (now.getTime() - notificationDate.getTime()) / (1000 * 60 * 60 * 24);\n if (diffInDays <= 7) return 'past7Days';\n return 'earlier';\n}\n\nfunction readErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : '發生未知錯誤';\n}\n","'use client';\n\nimport type { ReactElement, ReactNode } from 'react';\nimport {\n CalendarConfigProviderMoment,\n CalendarLocale,\n} from '@mezzanine-ui/react/moment';\nimport { AuthProvider } from './auth-provider';\nimport {\n BPMLanguageProvider,\n DEFAULT_BPM_LANGUAGE,\n type BPMLanguage,\n} from './language-provider';\nimport { BPMOrganizationTimeZoneProvider } from './organization-time-zone-provider';\nimport { NotificationDrawer } from '../components/notification-drawer';\nimport { NotificationDrawerProvider } from './notification-drawer-provider';\nimport { NotificationUnreadProvider } from './notification-unread-provider';\n\ninterface ProvidersProps {\n readonly children: ReactNode;\n /** Override Mezzanine calendar locale. Defaults to `CalendarLocale.ZH_TW`. */\n readonly locale?: CalendarLocale;\n /**\n * Language BPM views write their messages in, such as publish-lint errors.\n * Defaults to `'zh-TW'`. Pass the user's choice as state to let them switch.\n * Independent of `locale`, which only formats calendar dates.\n */\n readonly language?: BPMLanguage;\n /**\n * IANA zone in which BPM views read \"today\" against organization effective\n * dates. Pass the same value given to `BPMRootModule` as\n * `organizationTimeZone`; leave it unset when the API does not set one.\n * Defaults to `DEFAULT_BPM_ORGANIZATION_TIME_ZONE` (`'Asia/Taipei'`); an\n * unknown zone falls back to it with a console warning.\n */\n readonly organizationTimeZone?: string;\n /**\n * Public paths that should not trigger redirect to `/login` when there\n * is no session. Forwarded to `<AuthProvider>`. Defaults to `['/login']`.\n */\n readonly publicPaths?: readonly string[];\n /** Where to send unauthenticated users. Defaults to `'/login'`. */\n readonly loginPath?: string;\n}\n\n/**\n * One-stop BPM admin provider stack. Wires:\n *\n * - Mezzanine UI calendar locale (moment-based, `ZH_TW` by default)\n * - `<BPMLanguageProvider>` (message language, `'zh-TW'` by default)\n * - `<BPMOrganizationTimeZoneProvider>` (organization \"today\" zone)\n * - `<AuthProvider>` (BPM session via REST `/auth/*`)\n * - `<NotificationUnreadProvider>` (polls unread count)\n * - `<NotificationDrawerProvider>` (controls drawer open/close state)\n * - `<NotificationDrawer />` mounted at the root so the host navigation\n * bell (`<BPMNotificationBellButton />` or any custom trigger calling\n * `useNotificationDrawer().open`) can open it.\n *\n * Consumer hosts wrap this **inside** a `<RouterAdapterProvider>` (provided\n * by the `pages/*` subpath shims when consuming via Next.js, or wired by\n * hand for other frameworks).\n */\nexport function Providers({\n children,\n locale = CalendarLocale.ZH_TW,\n language = DEFAULT_BPM_LANGUAGE,\n organizationTimeZone,\n publicPaths,\n loginPath,\n}: ProvidersProps): ReactElement {\n return (\n <CalendarConfigProviderMoment locale={locale}>\n <BPMLanguageProvider language={language}>\n <BPMOrganizationTimeZoneProvider timeZone={organizationTimeZone}>\n <AuthProvider publicPaths={publicPaths} loginPath={loginPath}>\n <NotificationUnreadProvider>\n <NotificationDrawerProvider>\n {children}\n <NotificationDrawer />\n </NotificationDrawerProvider>\n </NotificationUnreadProvider>\n </AuthProvider>\n </BPMOrganizationTimeZoneProvider>\n </BPMLanguageProvider>\n </CalendarConfigProviderMoment>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAMc,IACJC,EAAqD,IAAI;AAgB3D,SAAgBC,EAA2B,EACzC,eACgD;CAChD,IAAM,CAACC,GAAQC,KAAaC,EAAS,EAAK,GAEpCC,IAAOC,QAAwB;EACnC,EAAU,EAAI;CAChB,GAAG,CAAC,CAAC,GACCC,IAAQD,QAAwB;EACpC,EAAU,EAAK;CACjB,GAAG,CAAC,CAAC,GACCE,IAASF,QAAwB;EACrC,GAAW,MAAY,CAACG,CAAO;CACjC,GAAG,CAAC,CAAC,GAECC,IAAQC,SACL;EAAE;EAAO;EAAQ;EAAM;CAAO,IACrC;EAACJ;EAAOL;EAAQG;EAAMG;CAAM,CAC9B;CAEA,OACE,kBAACT,EAA0B,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IAAIE,EAAuB,QAAQ,MAAMD,EAAc,QAAQ,GAAG,OAAO;CACzE,IAAME,IAAsB,IAAI,KAAKF,CAAa;CAOlD,OANAE,EAAoB,QAAQA,EAAoB,QAAQ,IAAI,CAAC,GACzDD,EAAuB,QAAQ,MAAMC,EAAoB,QAAQ,IAC5D,eAENf,EAAI,QAAQ,IAAIY,EAAiB,QAAQ,KAAM,SAChC,IAAU,cACrB;AACT;AAEA,SAAS5C,EAAiB,GAAwB;CAChD,OAAOzB,aAAiB,QAAQA,EAAM,UAAU;AAClD;;AChlBA,SAAgByE,EAAU,EACxB,aACA,YAASC,EAAe,OACxB,cAAW7I,GACX,yBACA,gBACA,gBAC+B;CAC/B,OACE,kBAAC8I,GAAD;EAAsC;EACpC,UAAA,kBAACC,GAAD;GAA+B;GAC7B,UAAA,kBAAC9I,GAAD;IAAiC,UAAU+I;IACzC,UAAA,kBAACC,GAAD;KAA2B;KAAwB;KACjD,UAAA,kBAACvH,GAAD,EAAA,UACE,kBAACd,GAAD,EAAA,UAAA,CACGsI,GACD,kBAAC5F,GAAD,CAAqB,CAAA,CACK,EAAA,CAAA,EACF,CAAA;IAChB,CAAA;GACiB,CAAA;EACd,CAAA;CACO,CAAA;AAElC"}
|
|
1
|
+
{"version":3,"file":"providers-D35lBOTd.js","names":["_Fragment","Modal","Textarea","useAuth","DEFAULT_BPM_LANGUAGE","BPMOrganizationTimeZoneProvider","useRouterAdapter","useBPMRoutes","BPMFormField","Fragment$1","Drawer","Modal$1","NotificationCenter","Textarea$1","NotificationDrawerContext","createContext","NotificationDrawerProvider","isOpen","setIsOpen","useState","open","useCallback","close","toggle","current","value","useMemo","useNotificationDrawer","useContext","NotificationUnreadContext","NotificationUnreadProvider","currentMemberId","member","unreadCount","setUnreadCount","refreshUnreadCount","next","readUnreadNotificationCount","active","useNotificationUnread","buildNotificationOptions","payload","readNotificationPayload","record","canReject","readNotificationAllowReject","opensToFill","readPayloadFlag","isRecord","key","TIME_GROUP_ORDER","TIME_GROUP_LABEL","PAGE_SIZE","TOGGLE_ARCHIVED_OPTION_ID","RESOLVED_TITLE","resolveDisplayTitle","resolveSeverity","toSeverity","NotificationDrawer","router","routes","rows","setRows","totalCount","setTotalCount","page","setPage","loading","setLoading","bulkLoading","setBulkLoading","error","setError","notice","setNotice","filter","setFilter","includeArchived","setIncludeArchived","approveTarget","setApproveTarget","approveComment","setApproveComment","rejectTarget","setRejectTarget","rejectReason","setRejectReason","deciding","setDeciding","trimmedApproveComment","trimmedRejectReason","loadPage","result","listNotifications","nextPage","append","readErrorMessage","handleFilterChange","event","handleMarkAllRead","markAllNotificationsRead","handleLoadMore","handleMarkRead","markNotificationRead","handleArchive","label","unarchiveNotifications","archiveNotifications","handleFilterAreaSelect","option","handleOpenInstance","openApproveModal","closeApproveModal","handleApproveConfirm","target","decideTask","openRejectModal","closeRejectModal","handleRejectConfirm","handleBadgeSelect","action","isCardActivation","card","handleCardActivate","handleCardKeyDown","filteredRows","row","groupedRows","now","buckets","group","accumulator","resolveTimeGroup","items","hasMore","Fragment","openable","itemIndex","Typography","type","notificationDate","nowStartOfDay","notificationStartOfDay","yesterdayStartOfDay","Providers","CalendarLocale","CalendarConfigProviderMoment","BPMLanguageProvider","organizationTimeZone","AuthProvider","children"],"sources":["../../src/lib/notification-drawer-provider.tsx","../../src/lib/notification-unread-provider.tsx","../../src/components/notification-drawer-options.ts","../../src/components/notification-drawer.tsx","../../src/lib/providers.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\ninterface NotificationDrawerContextValue {\n readonly close: () => void;\n readonly isOpen: boolean;\n readonly open: () => void;\n readonly toggle: () => void;\n}\n\nconst NotificationDrawerContext =\n createContext<NotificationDrawerContextValue | null>(null);\n\ninterface NotificationDrawerProviderProps {\n readonly children: ReactNode;\n}\n\n/**\n * Controls the open/closed state of the BPM notification drawer. Wraps\n * children with a context that `<NotificationDrawer />` reads to mount /\n * hide itself, and that the host navigation reads (via\n * `<BPMNotificationBellButton />` or `useNotificationDrawer().open`) to\n * open the drawer when the bell icon is clicked.\n *\n * When used outside this provider, the returned hook is a safe no-op so\n * components don't crash in test or storybook environments.\n */\nexport function NotificationDrawerProvider({\n children,\n}: NotificationDrawerProviderProps): ReactElement {\n const [isOpen, setIsOpen] = useState(false);\n\n const open = useCallback((): void => {\n setIsOpen(true);\n }, []);\n const close = useCallback((): void => {\n setIsOpen(false);\n }, []);\n const toggle = useCallback((): void => {\n setIsOpen((current) => !current);\n }, []);\n\n const value = useMemo<NotificationDrawerContextValue>(\n () => ({ close, isOpen, open, toggle }),\n [close, isOpen, open, toggle],\n );\n\n return (\n <NotificationDrawerContext.Provider value={value}>\n {children}\n </NotificationDrawerContext.Provider>\n );\n}\n\n/**\n * Read the BPM notification drawer's open state and control helpers.\n * Returns a no-op stub when used outside `<NotificationDrawerProvider>`.\n */\nexport function useNotificationDrawer(): NotificationDrawerContextValue {\n const context = useContext(NotificationDrawerContext);\n if (!context) {\n return {\n close: (): void => undefined,\n isOpen: false,\n open: (): void => undefined,\n toggle: (): void => undefined,\n };\n }\n return context;\n}\n","'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { readUnreadNotificationCount } from '@rytass/bpm-core-client/workflow';\nimport { useAuth } from './auth-provider';\n\ninterface NotificationUnreadContextValue {\n readonly refreshUnreadCount: () => Promise<number>;\n readonly unreadCount: number;\n}\n\nconst NotificationUnreadContext =\n createContext<NotificationUnreadContextValue | null>(null);\n\ninterface NotificationUnreadProviderProps {\n readonly children: ReactNode;\n}\n\n/**\n * Polls BPM for the current member's unread notification count via\n * `readUnreadNotificationCount` and exposes it through context for the\n * host navigation (`<BPMNotificationBellButton />` badge or any custom\n * trigger using `useNotificationUnread().unreadCount`) and the BPM\n * `<NotificationDrawer />` (header count). Refresh is triggered on\n * mount and whenever the auth member id changes; consumers can call\n * `refreshUnreadCount()` after acknowledging a notification.\n */\nexport function NotificationUnreadProvider({\n children,\n}: NotificationUnreadProviderProps): ReactElement {\n const { member } = useAuth();\n const currentMemberId = member?.memberId ?? null;\n const [unreadCount, setUnreadCount] = useState(0);\n\n const refreshUnreadCount = useCallback(async (): Promise<number> => {\n if (!currentMemberId) {\n setUnreadCount(0);\n return 0;\n }\n const next = await readUnreadNotificationCount(currentMemberId);\n setUnreadCount(next);\n return next;\n }, [currentMemberId]);\n\n useEffect((): (() => void) => {\n let active = true;\n void (async () => {\n try {\n const next = await refreshUnreadCount();\n if (active) setUnreadCount(next);\n } catch {\n if (active) setUnreadCount(0);\n }\n })();\n return (): void => {\n active = false;\n };\n }, [refreshUnreadCount]);\n\n const value = useMemo<NotificationUnreadContextValue>(\n () => ({ refreshUnreadCount, unreadCount }),\n [refreshUnreadCount, unreadCount],\n );\n\n return (\n <NotificationUnreadContext.Provider value={value}>\n {children}\n </NotificationUnreadContext.Provider>\n );\n}\n\n/**\n * Read the current unread-notification count and a manual refresh helper.\n * Returns a zero/no-op stub when used outside\n * `<NotificationUnreadProvider>`.\n */\nexport function useNotificationUnread(): NotificationUnreadContextValue {\n const context = useContext(NotificationUnreadContext);\n if (!context) {\n return {\n refreshUnreadCount: async (): Promise<number> => 0,\n unreadCount: 0,\n };\n }\n return context;\n}\n","import type { DropdownOption } from '@mezzanine-ui/core/dropdown/dropdown';\nimport type { NotificationRecord } from '@rytass/bpm-core-client/workflow';\n\nexport type NotificationAction =\n 'approve' | 'archive' | 'reject' | 'unarchive' | 'view' | 'read';\n\n/**\n * Build the `...` dropdown options for one notification. Approve / reject are\n * offered only while the server still reports the notification as `actionable`\n * (an unresolved task assignment) — once the task is decided / cancelled the\n * backend flips `actionable` to false, so a stale \"同意\" can never appear.\n * A task that fills in form fields (`hasFillableFields`) cannot be approved\n * from here — the fill has to be entered on the case page — so its \"同意\"\n * becomes \"開啟案件\". So does a task at a node that requires an approval\n * comment (`requireApprovalComment`): the drawer has no comment dialog of its\n * own for that, the case page does.\n * \"查看案件\" needs an `instanceId`; \"標為已讀\" only shows while unread.\n * Archiving is independent of read state, so the entry flips between\n * \"封存\" / \"取消封存\" for every notification.\n */\nexport function buildNotificationOptions(\n record: NotificationRecord,\n): readonly DropdownOption[] {\n const payload = readNotificationPayload(record);\n const canReject = readNotificationAllowReject(record, payload) !== false;\n const opensToFill =\n record.actionable &&\n Boolean(record.instanceId) &&\n (readPayloadFlag(payload, 'hasFillableFields') ||\n readPayloadFlag(payload, 'requireApprovalComment'));\n\n return [\n ...(record.actionable\n ? ([\n opensToFill\n ? { id: 'view', name: '開啟案件' }\n : { id: 'approve', name: '同意' },\n ...(canReject ? [{ id: 'reject', name: '拒絕' }] : []),\n ] satisfies DropdownOption[])\n : []),\n ...(record.instanceId && !opensToFill\n ? ([{ id: 'view', name: '查看案件' }] satisfies DropdownOption[])\n : []),\n ...(record.status !== 'READ'\n ? ([{ id: 'read', name: '標為已讀' }] satisfies DropdownOption[])\n : []),\n record.archivedAt\n ? { id: 'unarchive', name: '取消封存' }\n : { id: 'archive', name: '封存' },\n ];\n}\n\n/**\n * The notification's `payloadJson`, parsed once. `null` when it is not a JSON\n * object; every reader below takes this one result.\n */\nfunction readNotificationPayload(\n record: NotificationRecord,\n): Readonly<Record<string, unknown>> | null {\n try {\n const payload: unknown = JSON.parse(record.payloadJson);\n\n return isRecord(payload) ? payload : null;\n } catch {\n return null;\n }\n}\n\nfunction readNotificationAllowReject(\n record: NotificationRecord,\n payload: Readonly<Record<string, unknown>> | null,\n): boolean | null {\n if (payload && typeof payload.allowReject === 'boolean') {\n return payload.allowReject;\n }\n\n return record.allowReject;\n}\n\n/**\n * `true` only when the payload sets the flag to `true`. A missing key, a\n * `false`, or an unparsable payload all read as `false`.\n *\n * `TASK_ASSIGNED` / `TASK_TRANSFERRED` payloads carry `hasFillableFields`, and\n * `requireApprovalComment: true` only when the node asks for a comment on\n * approval. Notifications created before those keys existed read as `false`.\n */\nfunction readPayloadFlag(\n payload: Readonly<Record<string, unknown>> | null,\n key: string,\n): boolean {\n return payload !== null && payload[key] === true;\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","'use client';\n\nimport {\n Fragment,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n} from 'react';\nimport Drawer from '@mezzanine-ui/react/Drawer';\nimport Modal from '@mezzanine-ui/react/Modal';\nimport NotificationCenter from '@mezzanine-ui/react/NotificationCenter';\nimport Textarea from '@mezzanine-ui/react/Textarea';\nimport { Typography } from '@mezzanine-ui/react';\nimport type { NotificationSeverity } from '@mezzanine-ui/core/notification-center';\nimport type { DropdownOption } from '@mezzanine-ui/core/dropdown/dropdown';\nimport {\n archiveNotifications,\n decideTask,\n listNotifications,\n markAllNotificationsRead,\n markNotificationRead,\n unarchiveNotifications,\n type NotificationRecord,\n type NotificationResolution,\n type NotificationType,\n} from '@rytass/bpm-core-client/workflow';\nimport { useAuth } from '../lib/auth-provider';\nimport { useNotificationDrawer } from '../lib/notification-drawer-provider';\nimport { useNotificationUnread } from '../lib/notification-unread-provider';\nimport { useRouterAdapter } from '../lib/router-adapter';\nimport { useBPMRoutes } from '../lib/routes-config';\nimport { BPMFormField } from './bpm-form-field';\nimport {\n buildNotificationOptions,\n type NotificationAction,\n} from './notification-drawer-options';\n\ntype FilterValue = 'all' | 'read' | 'unread';\n\ntype TimeGroup = 'today' | 'yesterday' | 'past7Days' | 'earlier';\n\nconst TIME_GROUP_ORDER: readonly TimeGroup[] = [\n 'today',\n 'yesterday',\n 'past7Days',\n 'earlier',\n];\n\nconst TIME_GROUP_LABEL: Readonly<Record<TimeGroup, string>> = {\n earlier: '更早',\n past7Days: '過去七天',\n today: '今天',\n yesterday: '昨天',\n};\n\nconst PAGE_SIZE = 50;\n\n/** Identifier for the filter-bar dropdown entry toggling the archived view. */\nconst TOGGLE_ARCHIVED_OPTION_ID = 'toggleArchived';\n\n/**\n * Title shown for a resolved task-assignment notification, replacing the\n * stored \"新的待簽任務\" wording so a decided card no longer reads as pending.\n * The stored `body` is kept as historical context (which case / node).\n */\nconst RESOLVED_TITLE: Readonly<Record<NotificationResolution, string>> = {\n APPROVED: '簽核任務已同意',\n REJECTED: '簽核任務已拒絕',\n RETURNED: '簽核任務已退回',\n SUPERSEDED: '簽核任務已結束',\n TRANSFERRED: '簽核任務已轉派',\n};\n\nfunction resolveDisplayTitle(record: NotificationRecord): string {\n return record.resolution ? RESOLVED_TITLE[record.resolution] : record.title;\n}\n\n/**\n * Severity (icon colour) for a notification. Once resolved, it reflects the\n * outcome — green for approved, red for rejected, neutral otherwise — instead\n * of the original by-type colour.\n */\nfunction resolveSeverity(record: NotificationRecord): NotificationSeverity {\n if (record.resolution === 'APPROVED') return 'success';\n if (record.resolution === 'REJECTED') return 'error';\n if (record.resolution) return 'info';\n return toSeverity(record.type);\n}\n\n/**\n * Right-side notification drawer mounted at the root by `<Providers>`.\n * Opens / closes via `useNotificationDrawer()`, polls\n * `listNotifications()` for the current member, supports filter\n * (`all` / `read` / `unread`), per-row mark-read, per-row archive / unarchive,\n * bulk mark-all-read, and load-more pagination. Archived notifications are\n * hidden until the filter-bar menu turns \"顯示已封存\" on. Clicking a row with an\n * `instanceId` navigates to `/instances/<id>` via the host's router adapter.\n */\nexport function NotificationDrawer(): ReactElement | null {\n const router = useRouterAdapter();\n const routes = useBPMRoutes();\n const { member } = useAuth();\n const { close, isOpen } = useNotificationDrawer();\n const { refreshUnreadCount } = useNotificationUnread();\n const currentMemberId = member?.memberId ?? null;\n const [rows, setRows] = useState<readonly NotificationRecord[]>([]);\n const [totalCount, setTotalCount] = useState(0);\n const [page, setPage] = useState(1);\n const [loading, setLoading] = useState(false);\n const [bulkLoading, setBulkLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [notice, setNotice] = useState<string | null>(null);\n const [filter, setFilter] = useState<FilterValue>('all');\n const [includeArchived, setIncludeArchived] = useState(false);\n const [approveTarget, setApproveTarget] = useState<NotificationRecord | null>(\n null,\n );\n const [approveComment, setApproveComment] = useState('');\n const [rejectTarget, setRejectTarget] = useState<NotificationRecord | null>(\n null,\n );\n const [rejectReason, setRejectReason] = useState('');\n const [deciding, setDeciding] = useState(false);\n\n const trimmedApproveComment = approveComment.trim();\n const trimmedRejectReason = rejectReason.trim();\n\n const loadPage = useCallback(\n async (nextPage: number, append: boolean): Promise<boolean> => {\n if (!currentMemberId) return false;\n setLoading(true);\n setError(null);\n try {\n const result = await listNotifications({\n includeArchived,\n includeRead: true,\n page: nextPage,\n pageSize: PAGE_SIZE,\n recipientMemberId: currentMemberId,\n });\n setRows((current): readonly NotificationRecord[] =>\n append ? [...current, ...result.notifications] : result.notifications,\n );\n setTotalCount(result.totalCount);\n setPage(nextPage);\n await refreshUnreadCount();\n return true;\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n return false;\n } finally {\n setLoading(false);\n }\n },\n [currentMemberId, includeArchived, refreshUnreadCount],\n );\n\n useEffect((): void => {\n if (!isOpen || !currentMemberId) return;\n setError(null);\n setNotice(null);\n void loadPage(1, false);\n }, [isOpen, currentMemberId, loadPage]);\n\n const handleFilterChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>): void => {\n const next = event.target.value;\n if (next === 'all' || next === 'read' || next === 'unread') setFilter(next);\n },\n [],\n );\n\n const handleMarkAllRead = useCallback(async (): Promise<void> => {\n if (!currentMemberId || bulkLoading) return;\n setBulkLoading(true);\n setError(null);\n try {\n await markAllNotificationsRead({ recipientMemberId: currentMemberId });\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setBulkLoading(false);\n }\n }, [bulkLoading, currentMemberId, loadPage]);\n\n const handleLoadMore = useCallback((): void => {\n if (loading) return;\n void loadPage(page + 1, true);\n }, [loading, loadPage, page]);\n\n const handleMarkRead = useCallback(\n async (id: string): Promise<void> => {\n if (!currentMemberId) return;\n try {\n await markNotificationRead({ id, readerMemberId: currentMemberId });\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [currentMemberId, loadPage],\n );\n\n const handleArchive = useCallback(\n async (record: NotificationRecord): Promise<void> => {\n if (!currentMemberId) return;\n setError(null);\n setNotice(null);\n try {\n // Name the notification the way the row does — `title` is the raw\n // stored title, which can differ from the rendered one.\n const label = resolveDisplayTitle(record);\n\n if (record.archivedAt) {\n await unarchiveNotifications({ ids: [record.id] });\n setNotice(`已將「${label}」移出封存。`);\n } else {\n await archiveNotifications({ ids: [record.id] });\n setNotice(`已封存「${label}」。`);\n }\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [currentMemberId, loadPage],\n );\n\n const handleFilterAreaSelect = useCallback((option: DropdownOption): void => {\n if (option.id !== TOGGLE_ARCHIVED_OPTION_ID) return;\n setNotice(null);\n setIncludeArchived((current): boolean => !current);\n }, []);\n\n const handleOpenInstance = useCallback(\n async (record: NotificationRecord): Promise<void> => {\n if (!record.instanceId || !currentMemberId) return;\n try {\n if (record.status !== 'READ') {\n await markNotificationRead({\n id: record.id,\n readerMemberId: currentMemberId,\n });\n await refreshUnreadCount();\n }\n close();\n router.push(routes.caseDetail(record.instanceId));\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n }\n },\n [close, currentMemberId, refreshUnreadCount, router, routes],\n );\n\n const openApproveModal = useCallback((record: NotificationRecord): void => {\n setError(null);\n setApproveTarget(record);\n setApproveComment('');\n }, []);\n\n const closeApproveModal = useCallback((): void => {\n if (deciding) return;\n setApproveTarget(null);\n setApproveComment('');\n }, [deciding]);\n\n const handleApproveConfirm = useCallback(async (): Promise<void> => {\n const target = approveTarget;\n if (!target?.taskId || !currentMemberId || deciding) return;\n setDeciding(true);\n setError(null);\n setNotice(null);\n try {\n await decideTask({\n action: 'APPROVED',\n comment: trimmedApproveComment || null,\n decidedByMemberId: currentMemberId,\n taskId: target.taskId,\n });\n const refreshed = await loadPage(1, false);\n if (!refreshed) return;\n setApproveTarget(null);\n setApproveComment('');\n setNotice(`已同意「${target.title}」。`);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setDeciding(false);\n }\n }, [\n approveTarget,\n currentMemberId,\n deciding,\n loadPage,\n trimmedApproveComment,\n ]);\n\n const openRejectModal = useCallback((record: NotificationRecord): void => {\n setRejectTarget(record);\n setRejectReason('');\n }, []);\n\n const closeRejectModal = useCallback((): void => {\n setRejectTarget(null);\n setRejectReason('');\n }, []);\n\n const handleRejectConfirm = useCallback(async (): Promise<void> => {\n const target = rejectTarget;\n if (!target?.taskId || !currentMemberId || !trimmedRejectReason || deciding)\n return;\n setDeciding(true);\n setError(null);\n setNotice(null);\n try {\n await decideTask({\n action: 'REJECTED',\n comment: trimmedRejectReason,\n decidedByMemberId: currentMemberId,\n taskId: target.taskId,\n });\n setRejectTarget(null);\n setRejectReason('');\n setNotice(`已拒絕「${target.title}」。`);\n await loadPage(1, false);\n } catch (e: unknown) {\n setError(readErrorMessage(e));\n } finally {\n setDeciding(false);\n }\n }, [currentMemberId, deciding, loadPage, rejectTarget, trimmedRejectReason]);\n\n const handleBadgeSelect = useCallback(\n (record: NotificationRecord, option: DropdownOption): void => {\n const action = option.id as NotificationAction;\n if (action === 'approve') openApproveModal(record);\n else if (action === 'reject') openRejectModal(record);\n else if (action === 'view') void handleOpenInstance(record);\n else if (action === 'read') void handleMarkRead(record.id);\n else if (action === 'archive' || action === 'unarchive')\n void handleArchive(record);\n },\n [\n handleArchive,\n handleMarkRead,\n handleOpenInstance,\n openApproveModal,\n openRejectModal,\n ],\n );\n\n /**\n * Whether an event that reached the card wrapper actually happened inside the\n * card, and not on one of its action controls.\n *\n * Two escape hatches are needed. The `...` menu button (and its `<svg>` icon —\n * hence the `Element` check, SVG nodes are not HTMLElements) sits inside the\n * card and must open the dropdown rather than navigate. The dropdown itself\n * renders into a portal, and React replays events along the component tree\n * rather than the DOM tree, so picking \"封存\" also reaches this handler even\n * though the `<li role=\"option\">` lives outside the card's DOM — and it is not\n * a `<button>`, so the first guard alone misses it.\n */\n const isCardActivation = useCallback(\n (target: EventTarget | null, card: HTMLDivElement): boolean => {\n if (!(target instanceof Node) || !card.contains(target)) return false;\n\n return !(target instanceof Element && target.closest('button'));\n },\n [],\n );\n\n const handleCardActivate = useCallback(\n (record: NotificationRecord, event: ReactMouseEvent<HTMLDivElement>): void => {\n if (!isCardActivation(event.target, event.currentTarget)) return;\n void handleOpenInstance(record);\n },\n [handleOpenInstance, isCardActivation],\n );\n\n const handleCardKeyDown = useCallback(\n (\n record: NotificationRecord,\n event: ReactKeyboardEvent<HTMLDivElement>,\n ): void => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (!isCardActivation(event.target, event.currentTarget)) return;\n event.preventDefault();\n void handleOpenInstance(record);\n },\n [handleOpenInstance, isCardActivation],\n );\n\n const filteredRows = useMemo(\n (): readonly NotificationRecord[] =>\n rows.filter((row): boolean => {\n if (filter === 'all') return true;\n if (filter === 'read') return row.status === 'READ';\n return row.status !== 'READ';\n }),\n [filter, rows],\n );\n\n const groupedRows = useMemo(\n (): ReadonlyArray<readonly [TimeGroup, readonly NotificationRecord[]]> => {\n const now = new Date();\n const buckets = TIME_GROUP_ORDER.reduce<\n Record<TimeGroup, NotificationRecord[]>\n >(\n (accumulator, group) => {\n accumulator[group] = [];\n return accumulator;\n },\n { earlier: [], past7Days: [], today: [], yesterday: [] },\n );\n filteredRows.forEach((row): void => {\n buckets[resolveTimeGroup(row.createdAt, now)].push(row);\n });\n return TIME_GROUP_ORDER.map(\n (group) => [group, buckets[group]] as const,\n ).filter(([, items]) => items.length > 0);\n },\n [filteredRows],\n );\n\n const hasMore = rows.length < totalCount;\n\n if (!currentMemberId) return null;\n\n return (\n <>\n <Drawer\n bottomGhostActionDisabled={bulkLoading || loading}\n bottomGhostActionLoading={bulkLoading}\n bottomGhostActionText=\"全部標為已讀\"\n bottomOnGhostActionClick={(): void => {\n void handleMarkAllRead();\n }}\n bottomOnPrimaryActionClick={(): void => {\n handleLoadMore();\n }}\n bottomPrimaryActionDisabled={!hasMore || loading}\n bottomPrimaryActionLoading={loading && hasMore}\n bottomPrimaryActionText={hasMore ? '載入更多' : '已顯示全部'}\n contentKey={`${filter}:${includeArchived}:${rows.length}`}\n filterAreaAllRadioLabel=\"全部\"\n filterAreaOnRadioChange={handleFilterChange}\n filterAreaOnSelect={handleFilterAreaSelect}\n filterAreaOptions={[\n {\n id: TOGGLE_ARCHIVED_OPTION_ID,\n name: includeArchived ? '隱藏已封存' : '顯示已封存',\n },\n ]}\n filterAreaReadRadioLabel=\"已讀\"\n filterAreaShow\n filterAreaUnreadRadioLabel=\"未讀\"\n filterAreaValue={filter}\n headerTitle=\"通知中心\"\n isBottomDisplay\n isHeaderDisplay\n onClose={close}\n open={isOpen}\n size=\"medium\"\n >\n <div role=\"list\">\n {error ? (\n <p\n role=\"alert\"\n style={{\n color: 'var(--mzn-color-text-error, #d92d20)',\n padding: '12px 16px',\n }}\n >\n {error}\n </p>\n ) : null}\n {notice ? (\n <p\n role=\"status\"\n style={{\n color: 'var(--mzn-color-text-success, #079455)',\n padding: '12px 16px',\n }}\n >\n {notice}\n </p>\n ) : null}\n {groupedRows.length === 0 ? (\n <p\n style={{\n color: 'var(--mzn-color-text-secondary, #6b7280)',\n padding: '24px 16px',\n textAlign: 'center',\n }}\n >\n {loading ? '載入中…' : '目前沒有通知'}\n </p>\n ) : null}\n {groupedRows.map(([group, items]) => (\n <Fragment key={group}>\n {items.map((record, itemIndex) => {\n const openable = record.instanceId !== null;\n\n return (\n <div\n key={record.id}\n onClick={\n openable\n ? (event: ReactMouseEvent<HTMLDivElement>): void => {\n handleCardActivate(record, event);\n }\n : undefined\n }\n onKeyDown={\n openable\n ? (event: ReactKeyboardEvent<HTMLDivElement>): void => {\n handleCardKeyDown(record, event);\n }\n : undefined\n }\n role={openable ? 'button' : undefined}\n style={openable ? { cursor: 'pointer' } : undefined}\n tabIndex={openable ? 0 : undefined}\n >\n <NotificationCenter\n appendTips={record.archivedAt ? '已封存' : undefined}\n description={record.body}\n onBadgeSelect={(option: DropdownOption): void => {\n handleBadgeSelect(record, option);\n }}\n options={[...buildNotificationOptions(record)]}\n prependTips={\n itemIndex === 0 ? TIME_GROUP_LABEL[group] : undefined\n }\n reference={record.id}\n severity={resolveSeverity(record)}\n showBadge={record.status !== 'READ'}\n timeStamp={record.createdAt}\n title={resolveDisplayTitle(record)}\n type=\"drawer\"\n />\n </div>\n );\n })}\n </Fragment>\n ))}\n </div>\n </Drawer>\n <Modal\n cancelText=\"取消\"\n confirmText=\"送出同意\"\n loading={deciding}\n modalType=\"standard\"\n onCancel={closeApproveModal}\n onClose={closeApproveModal}\n onConfirm={(): void => {\n void handleApproveConfirm();\n }}\n open={approveTarget !== null}\n showModalFooter\n showModalHeader\n size=\"regular\"\n supportingText=\"可以留下同意說明,內容會記錄在簽核歷程;不填也可以直接送出。\"\n title=\"簽核意見\"\n >\n {error ? (\n <Typography color=\"text-error\" role=\"alert\" variant=\"body\">\n {error}\n </Typography>\n ) : null}\n <BPMFormField label=\"簽核意見\" name=\"notificationApproveComment\">\n <Textarea\n autoFocus\n onChange={(event: ChangeEvent<HTMLTextAreaElement>): void => {\n setApproveComment(event.target.value);\n }}\n placeholder=\"選填,例如補充核准條件或提醒事項\"\n rows={4}\n value={approveComment}\n />\n </BPMFormField>\n </Modal>\n <Modal\n cancelText=\"取消\"\n confirmButtonProps={{\n disabled: !trimmedRejectReason,\n variant: 'destructive-primary',\n }}\n confirmText=\"送出拒絕\"\n loading={deciding}\n modalStatusType=\"error\"\n modalType=\"standard\"\n onCancel={closeRejectModal}\n onClose={closeRejectModal}\n onConfirm={(): void => {\n void handleRejectConfirm();\n }}\n open={rejectTarget !== null}\n showModalFooter\n showModalHeader\n size=\"regular\"\n supportingText=\"拒絕案件時必須留下原因,供發起人與後續追蹤查看。\"\n title=\"拒絕原因\"\n >\n <Textarea\n autoFocus\n onChange={(event: ChangeEvent<HTMLTextAreaElement>): void => {\n setRejectReason(event.target.value);\n }}\n placeholder=\"請輸入拒絕原因\"\n rows={4}\n value={rejectReason}\n />\n </Modal>\n </>\n );\n}\n\nfunction toSeverity(type: NotificationType): NotificationSeverity {\n if (type === 'SLA_OVERDUE') return 'error';\n if (type === 'SLA_WARNING') return 'warning';\n if (type === 'INSTANCE_COMPLETED') return 'success';\n return 'info';\n}\n\nfunction resolveTimeGroup(value: string, now: Date): TimeGroup {\n const notificationDate = new Date(value);\n if (Number.isNaN(notificationDate.getTime())) return 'earlier';\n const nowStartOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n const notificationStartOfDay = new Date(\n notificationDate.getFullYear(),\n notificationDate.getMonth(),\n notificationDate.getDate(),\n );\n if (notificationStartOfDay.getTime() === nowStartOfDay.getTime()) return 'today';\n const yesterdayStartOfDay = new Date(nowStartOfDay);\n yesterdayStartOfDay.setDate(yesterdayStartOfDay.getDate() - 1);\n if (notificationStartOfDay.getTime() === yesterdayStartOfDay.getTime())\n return 'yesterday';\n const diffInDays =\n (now.getTime() - notificationDate.getTime()) / (1000 * 60 * 60 * 24);\n if (diffInDays <= 7) return 'past7Days';\n return 'earlier';\n}\n\nfunction readErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : '發生未知錯誤';\n}\n","'use client';\n\nimport type { ReactElement, ReactNode } from 'react';\nimport {\n CalendarConfigProviderMoment,\n CalendarLocale,\n} from '@mezzanine-ui/react/moment';\nimport { AuthProvider } from './auth-provider';\nimport {\n BPMLanguageProvider,\n DEFAULT_BPM_LANGUAGE,\n type BPMLanguage,\n} from './language-provider';\nimport { BPMOrganizationTimeZoneProvider } from './organization-time-zone-provider';\nimport { NotificationDrawer } from '../components/notification-drawer';\nimport { NotificationDrawerProvider } from './notification-drawer-provider';\nimport { NotificationUnreadProvider } from './notification-unread-provider';\n\ninterface ProvidersProps {\n readonly children: ReactNode;\n /** Override Mezzanine calendar locale. Defaults to `CalendarLocale.ZH_TW`. */\n readonly locale?: CalendarLocale;\n /**\n * Language BPM views write their messages in, such as publish-lint errors.\n * Defaults to `'zh-TW'`. Pass the user's choice as state to let them switch.\n * Independent of `locale`, which only formats calendar dates.\n */\n readonly language?: BPMLanguage;\n /**\n * IANA zone in which BPM views read \"today\" against organization effective\n * dates. Pass the same value given to `BPMRootModule` as\n * `organizationTimeZone`; leave it unset when the API does not set one.\n * Defaults to `DEFAULT_BPM_ORGANIZATION_TIME_ZONE` (`'Asia/Taipei'`); an\n * unknown zone falls back to it with a console warning.\n */\n readonly organizationTimeZone?: string;\n /**\n * Public paths that should not trigger redirect to `/login` when there\n * is no session. Forwarded to `<AuthProvider>`. Defaults to `['/login']`.\n */\n readonly publicPaths?: readonly string[];\n /** Where to send unauthenticated users. Defaults to `'/login'`. */\n readonly loginPath?: string;\n}\n\n/**\n * One-stop BPM admin provider stack. Wires:\n *\n * - Mezzanine UI calendar locale (moment-based, `ZH_TW` by default)\n * - `<BPMLanguageProvider>` (message language, `'zh-TW'` by default)\n * - `<BPMOrganizationTimeZoneProvider>` (organization \"today\" zone)\n * - `<AuthProvider>` (BPM session via REST `/auth/*`)\n * - `<NotificationUnreadProvider>` (polls unread count)\n * - `<NotificationDrawerProvider>` (controls drawer open/close state)\n * - `<NotificationDrawer />` mounted at the root so the host navigation\n * bell (`<BPMNotificationBellButton />` or any custom trigger calling\n * `useNotificationDrawer().open`) can open it.\n *\n * Consumer hosts wrap this **inside** a `<RouterAdapterProvider>` (provided\n * by the `pages/*` subpath shims when consuming via Next.js, or wired by\n * hand for other frameworks).\n */\nexport function Providers({\n children,\n locale = CalendarLocale.ZH_TW,\n language = DEFAULT_BPM_LANGUAGE,\n organizationTimeZone,\n publicPaths,\n loginPath,\n}: ProvidersProps): ReactElement {\n return (\n <CalendarConfigProviderMoment locale={locale}>\n <BPMLanguageProvider language={language}>\n <BPMOrganizationTimeZoneProvider timeZone={organizationTimeZone}>\n <AuthProvider publicPaths={publicPaths} loginPath={loginPath}>\n <NotificationUnreadProvider>\n <NotificationDrawerProvider>\n {children}\n <NotificationDrawer />\n </NotificationDrawerProvider>\n </NotificationUnreadProvider>\n </AuthProvider>\n </BPMOrganizationTimeZoneProvider>\n </BPMLanguageProvider>\n </CalendarConfigProviderMoment>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAMc,IACJC,EAAqD,IAAI;AAgB3D,SAAgBC,EAA2B,EACzC,eACgD;CAChD,IAAM,CAACC,GAAQC,KAAaC,EAAS,EAAK,GAEpCC,IAAOC,QAAwB;EACnC,EAAU,EAAI;CAChB,GAAG,CAAC,CAAC,GACCC,IAAQD,QAAwB;EACpC,EAAU,EAAK;CACjB,GAAG,CAAC,CAAC,GACCE,IAASF,QAAwB;EACrC,GAAW,MAAY,CAACG,CAAO;CACjC,GAAG,CAAC,CAAC,GAECC,IAAQC,SACL;EAAE;EAAO;EAAQ;EAAM;CAAO,IACrC;EAACJ;EAAOL;EAAQG;EAAMG;CAAM,CAC9B;CAEA,OACE,kBAACT,EAA0B,UAA3B;EAA2C;EACxC;CACiC,CAAA;AAExC;AAMA,SAAgBa,IAAwD;CAUtE,OATgBC,EAAWd,CACtB,KACI;EACL,aAAmB,KAAA;EACnB,QAAQ;EACR,YAAkB,KAAA;EAClB,cAAoB,KAAA;CACtB;AAGJ;;AC1DA,IAAMe,IACJd,EAAqD,IAAI;AAe3D,SAAgBe,EAA2B,EACzC,eACgD;CAChD,IAAM,EAAE,cAAW3B,EAAQ,GACrB4B,IAAkBC,GAAQ,YAAY,MACtC,CAACC,GAAaC,KAAkBf,EAAS,CAAC,GAE1CgB,IAAqBd,EAAY,YAA6B;EAClE,IAAI,CAACU,GAEH,OADAG,EAAe,CAAC,GACT;EAET,IAAME,IAAO,MAAMC,EAA4BN,CAAe;EAE9D,OADAG,EAAeE,CAAI,GACZA;CACT,GAAG,CAACL,CAAe,CAAC;CAEpB,QAA8B;EAC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C,UAAA,kBAACC,GAAD;KAA2B;KAAwB;KACjD,UAAA,kBAACvH,GAAD,EAAA,UACE,kBAACd,GAAD,EAAA,UAAA,CACGsI,GACD,kBAAC5F,GAAD,CAAqB,CAAA,CACK,EAAA,CAAA,EACF,CAAA;IAChB,CAAA;GACiB,CAAA;EACd,CAAA;CACO,CAAA;AAElC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./auth-provider-4BeCw7cI.cjs"),n=require("./organization-time-zone-provider-B7CXQril.cjs"),r=require("./router-adapter--gYs13E8.cjs"),i=require("./routes-config-C1j_vFKo.cjs"),a=require("./bpm-form-field-Bc6k4ZEO.cjs");let o=require("react"),s=require("@mezzanine-ui/react"),c=require("react/jsx-runtime"),l=require("@rytass/bpm-core-client/workflow"),u=require("@mezzanine-ui/react/moment"),d=require("@mezzanine-ui/react/Drawer");d=e.t(d,1);let f=require("@mezzanine-ui/react/Modal");f=e.t(f,1);let p=require("@mezzanine-ui/react/NotificationCenter");p=e.t(p,1);let m=require("@mezzanine-ui/react/Textarea");m=e.t(m,1);var h=(0,o.createContext)(null);function g({children:e}){let[t,n]=(0,o.useState)(!1),r=(0,o.useCallback)(()=>{n(!0)},[]),i=(0,o.useCallback)(()=>{n(!1)},[]),a=(0,o.useCallback)(()=>{n(e=>!e)},[]),s=(0,o.useMemo)(()=>({close:i,isOpen:t,open:r,toggle:a}),[i,t,r,a]);return(0,c.jsx)(h.Provider,{value:s,children:e})}function _(){return(0,o.useContext)(h)||{close:()=>void 0,isOpen:!1,open:()=>void 0,toggle:()=>void 0}}var v=(0,o.createContext)(null);function y({children:e}){let{member:n}=t.n(),r=n?.memberId??null,[i,a]=(0,o.useState)(0),s=(0,o.useCallback)(async()=>{if(!r)return a(0),0;let e=await(0,l.readUnreadNotificationCount)(r);return a(e),e},[r]);(0,o.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await s();e&&a(t)}catch{e&&a(0)}})(),()=>{e=!1}},[s]);let u=(0,o.useMemo)(()=>({refreshUnreadCount:s,unreadCount:i}),[s,i]);return(0,c.jsx)(v.Provider,{value:u,children:e})}function ee(){return(0,o.useContext)(v)||{refreshUnreadCount:async()=>0,unreadCount:0}}function te(e){let t=b(e),n=ne(e,t)!==!1,r=e.actionable&&!!e.instanceId&&(x(t,`hasFillableFields`)||x(t,`requireApprovalComment`));return[...e.actionable?[r?{id:`view`,name:`開啟案件`}:{id:`approve`,name:`同意`},...n?[{id:`reject`,name:`拒絕`}]:[]]:[],...e.instanceId&&!r?[{id:`view`,name:`查看案件`}]:[],...e.status===`READ`?[]:[{id:`read`,name:`標為已讀`}],e.archivedAt?{id:`unarchive`,name:`取消封存`}:{id:`archive`,name:`封存`}]}function b(e){try{let t=JSON.parse(e.payloadJson);return S(t)?t:null}catch{return null}}function ne(e,t){return t&&typeof t.allowReject==`boolean`?t.allowReject:e.allowReject}function x(e,t){return e!==null&&e[t]===!0}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var re=[`today`,`yesterday`,`past7Days`,`earlier`],ie={earlier:`更早`,past7Days:`過去七天`,today:`今天`,yesterday:`昨天`},ae=50,oe=`toggleArchived`,C={APPROVED:`簽核任務已同意`,REJECTED:`簽核任務已拒絕`,RETURNED:`簽核任務已退回`,SUPERSEDED:`簽核任務已結束`,TRANSFERRED:`簽核任務已轉派`};function w(e){return e.resolution?C[e.resolution]:e.title}function se(e){return e.resolution===`APPROVED`?`success`:e.resolution===`REJECTED`?`error`:e.resolution?`info`:E(e.type)}function T(){let e=r.r(),n=i.r(),{member:u}=t.n(),{close:h,isOpen:g}=_(),{refreshUnreadCount:v}=ee(),y=u?.memberId??null,[b,ne]=(0,o.useState)([]),[x,S]=(0,o.useState)(0),[C,T]=(0,o.useState)(1),[E,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)(!1),[j,M]=(0,o.useState)(null),[N,P]=(0,o.useState)(null),[F,le]=(0,o.useState)(`all`),[I,ue]=(0,o.useState)(!1),[L,R]=(0,o.useState)(null),[z,B]=(0,o.useState)(``),[V,H]=(0,o.useState)(null),[U,W]=(0,o.useState)(``),[G,K]=(0,o.useState)(!1),q=z.trim(),J=U.trim(),Y=(0,o.useCallback)(async(e,t)=>{if(!y)return!1;O(!0),M(null);try{let n=await(0,l.listNotifications)({includeArchived:I,includeRead:!0,page:e,pageSize:ae,recipientMemberId:y});return ne(e=>t?[...e,...n.notifications]:n.notifications),S(n.totalCount),T(e),await v(),!0}catch(e){return M(D(e)),!1}finally{O(!1)}},[y,I,v]);(0,o.useEffect)(()=>{g&&y&&(M(null),P(null),Y(1,!1))},[g,y,Y]);let de=(0,o.useCallback)(e=>{let t=e.target.value;(t===`all`||t===`read`||t===`unread`)&&le(t)},[]),fe=(0,o.useCallback)(async()=>{if(y&&!k){A(!0),M(null);try{await(0,l.markAllNotificationsRead)({recipientMemberId:y}),await Y(1,!1)}catch(e){M(D(e))}finally{A(!1)}}},[k,y,Y]),pe=(0,o.useCallback)(()=>{E||Y(C+1,!0)},[E,Y,C]),me=(0,o.useCallback)(async e=>{if(y)try{await(0,l.markNotificationRead)({id:e,readerMemberId:y}),await Y(1,!1)}catch(e){M(D(e))}},[y,Y]),he=(0,o.useCallback)(async e=>{if(y){M(null),P(null);try{let t=w(e);e.archivedAt?(await(0,l.unarchiveNotifications)({ids:[e.id]}),P(`已將「${t}」移出封存。`)):(await(0,l.archiveNotifications)({ids:[e.id]}),P(`已封存「${t}」。`)),await Y(1,!1)}catch(e){M(D(e))}}},[y,Y]),ge=(0,o.useCallback)(e=>{e.id===oe&&(P(null),ue(e=>!e))},[]),X=(0,o.useCallback)(async t=>{if(t.instanceId&&y)try{t.status!==`READ`&&(await(0,l.markNotificationRead)({id:t.id,readerMemberId:y}),await v()),h(),e.push(n.caseDetail(t.instanceId))}catch(e){M(D(e))}},[h,y,v,e,n]),_e=(0,o.useCallback)(e=>{M(null),R(e),B(``)},[]),ve=(0,o.useCallback)(()=>{G||(R(null),B(``))},[G]),ye=(0,o.useCallback)(async()=>{let e=L;if(e?.taskId&&y&&!G){K(!0),M(null),P(null);try{if(await(0,l.decideTask)({action:`APPROVED`,comment:q||null,decidedByMemberId:y,taskId:e.taskId}),!await Y(1,!1))return;R(null),B(``),P(`已同意「${e.title}」。`)}catch(e){M(D(e))}finally{K(!1)}}},[L,y,G,Y,q]),be=(0,o.useCallback)(e=>{H(e),W(``)},[]),xe=(0,o.useCallback)(()=>{H(null),W(``)},[]),Se=(0,o.useCallback)(async()=>{let e=V;if(e?.taskId&&y&&J&&!G){K(!0),M(null),P(null);try{await(0,l.decideTask)({action:`REJECTED`,comment:J,decidedByMemberId:y,taskId:e.taskId}),H(null),W(``),P(`已拒絕「${e.title}」。`),await Y(1,!1)}catch(e){M(D(e))}finally{K(!1)}}},[y,G,Y,V,J]),Ce=(0,o.useCallback)((e,t)=>{let n=t.id;n===`approve`?_e(e):n===`reject`?be(e):n===`view`?X(e):n===`read`?me(e.id):(n===`archive`||n===`unarchive`)&&he(e)},[he,me,X,_e,be]),Z=(0,o.useCallback)((e,t)=>!(e instanceof Node)||!t.contains(e)?!1:!(e instanceof Element&&e.closest(`button`)),[]),we=(0,o.useCallback)((e,t)=>{Z(t.target,t.currentTarget)&&X(e)},[X,Z]),Te=(0,o.useCallback)((e,t)=>{(t.key===`Enter`||t.key===` `)&&Z(t.target,t.currentTarget)&&(t.preventDefault(),X(e))},[X,Z]),Ee=(0,o.useMemo)(()=>b.filter(e=>F===`all`?!0:F===`read`?e.status===`READ`:e.status!==`READ`),[F,b]),Q=(0,o.useMemo)(()=>{let e=new Date,t=re.reduce((e,t)=>(e[t]=[],e),{earlier:[],past7Days:[],today:[],yesterday:[]});return Ee.forEach(n=>{t[ce(n.createdAt,e)].push(n)}),re.map(e=>[e,t[e]]).filter(([,e])=>e.length>0)},[Ee]),$=b.length<x;return y?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(d.default,{bottomGhostActionDisabled:k||E,bottomGhostActionLoading:k,bottomGhostActionText:`全部標為已讀`,bottomOnGhostActionClick:()=>{fe()},bottomOnPrimaryActionClick:()=>{pe()},bottomPrimaryActionDisabled:!$||E,bottomPrimaryActionLoading:E&&$,bottomPrimaryActionText:$?`載入更多`:`已顯示全部`,contentKey:`${F}:${I}:${b.length}`,filterAreaAllRadioLabel:`全部`,filterAreaOnRadioChange:de,filterAreaOnSelect:ge,filterAreaOptions:[{id:oe,name:I?`隱藏已封存`:`顯示已封存`}],filterAreaReadRadioLabel:`已讀`,filterAreaShow:!0,filterAreaUnreadRadioLabel:`未讀`,filterAreaValue:F,headerTitle:`通知中心`,isBottomDisplay:!0,isHeaderDisplay:!0,onClose:h,open:g,size:`medium`,children:(0,c.jsxs)(`div`,{role:`list`,children:[j?(0,c.jsx)(`p`,{role:`alert`,style:{color:`var(--mzn-color-text-error, #d92d20)`,padding:`12px 16px`},children:j}):null,N?(0,c.jsx)(`p`,{role:`status`,style:{color:`var(--mzn-color-text-success, #079455)`,padding:`12px 16px`},children:N}):null,Q.length===0?(0,c.jsx)(`p`,{style:{color:`var(--mzn-color-text-secondary, #6b7280)`,padding:`24px 16px`,textAlign:`center`},children:E?`載入中…`:`目前沒有通知`}):null,Q.map(([e,t])=>(0,c.jsx)(o.Fragment,{children:t.map((t,n)=>{let r=t.instanceId!==null;return(0,c.jsx)(`div`,{onClick:r?e=>{we(t,e)}:void 0,onKeyDown:r?e=>{Te(t,e)}:void 0,role:r?`button`:void 0,style:r?{cursor:`pointer`}:void 0,tabIndex:r?0:void 0,children:(0,c.jsx)(p.default,{appendTips:t.archivedAt?`已封存`:void 0,description:t.body,onBadgeSelect:e=>{Ce(t,e)},options:[...te(t)],prependTips:n===0?ie[e]:void 0,reference:t.id,severity:se(t),showBadge:t.status!==`READ`,timeStamp:t.createdAt,title:w(t),type:`drawer`})},t.id)})},e))]})}),(0,c.jsxs)(f.default,{cancelText:`取消`,confirmText:`送出同意`,loading:G,modalType:`standard`,onCancel:ve,onClose:ve,onConfirm:()=>{ye()},open:L!==null,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`可以留下同意說明,內容會記錄在簽核歷程;不填也可以直接送出。`,title:`簽核意見`,children:[j?(0,c.jsx)(s.Typography,{color:`text-error`,role:`alert`,variant:`body`,children:j}):null,(0,c.jsx)(a.t,{label:`簽核意見`,name:`notificationApproveComment`,children:(0,c.jsx)(m.default,{autoFocus:!0,onChange:e=>{B(e.target.value)},placeholder:`選填,例如補充核准條件或提醒事項`,rows:4,value:z})})]}),(0,c.jsx)(f.default,{cancelText:`取消`,confirmButtonProps:{disabled:!J,variant:`destructive-primary`},confirmText:`送出拒絕`,loading:G,modalStatusType:`error`,modalType:`standard`,onCancel:xe,onClose:xe,onConfirm:()=>{Se()},open:V!==null,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`拒絕案件時必須留下原因,供發起人與後續追蹤查看。`,title:`拒絕原因`,children:(0,c.jsx)(m.default,{autoFocus:!0,onChange:e=>{W(e.target.value)},placeholder:`請輸入拒絕原因`,rows:4,value:U})})]}):null}function E(e){return e===`SLA_OVERDUE`?`error`:e===`SLA_WARNING`?`warning`:e===`INSTANCE_COMPLETED`?`success`:`info`}function ce(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return`earlier`;let r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i.getTime()===r.getTime())return`today`;let a=new Date(r);return a.setDate(a.getDate()-1),i.getTime()===a.getTime()?`yesterday`:(t.getTime()-n.getTime())/864e5<=7?`past7Days`:`earlier`}function D(e){return e instanceof Error?e.message:`發生未知錯誤`}function O({children:e,locale:r=u.CalendarLocale.ZH_TW,language:i=n.a,organizationTimeZone:a,publicPaths:o,loginPath:s}){return(0,c.jsx)(u.CalendarConfigProviderMoment,{locale:r,children:(0,c.jsx)(n.r,{language:i,children:(0,c.jsx)(n.t,{timeZone:a,children:(0,c.jsx)(t.t,{publicPaths:o,loginPath:s,children:(0,c.jsx)(y,{children:(0,c.jsxs)(g,{children:[e,(0,c.jsx)(T,{})]})})})})})})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return O}});
|
|
2
|
-
//# sourceMappingURL=providers-
|
|
1
|
+
"use client";const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./auth-provider-4BeCw7cI.cjs"),n=require("./organization-time-zone-provider-B7CXQril.cjs"),r=require("./router-adapter--gYs13E8.cjs"),i=require("./routes-config-BWjZDAU3.cjs"),a=require("./bpm-form-field-Bc6k4ZEO.cjs");let o=require("react"),s=require("@mezzanine-ui/react"),c=require("react/jsx-runtime"),l=require("@rytass/bpm-core-client/workflow"),u=require("@mezzanine-ui/react/moment"),d=require("@mezzanine-ui/react/Drawer");d=e.t(d,1);let f=require("@mezzanine-ui/react/Modal");f=e.t(f,1);let p=require("@mezzanine-ui/react/NotificationCenter");p=e.t(p,1);let m=require("@mezzanine-ui/react/Textarea");m=e.t(m,1);var h=(0,o.createContext)(null);function g({children:e}){let[t,n]=(0,o.useState)(!1),r=(0,o.useCallback)(()=>{n(!0)},[]),i=(0,o.useCallback)(()=>{n(!1)},[]),a=(0,o.useCallback)(()=>{n(e=>!e)},[]),s=(0,o.useMemo)(()=>({close:i,isOpen:t,open:r,toggle:a}),[i,t,r,a]);return(0,c.jsx)(h.Provider,{value:s,children:e})}function _(){return(0,o.useContext)(h)||{close:()=>void 0,isOpen:!1,open:()=>void 0,toggle:()=>void 0}}var v=(0,o.createContext)(null);function y({children:e}){let{member:n}=t.n(),r=n?.memberId??null,[i,a]=(0,o.useState)(0),s=(0,o.useCallback)(async()=>{if(!r)return a(0),0;let e=await(0,l.readUnreadNotificationCount)(r);return a(e),e},[r]);(0,o.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await s();e&&a(t)}catch{e&&a(0)}})(),()=>{e=!1}},[s]);let u=(0,o.useMemo)(()=>({refreshUnreadCount:s,unreadCount:i}),[s,i]);return(0,c.jsx)(v.Provider,{value:u,children:e})}function ee(){return(0,o.useContext)(v)||{refreshUnreadCount:async()=>0,unreadCount:0}}function te(e){let t=b(e),n=ne(e,t)!==!1,r=e.actionable&&!!e.instanceId&&(x(t,`hasFillableFields`)||x(t,`requireApprovalComment`));return[...e.actionable?[r?{id:`view`,name:`開啟案件`}:{id:`approve`,name:`同意`},...n?[{id:`reject`,name:`拒絕`}]:[]]:[],...e.instanceId&&!r?[{id:`view`,name:`查看案件`}]:[],...e.status===`READ`?[]:[{id:`read`,name:`標為已讀`}],e.archivedAt?{id:`unarchive`,name:`取消封存`}:{id:`archive`,name:`封存`}]}function b(e){try{let t=JSON.parse(e.payloadJson);return S(t)?t:null}catch{return null}}function ne(e,t){return t&&typeof t.allowReject==`boolean`?t.allowReject:e.allowReject}function x(e,t){return e!==null&&e[t]===!0}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var re=[`today`,`yesterday`,`past7Days`,`earlier`],ie={earlier:`更早`,past7Days:`過去七天`,today:`今天`,yesterday:`昨天`},ae=50,oe=`toggleArchived`,C={APPROVED:`簽核任務已同意`,REJECTED:`簽核任務已拒絕`,RETURNED:`簽核任務已退回`,SUPERSEDED:`簽核任務已結束`,TRANSFERRED:`簽核任務已轉派`};function w(e){return e.resolution?C[e.resolution]:e.title}function se(e){return e.resolution===`APPROVED`?`success`:e.resolution===`REJECTED`?`error`:e.resolution?`info`:E(e.type)}function T(){let e=r.r(),n=i.r(),{member:u}=t.n(),{close:h,isOpen:g}=_(),{refreshUnreadCount:v}=ee(),y=u?.memberId??null,[b,ne]=(0,o.useState)([]),[x,S]=(0,o.useState)(0),[C,T]=(0,o.useState)(1),[E,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)(!1),[j,M]=(0,o.useState)(null),[N,P]=(0,o.useState)(null),[F,le]=(0,o.useState)(`all`),[I,ue]=(0,o.useState)(!1),[L,R]=(0,o.useState)(null),[z,B]=(0,o.useState)(``),[V,H]=(0,o.useState)(null),[U,W]=(0,o.useState)(``),[G,K]=(0,o.useState)(!1),q=z.trim(),J=U.trim(),Y=(0,o.useCallback)(async(e,t)=>{if(!y)return!1;O(!0),M(null);try{let n=await(0,l.listNotifications)({includeArchived:I,includeRead:!0,page:e,pageSize:ae,recipientMemberId:y});return ne(e=>t?[...e,...n.notifications]:n.notifications),S(n.totalCount),T(e),await v(),!0}catch(e){return M(D(e)),!1}finally{O(!1)}},[y,I,v]);(0,o.useEffect)(()=>{g&&y&&(M(null),P(null),Y(1,!1))},[g,y,Y]);let de=(0,o.useCallback)(e=>{let t=e.target.value;(t===`all`||t===`read`||t===`unread`)&&le(t)},[]),fe=(0,o.useCallback)(async()=>{if(y&&!k){A(!0),M(null);try{await(0,l.markAllNotificationsRead)({recipientMemberId:y}),await Y(1,!1)}catch(e){M(D(e))}finally{A(!1)}}},[k,y,Y]),pe=(0,o.useCallback)(()=>{E||Y(C+1,!0)},[E,Y,C]),me=(0,o.useCallback)(async e=>{if(y)try{await(0,l.markNotificationRead)({id:e,readerMemberId:y}),await Y(1,!1)}catch(e){M(D(e))}},[y,Y]),he=(0,o.useCallback)(async e=>{if(y){M(null),P(null);try{let t=w(e);e.archivedAt?(await(0,l.unarchiveNotifications)({ids:[e.id]}),P(`已將「${t}」移出封存。`)):(await(0,l.archiveNotifications)({ids:[e.id]}),P(`已封存「${t}」。`)),await Y(1,!1)}catch(e){M(D(e))}}},[y,Y]),ge=(0,o.useCallback)(e=>{e.id===oe&&(P(null),ue(e=>!e))},[]),X=(0,o.useCallback)(async t=>{if(t.instanceId&&y)try{t.status!==`READ`&&(await(0,l.markNotificationRead)({id:t.id,readerMemberId:y}),await v()),h(),e.push(n.caseDetail(t.instanceId))}catch(e){M(D(e))}},[h,y,v,e,n]),_e=(0,o.useCallback)(e=>{M(null),R(e),B(``)},[]),ve=(0,o.useCallback)(()=>{G||(R(null),B(``))},[G]),ye=(0,o.useCallback)(async()=>{let e=L;if(e?.taskId&&y&&!G){K(!0),M(null),P(null);try{if(await(0,l.decideTask)({action:`APPROVED`,comment:q||null,decidedByMemberId:y,taskId:e.taskId}),!await Y(1,!1))return;R(null),B(``),P(`已同意「${e.title}」。`)}catch(e){M(D(e))}finally{K(!1)}}},[L,y,G,Y,q]),be=(0,o.useCallback)(e=>{H(e),W(``)},[]),xe=(0,o.useCallback)(()=>{H(null),W(``)},[]),Se=(0,o.useCallback)(async()=>{let e=V;if(e?.taskId&&y&&J&&!G){K(!0),M(null),P(null);try{await(0,l.decideTask)({action:`REJECTED`,comment:J,decidedByMemberId:y,taskId:e.taskId}),H(null),W(``),P(`已拒絕「${e.title}」。`),await Y(1,!1)}catch(e){M(D(e))}finally{K(!1)}}},[y,G,Y,V,J]),Ce=(0,o.useCallback)((e,t)=>{let n=t.id;n===`approve`?_e(e):n===`reject`?be(e):n===`view`?X(e):n===`read`?me(e.id):(n===`archive`||n===`unarchive`)&&he(e)},[he,me,X,_e,be]),Z=(0,o.useCallback)((e,t)=>!(e instanceof Node)||!t.contains(e)?!1:!(e instanceof Element&&e.closest(`button`)),[]),we=(0,o.useCallback)((e,t)=>{Z(t.target,t.currentTarget)&&X(e)},[X,Z]),Te=(0,o.useCallback)((e,t)=>{(t.key===`Enter`||t.key===` `)&&Z(t.target,t.currentTarget)&&(t.preventDefault(),X(e))},[X,Z]),Ee=(0,o.useMemo)(()=>b.filter(e=>F===`all`?!0:F===`read`?e.status===`READ`:e.status!==`READ`),[F,b]),Q=(0,o.useMemo)(()=>{let e=new Date,t=re.reduce((e,t)=>(e[t]=[],e),{earlier:[],past7Days:[],today:[],yesterday:[]});return Ee.forEach(n=>{t[ce(n.createdAt,e)].push(n)}),re.map(e=>[e,t[e]]).filter(([,e])=>e.length>0)},[Ee]),$=b.length<x;return y?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(d.default,{bottomGhostActionDisabled:k||E,bottomGhostActionLoading:k,bottomGhostActionText:`全部標為已讀`,bottomOnGhostActionClick:()=>{fe()},bottomOnPrimaryActionClick:()=>{pe()},bottomPrimaryActionDisabled:!$||E,bottomPrimaryActionLoading:E&&$,bottomPrimaryActionText:$?`載入更多`:`已顯示全部`,contentKey:`${F}:${I}:${b.length}`,filterAreaAllRadioLabel:`全部`,filterAreaOnRadioChange:de,filterAreaOnSelect:ge,filterAreaOptions:[{id:oe,name:I?`隱藏已封存`:`顯示已封存`}],filterAreaReadRadioLabel:`已讀`,filterAreaShow:!0,filterAreaUnreadRadioLabel:`未讀`,filterAreaValue:F,headerTitle:`通知中心`,isBottomDisplay:!0,isHeaderDisplay:!0,onClose:h,open:g,size:`medium`,children:(0,c.jsxs)(`div`,{role:`list`,children:[j?(0,c.jsx)(`p`,{role:`alert`,style:{color:`var(--mzn-color-text-error, #d92d20)`,padding:`12px 16px`},children:j}):null,N?(0,c.jsx)(`p`,{role:`status`,style:{color:`var(--mzn-color-text-success, #079455)`,padding:`12px 16px`},children:N}):null,Q.length===0?(0,c.jsx)(`p`,{style:{color:`var(--mzn-color-text-secondary, #6b7280)`,padding:`24px 16px`,textAlign:`center`},children:E?`載入中…`:`目前沒有通知`}):null,Q.map(([e,t])=>(0,c.jsx)(o.Fragment,{children:t.map((t,n)=>{let r=t.instanceId!==null;return(0,c.jsx)(`div`,{onClick:r?e=>{we(t,e)}:void 0,onKeyDown:r?e=>{Te(t,e)}:void 0,role:r?`button`:void 0,style:r?{cursor:`pointer`}:void 0,tabIndex:r?0:void 0,children:(0,c.jsx)(p.default,{appendTips:t.archivedAt?`已封存`:void 0,description:t.body,onBadgeSelect:e=>{Ce(t,e)},options:[...te(t)],prependTips:n===0?ie[e]:void 0,reference:t.id,severity:se(t),showBadge:t.status!==`READ`,timeStamp:t.createdAt,title:w(t),type:`drawer`})},t.id)})},e))]})}),(0,c.jsxs)(f.default,{cancelText:`取消`,confirmText:`送出同意`,loading:G,modalType:`standard`,onCancel:ve,onClose:ve,onConfirm:()=>{ye()},open:L!==null,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`可以留下同意說明,內容會記錄在簽核歷程;不填也可以直接送出。`,title:`簽核意見`,children:[j?(0,c.jsx)(s.Typography,{color:`text-error`,role:`alert`,variant:`body`,children:j}):null,(0,c.jsx)(a.t,{label:`簽核意見`,name:`notificationApproveComment`,children:(0,c.jsx)(m.default,{autoFocus:!0,onChange:e=>{B(e.target.value)},placeholder:`選填,例如補充核准條件或提醒事項`,rows:4,value:z})})]}),(0,c.jsx)(f.default,{cancelText:`取消`,confirmButtonProps:{disabled:!J,variant:`destructive-primary`},confirmText:`送出拒絕`,loading:G,modalStatusType:`error`,modalType:`standard`,onCancel:xe,onClose:xe,onConfirm:()=>{Se()},open:V!==null,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`拒絕案件時必須留下原因,供發起人與後續追蹤查看。`,title:`拒絕原因`,children:(0,c.jsx)(m.default,{autoFocus:!0,onChange:e=>{W(e.target.value)},placeholder:`請輸入拒絕原因`,rows:4,value:U})})]}):null}function E(e){return e===`SLA_OVERDUE`?`error`:e===`SLA_WARNING`?`warning`:e===`INSTANCE_COMPLETED`?`success`:`info`}function ce(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return`earlier`;let r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(i.getTime()===r.getTime())return`today`;let a=new Date(r);return a.setDate(a.getDate()-1),i.getTime()===a.getTime()?`yesterday`:(t.getTime()-n.getTime())/864e5<=7?`past7Days`:`earlier`}function D(e){return e instanceof Error?e.message:`發生未知錯誤`}function O({children:e,locale:r=u.CalendarLocale.ZH_TW,language:i=n.a,organizationTimeZone:a,publicPaths:o,loginPath:s}){return(0,c.jsx)(u.CalendarConfigProviderMoment,{locale:r,children:(0,c.jsx)(n.r,{language:i,children:(0,c.jsx)(n.t,{timeZone:a,children:(0,c.jsx)(t.t,{publicPaths:o,loginPath:s,children:(0,c.jsx)(y,{children:(0,c.jsxs)(g,{children:[e,(0,c.jsx)(T,{})]})})})})})})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return O}});
|
|
2
|
+
//# sourceMappingURL=providers-Dz4Wqxr6.cjs.map
|