@vicacha-devs/strapi-plugin-inbox 0.0.0-stage → 1.0.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.
Files changed (90) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +17 -2
  3. package/dist/admin/InboxHomePage-B5xUPD7Y.mjs +2153 -0
  4. package/dist/admin/InboxHomePage-BCHbPE2t.js +2171 -0
  5. package/dist/admin/LocalizationRoutingTab-CEXbHNe4.mjs +282 -0
  6. package/dist/admin/LocalizationRoutingTab-Dt6U-kXn.js +281 -0
  7. package/dist/admin/SettingsPage-Dif7Cq7I.mjs +819 -0
  8. package/dist/admin/SettingsPage-qB_efKCl.js +837 -0
  9. package/dist/admin/ar-CbjX4o07.mjs +268 -0
  10. package/dist/admin/ar-KedDMvsH.js +268 -0
  11. package/dist/admin/de-BrJIGJEV.mjs +268 -0
  12. package/dist/admin/de-rj5pqQ0S.js +268 -0
  13. package/dist/admin/en-BE8TARw0.mjs +268 -0
  14. package/dist/admin/en-CuTmgXZL.js +268 -0
  15. package/dist/admin/es-Berf1dRb.js +268 -0
  16. package/dist/admin/es-Ce4nMwC7.mjs +268 -0
  17. package/dist/admin/fr-CfdjWCiu.js +268 -0
  18. package/dist/admin/fr-Y3GKi6mQ.mjs +268 -0
  19. package/dist/admin/index-5e9dAMBs.mjs +822 -0
  20. package/dist/admin/index-DLfoIVZP.js +839 -0
  21. package/dist/admin/index.js +5 -0
  22. package/dist/admin/index.mjs +5 -0
  23. package/dist/admin/it-DXXnvX5J.mjs +268 -0
  24. package/dist/admin/it-DkJ3WwLA.js +268 -0
  25. package/dist/admin/pt-D7WKv-MR.js +268 -0
  26. package/dist/admin/pt-QDCJ6lOH.mjs +268 -0
  27. package/dist/admin/ru-DgYTw9aE.js +268 -0
  28. package/dist/admin/ru-DzP0H4fh.mjs +268 -0
  29. package/dist/admin/src/components/Initializer.d.ts +6 -0
  30. package/dist/admin/src/components/PluginIcon.d.ts +3 -0
  31. package/dist/admin/src/components/inbox/AlertBannersTab.d.ts +10 -0
  32. package/dist/admin/src/components/inbox/CaseworkDetailPanel.d.ts +15 -0
  33. package/dist/admin/src/components/inbox/CaseworkPayloadChecklistColumn.d.ts +12 -0
  34. package/dist/admin/src/components/inbox/CaseworkSubmissionsTab.d.ts +12 -0
  35. package/dist/admin/src/components/inbox/FormBuilderTab.d.ts +17 -0
  36. package/dist/admin/src/components/inbox/FormChecklistAndLocalePanels.d.ts +17 -0
  37. package/dist/admin/src/components/inbox/FormRoutingDrawer.d.ts +15 -0
  38. package/dist/admin/src/components/inbox/SubscribersTab.d.ts +10 -0
  39. package/dist/admin/src/components/settings/AntiSpamCaptchaTab.d.ts +9 -0
  40. package/dist/admin/src/components/settings/BridgesNotificationsTab.d.ts +8 -0
  41. package/dist/admin/src/components/settings/CaptchaProviderCard.d.ts +21 -0
  42. package/dist/admin/src/components/settings/LocalizationRoutingTab.d.ts +16 -0
  43. package/dist/admin/src/index.d.ts +21 -0
  44. package/dist/admin/src/pages/InboxHomePage.d.ts +3 -0
  45. package/dist/admin/src/pages/SettingsPage.d.ts +3 -0
  46. package/dist/admin/src/pluginId.d.ts +3 -0
  47. package/dist/admin/src/translations/cmLabels.d.ts +1 -0
  48. package/dist/admin/src/translations/cmPlaceholders.d.ts +1 -0
  49. package/dist/admin/src/utils/getTranslation.d.ts +3 -0
  50. package/dist/admin/tr-5q4NwTgF.mjs +268 -0
  51. package/dist/admin/tr-CT-24fLA.js +268 -0
  52. package/dist/admin/zh-CYhWM5Qr.mjs +268 -0
  53. package/dist/admin/zh-CmCHcNcd.js +268 -0
  54. package/dist/server/index.js +3108 -0
  55. package/dist/server/index.mjs +3108 -0
  56. package/dist/server/src/bootstrap.d.ts +5 -0
  57. package/dist/server/src/config/index.d.ts +5 -0
  58. package/dist/server/src/content-types/alert-banner/index.d.ts +73 -0
  59. package/dist/server/src/content-types/alert-banner/schema.json.d.ts +73 -0
  60. package/dist/server/src/content-types/index.d.ts +253 -0
  61. package/dist/server/src/content-types/submission/index.d.ts +111 -0
  62. package/dist/server/src/content-types/submission/schema.json.d.ts +126 -0
  63. package/dist/server/src/content-types/subscriber/index.d.ts +69 -0
  64. package/dist/server/src/content-types/subscriber/schema.json.d.ts +69 -0
  65. package/dist/server/src/controllers/caseworkHandlers.d.ts +10 -0
  66. package/dist/server/src/controllers/communityHandlers.d.ts +10 -0
  67. package/dist/server/src/controllers/formHandlers.d.ts +14 -0
  68. package/dist/server/src/controllers/inboxController.d.ts +40 -0
  69. package/dist/server/src/controllers/index.d.ts +2 -0
  70. package/dist/server/src/destroy.d.ts +5 -0
  71. package/dist/server/src/index.d.ts +2 -0
  72. package/dist/server/src/register.d.ts +5 -0
  73. package/dist/server/src/routes/admin.d.ts +12 -0
  74. package/dist/server/src/routes/content-api.d.ts +13 -0
  75. package/dist/server/src/routes/index.d.ts +26 -0
  76. package/dist/server/src/services/alertService.d.ts +16 -0
  77. package/dist/server/src/services/docHelper.d.ts +28 -0
  78. package/dist/server/src/services/formBuilderMapper.d.ts +22 -0
  79. package/dist/server/src/services/formBuilderSync.d.ts +13 -0
  80. package/dist/server/src/services/formService.d.ts +40 -0
  81. package/dist/server/src/services/index.d.ts +2 -0
  82. package/dist/server/src/services/settings.d.ts +9 -0
  83. package/dist/server/src/services/submissionEcosystemBridges.d.ts +21 -0
  84. package/dist/server/src/services/submissionFormBuilderBridge.d.ts +23 -0
  85. package/dist/server/src/services/submissionService.d.ts +58 -0
  86. package/dist/server/src/services/subscriberService.d.ts +22 -0
  87. package/dist/shared/index.d.ts +1 -0
  88. package/dist/shared/index.js +917 -0
  89. package/dist/shared/index.mjs +917 -0
  90. package/package.json +125 -3
@@ -0,0 +1,2171 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const designSystem = require("@strapi/design-system");
5
+ const admin = require("@strapi/strapi/admin");
6
+ const React = require("react");
7
+ const reactIntl = require("react-intl");
8
+ const index = require("./index-DLfoIVZP.js");
9
+ const reactRouterDom = require("react-router-dom");
10
+ const LocalizationRoutingTab = require("./LocalizationRoutingTab-Dt6U-kXn.js");
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
14
+ if (e) {
15
+ for (const k in e) {
16
+ if (k !== "default") {
17
+ const d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: () => e[k]
21
+ });
22
+ }
23
+ }
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
29
+ const STARTER_FORM_TEMPLATES = [
30
+ {
31
+ id: "general-contact",
32
+ name: "General Contact & Inquiry",
33
+ description: "Multi-language contact form with subject routing and anti-spam protection.",
34
+ form: {
35
+ title: "General Contact",
36
+ slug: "general-contact",
37
+ description: "Send us a message and our team will respond promptly.",
38
+ category: "contact",
39
+ active: true,
40
+ publishedAt: "2026-01-01T00:00:00.000Z",
41
+ translations: {
42
+ es: {
43
+ title: "Contacto General",
44
+ description: "Envíanos un mensaje y nuestro equipo te responderá pronto.",
45
+ submitButtonLabel: "Enviar mensaje",
46
+ successMessage: "Gracias por contactarnos. Hemos recibido tu mensaje."
47
+ },
48
+ en: {
49
+ title: "General Contact",
50
+ description: "Send us a message and our team will respond promptly.",
51
+ submitButtonLabel: "Send message",
52
+ successMessage: "Thank you for reaching out. We have received your message."
53
+ },
54
+ ar: {
55
+ title: "الاتصال العام",
56
+ description: "أرسل لنا رسالة وسيرد فريقنا في أقرب وقت.",
57
+ submitButtonLabel: "إرسال الرسالة",
58
+ successMessage: "شكراً لتواصلك معنا. لقد استلمنا رسالتك."
59
+ }
60
+ },
61
+ fields: [
62
+ {
63
+ id: "fld_full_name",
64
+ type: "text",
65
+ name: "fullName",
66
+ label: "Full Name",
67
+ required: true,
68
+ width: "half",
69
+ localizedLabels: {
70
+ es: "Nombre completo",
71
+ en: "Full Name",
72
+ ar: "الاسم الكامل"
73
+ },
74
+ validation: [{ type: "minLength", value: 2 }]
75
+ },
76
+ {
77
+ id: "fld_email",
78
+ type: "email",
79
+ name: "email",
80
+ label: "Email Address",
81
+ required: true,
82
+ width: "half",
83
+ localizedLabels: {
84
+ es: "Correo electrónico",
85
+ en: "Email Address",
86
+ ar: "البريد الإلكتروني"
87
+ }
88
+ },
89
+ {
90
+ id: "fld_phone",
91
+ type: "phone",
92
+ name: "phone",
93
+ label: "Phone / WhatsApp",
94
+ required: false,
95
+ width: "half",
96
+ localizedLabels: {
97
+ es: "Teléfono / WhatsApp",
98
+ en: "Phone / WhatsApp",
99
+ ar: "الهاتف / واتساب"
100
+ }
101
+ },
102
+ {
103
+ id: "fld_subject",
104
+ type: "select",
105
+ name: "subject",
106
+ label: "Subject",
107
+ required: true,
108
+ width: "half",
109
+ localizedLabels: {
110
+ es: "Asunto",
111
+ en: "Subject",
112
+ ar: "الموضوع"
113
+ },
114
+ options: [
115
+ {
116
+ value: "general",
117
+ label: "General Inquiry",
118
+ localizedLabels: {
119
+ es: "Consulta general",
120
+ en: "General Inquiry",
121
+ ar: "استفسار عام"
122
+ }
123
+ },
124
+ {
125
+ value: "visit",
126
+ label: "Guided Visit",
127
+ localizedLabels: {
128
+ es: "Visita guiada",
129
+ en: "Guided Visit",
130
+ ar: "زيارة إرشادية"
131
+ }
132
+ },
133
+ {
134
+ value: "support",
135
+ label: "Support & Assistance",
136
+ localizedLabels: {
137
+ es: "Apoyo y asistencia",
138
+ en: "Support & Assistance",
139
+ ar: "الدعم والمساعدة"
140
+ }
141
+ }
142
+ ]
143
+ },
144
+ {
145
+ id: "fld_message",
146
+ type: "textarea",
147
+ name: "message",
148
+ label: "Message",
149
+ required: true,
150
+ width: "full",
151
+ localizedLabels: {
152
+ es: "Mensaje",
153
+ en: "Message",
154
+ ar: "الرسالة"
155
+ },
156
+ validation: [
157
+ { type: "minLength", value: 10 },
158
+ { type: "maxLength", value: 2e3 }
159
+ ]
160
+ }
161
+ ],
162
+ settings: {
163
+ honeypotField: "_website_url",
164
+ rateLimitPerHour: 15,
165
+ captchaProvider: "none",
166
+ defaultPriority: "normal",
167
+ department: "general"
168
+ }
169
+ }
170
+ },
171
+ {
172
+ id: "service-desk-application",
173
+ name: "Service-Desk Casework & Document Checklist",
174
+ description: "Casework intake form with document verification checklist, booking bridge, and certificate bridge.",
175
+ form: {
176
+ title: "Formal Service Request",
177
+ slug: "service-request",
178
+ description: "Submit an official service application and required supporting documents.",
179
+ category: "service_desk",
180
+ active: true,
181
+ publishedAt: "2026-01-01T00:00:00.000Z",
182
+ translations: {
183
+ es: {
184
+ title: "Solicitud Formal de Servicio",
185
+ description: "Envía una solicitud oficial de servicio con los documentos requeridos.",
186
+ submitButtonLabel: "Radicar solicitud",
187
+ successMessage: "Tu solicitud ha sido radicada con éxito."
188
+ },
189
+ en: {
190
+ title: "Formal Service Request",
191
+ description: "Submit an official service application and required supporting documents.",
192
+ submitButtonLabel: "Submit application",
193
+ successMessage: "Your application has been registered."
194
+ },
195
+ ar: {
196
+ title: "طلب خدمة رسمي",
197
+ description: "قدم طلب خدمة رسمي مع المستندات المطلوبة.",
198
+ submitButtonLabel: "تقديم الطلب",
199
+ successMessage: "تم تسجيل طلبك بنجاح."
200
+ }
201
+ },
202
+ fields: [
203
+ {
204
+ id: "fld_applicant_name",
205
+ type: "text",
206
+ name: "applicantName",
207
+ label: "Applicant Full Name",
208
+ required: true,
209
+ width: "half",
210
+ localizedLabels: {
211
+ es: "Nombre completo del solicitante",
212
+ en: "Applicant Full Name",
213
+ ar: "الاسم الكامل لمقدم الطلب"
214
+ }
215
+ },
216
+ {
217
+ id: "fld_applicant_email",
218
+ type: "email",
219
+ name: "applicantEmail",
220
+ label: "Applicant Email",
221
+ required: true,
222
+ width: "half",
223
+ localizedLabels: {
224
+ es: "Correo del solicitante",
225
+ en: "Applicant Email",
226
+ ar: "البريد الإلكتروني لمقدم الطلب"
227
+ }
228
+ },
229
+ {
230
+ id: "fld_applicant_phone",
231
+ type: "phone",
232
+ name: "applicantPhone",
233
+ label: "Contact Phone",
234
+ required: true,
235
+ width: "half",
236
+ localizedLabels: {
237
+ es: "Teléfono de contacto",
238
+ en: "Contact Phone",
239
+ ar: "هاتف الاتصال"
240
+ }
241
+ },
242
+ {
243
+ id: "fld_preferred_date",
244
+ type: "date",
245
+ name: "preferredDate",
246
+ label: "Preferred Appointment Date",
247
+ required: false,
248
+ width: "half",
249
+ localizedLabels: {
250
+ es: "Fecha preferida de cita",
251
+ en: "Preferred Appointment Date",
252
+ ar: "تاريخ الموعد المفضل"
253
+ }
254
+ },
255
+ {
256
+ id: "fld_details",
257
+ type: "textarea",
258
+ name: "details",
259
+ label: "Case Details & Notes",
260
+ required: true,
261
+ width: "full",
262
+ localizedLabels: {
263
+ es: "Detalles del caso y observaciones",
264
+ en: "Case Details & Notes",
265
+ ar: "تفاصيل الطلب والملاحظات"
266
+ }
267
+ }
268
+ ],
269
+ checklistTemplate: [
270
+ {
271
+ id: "chk_id_document",
272
+ label: "Government ID / Passport Copy",
273
+ required: true,
274
+ verified: false,
275
+ localizedLabels: {
276
+ es: "Copia de documento de identidad / Pasaporte",
277
+ en: "Government ID / Passport Copy",
278
+ ar: "نسخة من بطاقة الهوية أو جواز السفر"
279
+ }
280
+ },
281
+ {
282
+ id: "chk_supporting_form",
283
+ label: "Signed Application Form",
284
+ required: true,
285
+ verified: false,
286
+ localizedLabels: {
287
+ es: "Formulario de solicitud firmado",
288
+ en: "Signed Application Form",
289
+ ar: "نموذج الطلب الموقع"
290
+ }
291
+ }
292
+ ],
293
+ settings: {
294
+ honeypotField: "_website_url",
295
+ rateLimitPerHour: 10,
296
+ captchaProvider: "none",
297
+ enableBookingBridge: true,
298
+ enableCertificateBridge: true,
299
+ defaultPriority: "normal",
300
+ department: "services"
301
+ }
302
+ }
303
+ }
304
+ ];
305
+ const cardBorderStyle$1 = {
306
+ border: "1px solid rgba(128, 128, 128, 0.2)"
307
+ };
308
+ const AlertBannersTab = ({
309
+ t,
310
+ alerts,
311
+ post,
312
+ onStatusMessage,
313
+ onReload
314
+ }) => {
315
+ const [showCreateForm, setShowCreateForm] = React__namespace.useState(false);
316
+ const [newAlertCode, setNewAlertCode] = React__namespace.useState("");
317
+ const [newAlertSeverity, setNewAlertSeverity] = React__namespace.useState("urgent");
318
+ const [newAlertPriority, setNewAlertPriority] = React__namespace.useState(100);
319
+ const [newAlertTitle, setNewAlertTitle] = React__namespace.useState("");
320
+ const [newAlertMessage, setNewAlertMessage] = React__namespace.useState("");
321
+ const [newAlertCtaLabel, setNewAlertCtaLabel] = React__namespace.useState("");
322
+ const [newAlertCtaUrl, setNewAlertCtaUrl] = React__namespace.useState("");
323
+ const handleCreateAlert = async () => {
324
+ if (!newAlertCode || !newAlertTitle || !newAlertMessage) return;
325
+ await post(`/${index.PLUGIN_ID}/alerts`, {
326
+ code: newAlertCode,
327
+ title: newAlertTitle,
328
+ message: newAlertMessage,
329
+ severity: newAlertSeverity,
330
+ active: true,
331
+ priority: newAlertPriority,
332
+ ctaLabel: newAlertCtaLabel || void 0,
333
+ ctaUrl: newAlertCtaUrl || void 0
334
+ });
335
+ setNewAlertCode("");
336
+ setNewAlertTitle("");
337
+ setNewAlertMessage("");
338
+ setNewAlertCtaLabel("");
339
+ setNewAlertCtaUrl("");
340
+ setShowCreateForm(false);
341
+ onStatusMessage("Site-wide alert banner saved");
342
+ await onReload();
343
+ };
344
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingTop: 5, children: [
345
+ /* @__PURE__ */ jsxRuntime.jsxs(
346
+ designSystem.Flex,
347
+ {
348
+ justifyContent: "space-between",
349
+ alignItems: "center",
350
+ paddingBottom: 4,
351
+ wrap: "wrap",
352
+ gap: 3,
353
+ children: [
354
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", children: t("page.ui.alert_banners_list", "Site-Wide Alert Banners") }),
355
+ /* @__PURE__ */ jsxRuntime.jsx(
356
+ designSystem.Button,
357
+ {
358
+ size: "S",
359
+ variant: showCreateForm ? "tertiary" : "default",
360
+ onClick: () => setShowCreateForm(!showCreateForm),
361
+ children: showCreateForm ? t("page.ui.cancel", "Cancel") : t("page.ui.new_alert_banner", "+ New Alert Banner")
362
+ }
363
+ )
364
+ ]
365
+ }
366
+ ),
367
+ showCreateForm ? /* @__PURE__ */ jsxRuntime.jsxs(
368
+ designSystem.Box,
369
+ {
370
+ padding: 5,
371
+ marginBottom: 5,
372
+ background: "neutral0",
373
+ hasRadius: true,
374
+ shadow: "filterShadow",
375
+ style: cardBorderStyle$1,
376
+ children: [
377
+ /* @__PURE__ */ jsxRuntime.jsxs(
378
+ designSystem.Flex,
379
+ {
380
+ justifyContent: "space-between",
381
+ alignItems: "center",
382
+ paddingBottom: 3,
383
+ wrap: "wrap",
384
+ gap: 2,
385
+ children: [
386
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h3", fontWeight: "bold", children: t(
387
+ "page.ui.publish_urgent_site_wide_alert_banner",
388
+ "Publish Site-Wide Alert Banner"
389
+ ) }),
390
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", onClick: handleCreateAlert, children: t("page.ui.save_alert_banner", "Save Alert Banner") })
391
+ ]
392
+ }
393
+ ),
394
+ /* @__PURE__ */ jsxRuntime.jsxs(
395
+ designSystem.Box,
396
+ {
397
+ style: {
398
+ display: "grid",
399
+ gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))",
400
+ gap: 16
401
+ },
402
+ children: [
403
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "code", required: true, children: [
404
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.alert_code", "Alert Code") }),
405
+ /* @__PURE__ */ jsxRuntime.jsx(
406
+ designSystem.TextInput,
407
+ {
408
+ name: "code",
409
+ placeholder: t("placeholder.alert_code", "RAMADAN-1448-HILAL"),
410
+ value: newAlertCode,
411
+ onChange: (e) => setNewAlertCode(e.target.value)
412
+ }
413
+ )
414
+ ] }),
415
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "severity", required: true, children: [
416
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.severity_level", "Severity") }),
417
+ /* @__PURE__ */ jsxRuntime.jsx(
418
+ designSystem.SingleSelect,
419
+ {
420
+ value: newAlertSeverity,
421
+ onChange: (val) => setNewAlertSeverity(String(val)),
422
+ children: index.ALERT_SEVERITIES.map((sev) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: sev, children: sev.toUpperCase() }, sev))
423
+ }
424
+ )
425
+ ] }),
426
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "priority", children: [
427
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.display_priority", "Priority") }),
428
+ /* @__PURE__ */ jsxRuntime.jsx(
429
+ designSystem.NumberInput,
430
+ {
431
+ name: "priority",
432
+ value: newAlertPriority,
433
+ onValueChange: (val) => setNewAlertPriority(typeof val === "number" ? val : 100)
434
+ }
435
+ )
436
+ ] }),
437
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "title", required: true, children: [
438
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.headline_title", "Headline") }),
439
+ /* @__PURE__ */ jsxRuntime.jsx(
440
+ designSystem.TextInput,
441
+ {
442
+ name: "title",
443
+ placeholder: t(
444
+ "placeholder.alert_headline",
445
+ "Moon-Sighting Announcement"
446
+ ),
447
+ value: newAlertTitle,
448
+ onChange: (e) => setNewAlertTitle(e.target.value)
449
+ }
450
+ )
451
+ ] }),
452
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "message", required: true, children: [
453
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.ticker_message", "Message") }),
454
+ /* @__PURE__ */ jsxRuntime.jsx(
455
+ designSystem.TextInput,
456
+ {
457
+ name: "message",
458
+ placeholder: t(
459
+ "placeholder.alert_message",
460
+ "The first day of Ramadan will be..."
461
+ ),
462
+ value: newAlertMessage,
463
+ onChange: (e) => setNewAlertMessage(e.target.value)
464
+ }
465
+ )
466
+ ] }),
467
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "ctaLabel", children: [
468
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.cta_button_label_optional", "CTA Label") }),
469
+ /* @__PURE__ */ jsxRuntime.jsx(
470
+ designSystem.TextInput,
471
+ {
472
+ name: "ctaLabel",
473
+ placeholder: t("placeholder.alert_cta_label", "View Schedule"),
474
+ value: newAlertCtaLabel,
475
+ onChange: (e) => setNewAlertCtaLabel(e.target.value)
476
+ }
477
+ )
478
+ ] }),
479
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "ctaUrl", children: [
480
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.cta_target_url_optional", "CTA URL") }),
481
+ /* @__PURE__ */ jsxRuntime.jsx(
482
+ designSystem.TextInput,
483
+ {
484
+ name: "ctaUrl",
485
+ placeholder: t("placeholder.alert_cta_url", "/es/ramadan"),
486
+ value: newAlertCtaUrl,
487
+ onChange: (e) => setNewAlertCtaUrl(e.target.value)
488
+ }
489
+ )
490
+ ] })
491
+ ]
492
+ }
493
+ )
494
+ ]
495
+ }
496
+ ) : null,
497
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: alerts.length + 1, children: [
498
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
499
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.code", "Code") }) }),
500
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.severity", "Severity") }) }),
501
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.title", "Headline") }) }),
502
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.message", "Message") }) }),
503
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.secondary_calendar", "Hijri Date") }) })
504
+ ] }) }),
505
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: alerts.map((banner) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
506
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: banner.code }) }),
507
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: banner.severity }) }),
508
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: banner.title }) }),
509
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: banner.message }) }),
510
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: banner.secondaryDateLabel || "-" }) })
511
+ ] }, banner.code)) })
512
+ ] })
513
+ ] });
514
+ };
515
+ function formatFieldKeyLabel(rawKey) {
516
+ return rawKey.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").trim().replace(/\b\w/g, (ch) => ch.toUpperCase());
517
+ }
518
+ const CaseworkPayloadChecklistColumn = ({
519
+ t,
520
+ shortLocale,
521
+ dataEntries,
522
+ form,
523
+ checklist,
524
+ onToggleChecklistItem
525
+ }) => {
526
+ const resolveFieldLabel = (key) => {
527
+ const matchedField = form?.fields?.find((f) => f.name === key);
528
+ if (matchedField) {
529
+ return matchedField.localizedLabels?.[shortLocale] || matchedField.label || formatFieldKeyLabel(key);
530
+ }
531
+ return formatFieldKeyLabel(key);
532
+ };
533
+ const resolveFieldValue = (key, val) => {
534
+ if (val === null || val === void 0 || val === "") return "-";
535
+ if (typeof val === "object") return JSON.stringify(val);
536
+ const strVal = String(val);
537
+ const matchedField = form?.fields?.find((f) => f.name === key);
538
+ const matchedOption = matchedField?.options?.find(
539
+ (o) => o.value === strVal
540
+ );
541
+ if (matchedOption) {
542
+ return matchedOption.localizedLabels?.[shortLocale] || matchedOption.label;
543
+ }
544
+ return strVal;
545
+ };
546
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { flex: "1 1 360px" }, children: [
547
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingBottom: 4, children: [
548
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("page.ui.submitted_form_payload", "Submitted Form Payload") }),
549
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 3, hasRadius: true, marginTop: 2, children: dataEntries.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: t(
550
+ "page.ui.no_payload_fields",
551
+ "No custom payload fields recorded."
552
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 0, children: dataEntries.map(([key, val], idx) => /* @__PURE__ */ jsxRuntime.jsxs(
553
+ designSystem.Flex,
554
+ {
555
+ justifyContent: "space-between",
556
+ alignItems: "baseline",
557
+ gap: 3,
558
+ paddingTop: 2,
559
+ paddingBottom: 2,
560
+ style: {
561
+ borderBottom: idx < dataEntries.length - 1 ? "1px solid rgba(128, 128, 128, 0.14)" : "none"
562
+ },
563
+ children: [
564
+ /* @__PURE__ */ jsxRuntime.jsx(
565
+ designSystem.Typography,
566
+ {
567
+ variant: "pi",
568
+ fontWeight: "bold",
569
+ textColor: "neutral600",
570
+ style: { textTransform: "capitalize" },
571
+ children: resolveFieldLabel(key)
572
+ }
573
+ ),
574
+ /* @__PURE__ */ jsxRuntime.jsx(
575
+ designSystem.Typography,
576
+ {
577
+ variant: "pi",
578
+ fontWeight: "semiBold",
579
+ textColor: "neutral800",
580
+ style: { textAlign: "right" },
581
+ children: resolveFieldValue(key, val)
582
+ }
583
+ )
584
+ ]
585
+ },
586
+ key
587
+ )) }) })
588
+ ] }),
589
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
590
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: [
591
+ t(
592
+ "page.ui.document_verification_checklist",
593
+ "Document Verification Checklist"
594
+ ),
595
+ " ",
596
+ "(",
597
+ checklist.filter((c) => c.verified).length,
598
+ "/",
599
+ checklist.length,
600
+ ")"
601
+ ] }),
602
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "neutral100", padding: 3, hasRadius: true, marginTop: 2, children: checklist.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: t(
603
+ "page.ui.no_checklist",
604
+ "No verification checklist attached to this form."
605
+ ) }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: checklist.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
606
+ designSystem.Flex,
607
+ {
608
+ justifyContent: "space-between",
609
+ alignItems: "center",
610
+ gap: 2,
611
+ children: [
612
+ /* @__PURE__ */ jsxRuntime.jsx(
613
+ designSystem.Checkbox,
614
+ {
615
+ checked: Boolean(item.verified),
616
+ onCheckedChange: (checked) => onToggleChecklistItem(item.id, Boolean(checked)),
617
+ children: item.localizedLabels?.[shortLocale] || item.label
618
+ }
619
+ ),
620
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { active: Boolean(item.verified), children: item.verified ? t("page.ui.verified", "Verified") : item.required ? t("page.ui.required", "Required") : t("page.ui.optional", "Optional") })
621
+ ]
622
+ },
623
+ item.id
624
+ )) }) })
625
+ ] })
626
+ ] });
627
+ };
628
+ const CaseworkHeaderBar = ({
629
+ t,
630
+ submission,
631
+ onClose
632
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(
633
+ designSystem.Flex,
634
+ {
635
+ justifyContent: "space-between",
636
+ alignItems: "center",
637
+ paddingBottom: 3,
638
+ wrap: "wrap",
639
+ gap: 2,
640
+ children: [
641
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", wrap: "wrap", children: [
642
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "delta", fontWeight: "bold", children: [
643
+ t("page.ui.casework_inspector", "Casework Inspector"),
644
+ ":",
645
+ " ",
646
+ submission.referenceCode
647
+ ] }),
648
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: submission.formSlug }),
649
+ submission.secondaryDate?.formatted ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: submission.secondaryDate.formatted }) : null,
650
+ submission.linkedBookingId ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { active: true, children: [
651
+ t("page.ui.booking_badge", "Booking"),
652
+ ": ",
653
+ submission.linkedBookingId
654
+ ] }) : null,
655
+ submission.linkedCertificateNumber ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { active: true, children: [
656
+ t("page.ui.cert_badge", "Cert"),
657
+ ":",
658
+ " ",
659
+ submission.linkedCertificateNumber
660
+ ] }) : null
661
+ ] }),
662
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", size: "S", onClick: onClose, children: t("page.ui.close_inspector", "Close Inspector") })
663
+ ]
664
+ }
665
+ );
666
+ const CaseworkQuickBridges = ({
667
+ t,
668
+ bookingServiceSlug,
669
+ onBookingServiceSlugChange,
670
+ bookingDate,
671
+ onBookingDateChange,
672
+ bookingTime,
673
+ onBookingTimeChange,
674
+ onBookSlot,
675
+ certTemplateSlug,
676
+ onCertTemplateSlugChange,
677
+ certRecipient,
678
+ onCertRecipientChange,
679
+ requireVerifiedChecklist,
680
+ onRequireVerifiedChecklistChange,
681
+ onIssueCert
682
+ }) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, paddingTop: 3, wrap: "wrap", alignItems: "stretch", children: [
683
+ /* @__PURE__ */ jsxRuntime.jsxs(
684
+ designSystem.Box,
685
+ {
686
+ background: "neutral100",
687
+ padding: 3,
688
+ hasRadius: true,
689
+ style: { flex: "1 1 180px" },
690
+ children: [
691
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.schedule_appointment", "Schedule Appointment") }),
692
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, paddingTop: 2, children: [
693
+ /* @__PURE__ */ jsxRuntime.jsx(
694
+ designSystem.TextInput,
695
+ {
696
+ name: "bookingServiceSlug",
697
+ placeholder: t("placeholder.service_slug", "Service slug"),
698
+ value: bookingServiceSlug,
699
+ onChange: (e) => onBookingServiceSlugChange(e.target.value)
700
+ }
701
+ ),
702
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
703
+ /* @__PURE__ */ jsxRuntime.jsx(
704
+ designSystem.TextInput,
705
+ {
706
+ name: "bookingDate",
707
+ type: "date",
708
+ value: bookingDate,
709
+ onChange: (e) => onBookingDateChange(e.target.value)
710
+ }
711
+ ),
712
+ /* @__PURE__ */ jsxRuntime.jsx(
713
+ designSystem.TextInput,
714
+ {
715
+ name: "bookingTime",
716
+ placeholder: "10:00",
717
+ value: bookingTime,
718
+ onChange: (e) => onBookingTimeChange(e.target.value)
719
+ }
720
+ )
721
+ ] }),
722
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: onBookSlot, children: t("page.ui.book_slot", "Book Slot") })
723
+ ] })
724
+ ]
725
+ }
726
+ ),
727
+ /* @__PURE__ */ jsxRuntime.jsxs(
728
+ designSystem.Box,
729
+ {
730
+ background: "neutral100",
731
+ padding: 3,
732
+ hasRadius: true,
733
+ style: { flex: "1 1 180px" },
734
+ children: [
735
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.issue_certificate", "Issue Certificate") }),
736
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, paddingTop: 2, children: [
737
+ /* @__PURE__ */ jsxRuntime.jsx(
738
+ designSystem.TextInput,
739
+ {
740
+ name: "certTemplateSlug",
741
+ placeholder: t("placeholder.template_slug", "Template slug"),
742
+ value: certTemplateSlug,
743
+ onChange: (e) => onCertTemplateSlugChange(e.target.value)
744
+ }
745
+ ),
746
+ /* @__PURE__ */ jsxRuntime.jsx(
747
+ designSystem.TextInput,
748
+ {
749
+ name: "certRecipient",
750
+ placeholder: t(
751
+ "placeholder.recipient_full_name",
752
+ "Recipient full name"
753
+ ),
754
+ value: certRecipient,
755
+ onChange: (e) => onCertRecipientChange(e.target.value)
756
+ }
757
+ ),
758
+ /* @__PURE__ */ jsxRuntime.jsx(
759
+ designSystem.Checkbox,
760
+ {
761
+ checked: requireVerifiedChecklist,
762
+ onCheckedChange: (c) => onRequireVerifiedChecklistChange(Boolean(c)),
763
+ children: t(
764
+ "page.ui.require_verified_checklist",
765
+ "Require verified checklist"
766
+ )
767
+ }
768
+ ),
769
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: onIssueCert, children: t("page.ui.issue_cert", "Issue Cert") })
770
+ ] })
771
+ ]
772
+ }
773
+ )
774
+ ] });
775
+ const CaseworkDetailPanel = ({
776
+ t,
777
+ submission,
778
+ form,
779
+ post,
780
+ put,
781
+ onStatusMessage,
782
+ onReload,
783
+ onClose
784
+ }) => {
785
+ const { locale } = reactIntl.useIntl();
786
+ const shortLocale = (locale || "es").split("-")[0].toLowerCase();
787
+ const [status, setStatus] = React__namespace.useState(
788
+ submission.status
789
+ );
790
+ const [priority, setPriority] = React__namespace.useState(
791
+ submission.priority
792
+ );
793
+ const [department, setDepartment] = React__namespace.useState(
794
+ submission.department || "general"
795
+ );
796
+ const [assignedTo, setAssignedTo] = React__namespace.useState(
797
+ submission.assignedTo || ""
798
+ );
799
+ const [staffNotes, setStaffNotes] = React__namespace.useState(
800
+ submission.staffNotes || ""
801
+ );
802
+ const [checklist, setChecklist] = React__namespace.useState(
803
+ submission.checklistItems || []
804
+ );
805
+ const [bookingServiceSlug, setBookingServiceSlug] = React__namespace.useState(
806
+ form?.settings?.defaultBookingServiceSlug || "general-appointment"
807
+ );
808
+ const [bookingDate, setBookingDate] = React__namespace.useState(
809
+ (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
810
+ );
811
+ const [bookingTime, setBookingTime] = React__namespace.useState("10:00");
812
+ const [certTemplateSlug, setCertTemplateSlug] = React__namespace.useState(
813
+ form?.settings?.defaultCertificateTemplateId || "official-service-certificate"
814
+ );
815
+ const [certRecipient, setCertRecipient] = React__namespace.useState(
816
+ submission.applicantName || ""
817
+ );
818
+ const [requireVerifiedChecklist, setRequireVerifiedChecklist] = React__namespace.useState(true);
819
+ React__namespace.useEffect(() => {
820
+ setStatus(submission.status);
821
+ setPriority(submission.priority);
822
+ setDepartment(submission.department || "general");
823
+ setAssignedTo(submission.assignedTo || "");
824
+ setStaffNotes(submission.staffNotes || "");
825
+ setChecklist(submission.checklistItems || []);
826
+ setCertRecipient(submission.applicantName || "");
827
+ }, [submission]);
828
+ const handleToggleChecklistItem = async (itemId, verified) => {
829
+ const nextChecklist = checklist.map(
830
+ (item) => item.id === itemId ? {
831
+ ...item,
832
+ verified,
833
+ verifiedAt: verified ? (/* @__PURE__ */ new Date()).toISOString() : void 0
834
+ } : item
835
+ );
836
+ setChecklist(nextChecklist);
837
+ if (!submission.documentId) return;
838
+ await put(`/${index.PLUGIN_ID}/submissions/${submission.documentId}/casework`, {
839
+ checklistItems: nextChecklist
840
+ });
841
+ onStatusMessage(
842
+ `${t("page.ui.checklist_updated", "Checklist updated")}: ${submission.referenceCode}`
843
+ );
844
+ await onReload();
845
+ };
846
+ const handleSaveCasework = async () => {
847
+ if (!submission.documentId) return;
848
+ await put(`/${index.PLUGIN_ID}/submissions/${submission.documentId}/casework`, {
849
+ status,
850
+ priority,
851
+ department,
852
+ assignedTo,
853
+ staffNotes,
854
+ checklistItems: checklist
855
+ });
856
+ onStatusMessage(
857
+ `${t("page.ui.casework_saved", "Saved casework updates")}: ${submission.referenceCode}`
858
+ );
859
+ await onReload();
860
+ };
861
+ const handleCustomBooking = async () => {
862
+ if (!submission.documentId) return;
863
+ await post(
864
+ `/${index.PLUGIN_ID}/submissions/${submission.documentId}/schedule-booking`,
865
+ {
866
+ serviceSlug: bookingServiceSlug,
867
+ date: bookingDate,
868
+ startTime: bookingTime,
869
+ notes: staffNotes || `Casework Ref: ${submission.referenceCode}`
870
+ }
871
+ );
872
+ onStatusMessage(
873
+ `${t("page.ui.appointment_scheduled", "Appointment scheduled")} (${bookingDate} ${bookingTime})`
874
+ );
875
+ await onReload();
876
+ };
877
+ const handleCustomCertificate = async () => {
878
+ if (!submission.documentId) return;
879
+ try {
880
+ await post(
881
+ `/${index.PLUGIN_ID}/submissions/${submission.documentId}/issue-certificate`,
882
+ {
883
+ templateSlug: certTemplateSlug,
884
+ recipientName: certRecipient || submission.applicantName,
885
+ requireChecklistVerified: requireVerifiedChecklist
886
+ }
887
+ );
888
+ onStatusMessage(
889
+ `${t("page.ui.certificate_issued", "Certificate issued")}: ${submission.referenceCode}`
890
+ );
891
+ await onReload();
892
+ } catch (err) {
893
+ const fallbackError = t(
894
+ "page.ui.verify_checklist_error",
895
+ "Cannot issue certificate: verify required checklist items first"
896
+ );
897
+ onStatusMessage(err instanceof Error ? err.message : fallbackError);
898
+ }
899
+ };
900
+ const dataEntries = Object.entries(submission.data || {});
901
+ return /* @__PURE__ */ jsxRuntime.jsxs(
902
+ designSystem.Box,
903
+ {
904
+ background: "neutral0",
905
+ padding: 5,
906
+ shadow: "filterShadow",
907
+ hasRadius: true,
908
+ marginBottom: 5,
909
+ children: [
910
+ /* @__PURE__ */ jsxRuntime.jsx(CaseworkHeaderBar, { t, submission, onClose }),
911
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
912
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 5, paddingTop: 4, alignItems: "flex-start", wrap: "wrap", children: [
913
+ /* @__PURE__ */ jsxRuntime.jsx(
914
+ CaseworkPayloadChecklistColumn,
915
+ {
916
+ t,
917
+ shortLocale,
918
+ dataEntries,
919
+ form,
920
+ checklist,
921
+ onToggleChecklistItem: handleToggleChecklistItem
922
+ }
923
+ ),
924
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { flex: "1 1 400px" }, children: [
925
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, wrap: "wrap", children: [
926
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 130px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
927
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("page.ui.status", "Status") }),
928
+ /* @__PURE__ */ jsxRuntime.jsx(
929
+ designSystem.SingleSelect,
930
+ {
931
+ value: status,
932
+ onChange: (v) => setStatus(v),
933
+ children: index.SUBMISSION_STATUSES.map((st) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: st, children: st }, st))
934
+ }
935
+ )
936
+ ] }) }),
937
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 130px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
938
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("page.ui.priority", "Priority") }),
939
+ /* @__PURE__ */ jsxRuntime.jsx(
940
+ designSystem.SingleSelect,
941
+ {
942
+ value: priority,
943
+ onChange: (v) => setPriority(v),
944
+ children: index.SUBMISSION_PRIORITIES.map((pr) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: pr, children: pr }, pr))
945
+ }
946
+ )
947
+ ] }) }),
948
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 150px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
949
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("page.ui.assignee", "Assignee") }),
950
+ /* @__PURE__ */ jsxRuntime.jsx(
951
+ designSystem.TextInput,
952
+ {
953
+ name: "assignedTo",
954
+ placeholder: t(
955
+ "placeholder.assignee_example",
956
+ "e.g. Sheikh Ahmad"
957
+ ),
958
+ value: assignedTo,
959
+ onChange: (e) => setAssignedTo(e.target.value)
960
+ }
961
+ )
962
+ ] }) })
963
+ ] }),
964
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingTop: 3, paddingBottom: 3, children: [
965
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
966
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("page.ui.internal_staff_notes", "Internal Staff Notes") }),
967
+ /* @__PURE__ */ jsxRuntime.jsx(
968
+ designSystem.Textarea,
969
+ {
970
+ name: "staffNotes",
971
+ value: staffNotes,
972
+ onChange: (e) => setStaffNotes(e.target.value)
973
+ }
974
+ )
975
+ ] }),
976
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", onClick: handleSaveCasework, children: t("page.ui.save_casework_notes", "Save Casework & Notes") }) })
977
+ ] }),
978
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
979
+ /* @__PURE__ */ jsxRuntime.jsx(
980
+ CaseworkQuickBridges,
981
+ {
982
+ t,
983
+ bookingServiceSlug,
984
+ onBookingServiceSlugChange: setBookingServiceSlug,
985
+ bookingDate,
986
+ onBookingDateChange: setBookingDate,
987
+ bookingTime,
988
+ onBookingTimeChange: setBookingTime,
989
+ onBookSlot: handleCustomBooking,
990
+ certTemplateSlug,
991
+ onCertTemplateSlugChange: setCertTemplateSlug,
992
+ certRecipient,
993
+ onCertRecipientChange: setCertRecipient,
994
+ requireVerifiedChecklist,
995
+ onRequireVerifiedChecklistChange: setRequireVerifiedChecklist,
996
+ onIssueCert: handleCustomCertificate
997
+ }
998
+ )
999
+ ] })
1000
+ ] })
1001
+ ]
1002
+ }
1003
+ );
1004
+ };
1005
+ const matchesSubmissionFilters = (sub, statusFilter, priorityFilter, searchQuery) => {
1006
+ if (statusFilter !== "all" && sub.status !== statusFilter) return false;
1007
+ if (priorityFilter !== "all" && sub.priority !== priorityFilter) return false;
1008
+ const q = searchQuery.trim().toLowerCase();
1009
+ if (!q) return true;
1010
+ const haystack = [
1011
+ sub.referenceCode,
1012
+ sub.formSlug,
1013
+ sub.department,
1014
+ sub.applicantName,
1015
+ sub.applicantEmail
1016
+ ].filter(Boolean).join(" ").toLowerCase();
1017
+ return haystack.includes(q);
1018
+ };
1019
+ const SubmissionRow = ({
1020
+ t,
1021
+ sub,
1022
+ isSelected,
1023
+ onToggleInspect,
1024
+ onScheduleBooking,
1025
+ onIssueCertificate,
1026
+ onMarkCompleted
1027
+ }) => {
1028
+ const items = sub.checklistItems || [];
1029
+ const totalChecklist = items.length;
1030
+ const verifiedChecklist = items.filter((c) => c.verified).length;
1031
+ const linkedSummary = [sub.linkedBookingId, sub.linkedCertificateNumber].filter(Boolean).join(" • ");
1032
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
1033
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
1034
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: sub.referenceCode }),
1035
+ linkedSummary ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: linkedSummary }) : null
1036
+ ] }) }),
1037
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", children: [
1038
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: sub.applicantName || t("page.ui.anonymous", "Anonymous") }),
1039
+ sub.applicantEmail ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: sub.applicantEmail }) : null
1040
+ ] }) }),
1041
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
1042
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { children: [
1043
+ sub.formSlug,
1044
+ " (",
1045
+ sub.department || "general",
1046
+ ")"
1047
+ ] }),
1048
+ totalChecklist > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: [
1049
+ t("page.ui.checklist", "Checklist"),
1050
+ ": ",
1051
+ verifiedChecklist,
1052
+ "/",
1053
+ totalChecklist,
1054
+ " ",
1055
+ t("page.ui.verified", "verified")
1056
+ ] }) : null
1057
+ ] }) }),
1058
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
1059
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: sub.status }),
1060
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: sub.priority })
1061
+ ] }) }),
1062
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", children: [
1063
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: sub.submittedAt?.slice(0, 10) }),
1064
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: sub.secondaryDate?.formatted || "-" })
1065
+ ] }) }),
1066
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
1067
+ /* @__PURE__ */ jsxRuntime.jsx(
1068
+ designSystem.Button,
1069
+ {
1070
+ size: "S",
1071
+ variant: isSelected ? "default" : "tertiary",
1072
+ onClick: () => onToggleInspect(sub.referenceCode, isSelected),
1073
+ children: isSelected ? t("page.ui.hide_details", "Close") : t("page.ui.inspect", "Inspect")
1074
+ }
1075
+ ),
1076
+ /* @__PURE__ */ jsxRuntime.jsx(
1077
+ designSystem.Button,
1078
+ {
1079
+ size: "S",
1080
+ variant: "secondary",
1081
+ onClick: () => onScheduleBooking(sub.documentId),
1082
+ children: t("page.ui.book_slot", "Book Slot")
1083
+ }
1084
+ ),
1085
+ /* @__PURE__ */ jsxRuntime.jsx(
1086
+ designSystem.Button,
1087
+ {
1088
+ size: "S",
1089
+ variant: "secondary",
1090
+ onClick: () => onIssueCertificate(sub.documentId),
1091
+ children: t("page.ui.issue_cert", "Issue Cert")
1092
+ }
1093
+ ),
1094
+ /* @__PURE__ */ jsxRuntime.jsx(
1095
+ designSystem.Button,
1096
+ {
1097
+ size: "S",
1098
+ variant: "tertiary",
1099
+ onClick: () => onMarkCompleted(sub.documentId),
1100
+ children: t("page.ui.complete", "Complete")
1101
+ }
1102
+ )
1103
+ ] }) })
1104
+ ] }, sub.referenceCode);
1105
+ };
1106
+ const CaseworkSubmissionsTab = ({
1107
+ t,
1108
+ submissions,
1109
+ forms = [],
1110
+ post,
1111
+ put,
1112
+ onStatusMessage,
1113
+ onReload
1114
+ }) => {
1115
+ const [searchQuery, setSearchQuery] = React__namespace.useState("");
1116
+ const [statusFilter, setStatusFilter] = React__namespace.useState("all");
1117
+ const [priorityFilter, setPriorityFilter] = React__namespace.useState("all");
1118
+ const [selectedRefCode, setSelectedRefCode] = React__namespace.useState(
1119
+ null
1120
+ );
1121
+ const selectedSubmission = React__namespace.useMemo(
1122
+ () => submissions.find((s) => s.referenceCode === selectedRefCode) || null,
1123
+ [submissions, selectedRefCode]
1124
+ );
1125
+ const selectedForm = React__namespace.useMemo(
1126
+ () => selectedSubmission ? forms.find((f) => f.slug === selectedSubmission.formSlug) || null : null,
1127
+ [forms, selectedSubmission]
1128
+ );
1129
+ const handleScheduleBooking = async (documentId) => {
1130
+ if (!documentId) return;
1131
+ await post(`/${index.PLUGIN_ID}/submissions/${documentId}/schedule-booking`, {
1132
+ serviceSlug: "general-appointment",
1133
+ date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
1134
+ startTime: "10:00"
1135
+ });
1136
+ onStatusMessage("Appointment scheduled via Bookings bridge");
1137
+ await onReload();
1138
+ };
1139
+ const handleIssueCertificate = async (documentId) => {
1140
+ if (!documentId) return;
1141
+ await post(`/${index.PLUGIN_ID}/submissions/${documentId}/issue-certificate`, {
1142
+ requireChecklistVerified: false
1143
+ });
1144
+ onStatusMessage("Certificate issued via Certificates bridge");
1145
+ await onReload();
1146
+ };
1147
+ const handleMarkCompleted = async (documentId) => {
1148
+ if (!documentId) return;
1149
+ await put(`/${index.PLUGIN_ID}/submissions/${documentId}/casework`, {
1150
+ status: "completed"
1151
+ });
1152
+ onStatusMessage("Submission marked as completed");
1153
+ await onReload();
1154
+ };
1155
+ const filteredSubmissions = React__namespace.useMemo(
1156
+ () => submissions.filter(
1157
+ (sub) => matchesSubmissionFilters(sub, statusFilter, priorityFilter, searchQuery)
1158
+ ),
1159
+ [submissions, statusFilter, priorityFilter, searchQuery]
1160
+ );
1161
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingTop: 5, children: [
1162
+ /* @__PURE__ */ jsxRuntime.jsxs(
1163
+ designSystem.Flex,
1164
+ {
1165
+ justifyContent: "space-between",
1166
+ alignItems: "center",
1167
+ paddingBottom: 4,
1168
+ wrap: "wrap",
1169
+ gap: 3,
1170
+ children: [
1171
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 280px", maxWidth: 420 }, children: /* @__PURE__ */ jsxRuntime.jsx(
1172
+ designSystem.TextInput,
1173
+ {
1174
+ name: "searchSubmissions",
1175
+ placeholder: t(
1176
+ "placeholder.search_submissions",
1177
+ "Search by reference code, applicant, or form..."
1178
+ ),
1179
+ value: searchQuery,
1180
+ onChange: (e) => setSearchQuery(e.target.value)
1181
+ }
1182
+ ) }),
1183
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, wrap: "wrap", children: [
1184
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { minWidth: 170 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
1185
+ designSystem.SingleSelect,
1186
+ {
1187
+ value: statusFilter,
1188
+ onChange: (val) => setStatusFilter(String(val)),
1189
+ children: [
1190
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "all", children: t("page.ui.all_statuses", "Status: All") }),
1191
+ index.SUBMISSION_STATUSES.map((st) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: st, children: [
1192
+ t("page.ui.status", "Status"),
1193
+ ": ",
1194
+ st
1195
+ ] }, st))
1196
+ ]
1197
+ }
1198
+ ) }),
1199
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { minWidth: 170 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
1200
+ designSystem.SingleSelect,
1201
+ {
1202
+ value: priorityFilter,
1203
+ onChange: (val) => setPriorityFilter(String(val)),
1204
+ children: [
1205
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "all", children: t("page.ui.all_priorities", "Priority: All") }),
1206
+ index.SUBMISSION_PRIORITIES.map((pr) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelectOption, { value: pr, children: [
1207
+ t("page.ui.priority", "Priority"),
1208
+ ": ",
1209
+ pr
1210
+ ] }, pr))
1211
+ ]
1212
+ }
1213
+ ) })
1214
+ ] })
1215
+ ]
1216
+ }
1217
+ ),
1218
+ selectedSubmission ? /* @__PURE__ */ jsxRuntime.jsx(
1219
+ CaseworkDetailPanel,
1220
+ {
1221
+ t,
1222
+ submission: selectedSubmission,
1223
+ form: selectedForm,
1224
+ post,
1225
+ put,
1226
+ onStatusMessage,
1227
+ onReload,
1228
+ onClose: () => setSelectedRefCode(null)
1229
+ }
1230
+ ) : null,
1231
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 6, rowCount: filteredSubmissions.length + 1, children: [
1232
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
1233
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.ref_code", "Reference") }) }),
1234
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.applicant", "Applicant") }) }),
1235
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.form_dept", "Form & Dept") }) }),
1236
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.status_priority", "Status") }) }),
1237
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.date_secondary", "Submitted (Hijri)") }) }),
1238
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.actions", "Actions") }) })
1239
+ ] }) }),
1240
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: filteredSubmissions.map((sub) => /* @__PURE__ */ jsxRuntime.jsx(
1241
+ SubmissionRow,
1242
+ {
1243
+ t,
1244
+ sub,
1245
+ isSelected: selectedRefCode === sub.referenceCode,
1246
+ onToggleInspect: (refCode, selected) => setSelectedRefCode(selected ? null : refCode),
1247
+ onScheduleBooking: handleScheduleBooking,
1248
+ onIssueCertificate: handleIssueCertificate,
1249
+ onMarkCompleted: handleMarkCompleted
1250
+ },
1251
+ sub.referenceCode
1252
+ )) })
1253
+ ] })
1254
+ ] });
1255
+ };
1256
+ const SUPPORTED_FORM_LOCALES = ["es", "en", "ar"];
1257
+ const FormChecklistAndLocalePanels = ({
1258
+ t,
1259
+ checklistItems,
1260
+ newChecklistLabel,
1261
+ onNewChecklistLabelChange,
1262
+ onAddChecklistItem,
1263
+ onRemoveChecklistItem,
1264
+ onUpdateChecklistItemLabel,
1265
+ activeLocale,
1266
+ onActiveLocaleChange,
1267
+ translations,
1268
+ onUpdateTranslationField
1269
+ }) => {
1270
+ const currentTranslation = translations[activeLocale] || {};
1271
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 5, paddingTop: 4, wrap: "wrap", alignItems: "flex-start", children: [
1272
+ /* @__PURE__ */ jsxRuntime.jsxs(
1273
+ designSystem.Box,
1274
+ {
1275
+ padding: 4,
1276
+ background: "neutral100",
1277
+ hasRadius: true,
1278
+ style: { flex: "1 1 340px" },
1279
+ children: [
1280
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
1281
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: [
1282
+ t(
1283
+ "page.ui.required_verification_documents",
1284
+ "Required Verification Documents"
1285
+ ),
1286
+ " ",
1287
+ "(",
1288
+ checklistItems.length,
1289
+ ")"
1290
+ ] }),
1291
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: activeLocale.toUpperCase() })
1292
+ ] }),
1293
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, paddingTop: 2, children: [
1294
+ checklistItems.map((item) => {
1295
+ const displayLabel = item.localizedLabels?.[activeLocale] ?? item.label;
1296
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1297
+ designSystem.Flex,
1298
+ {
1299
+ justifyContent: "space-between",
1300
+ alignItems: "center",
1301
+ gap: 2,
1302
+ padding: 2,
1303
+ background: "neutral0",
1304
+ hasRadius: true,
1305
+ children: [
1306
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: onUpdateChecklistItemLabel ? /* @__PURE__ */ jsxRuntime.jsx(
1307
+ designSystem.TextInput,
1308
+ {
1309
+ name: `chk_${item.id}`,
1310
+ value: displayLabel,
1311
+ onChange: (e) => onUpdateChecklistItemLabel(item.id, e.target.value)
1312
+ }
1313
+ ) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: displayLabel }) }),
1314
+ /* @__PURE__ */ jsxRuntime.jsx(
1315
+ designSystem.Button,
1316
+ {
1317
+ size: "S",
1318
+ variant: "danger-light",
1319
+ onClick: () => onRemoveChecklistItem(item.id),
1320
+ children: t("page.ui.remove", "Remove")
1321
+ }
1322
+ )
1323
+ ]
1324
+ },
1325
+ item.id
1326
+ );
1327
+ }),
1328
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, paddingTop: 2, children: [
1329
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
1330
+ designSystem.TextInput,
1331
+ {
1332
+ name: "newChecklistLabel",
1333
+ placeholder: t(
1334
+ "placeholder.add_required_document",
1335
+ "Add required document (e.g., Valid National ID)..."
1336
+ ),
1337
+ value: newChecklistLabel,
1338
+ onChange: (e) => onNewChecklistLabelChange(e.target.value)
1339
+ }
1340
+ ) }),
1341
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: onAddChecklistItem, children: t("page.ui.add_item", "+ Add") })
1342
+ ] })
1343
+ ] })
1344
+ ]
1345
+ }
1346
+ ),
1347
+ /* @__PURE__ */ jsxRuntime.jsxs(
1348
+ designSystem.Box,
1349
+ {
1350
+ padding: 4,
1351
+ background: "neutral100",
1352
+ hasRadius: true,
1353
+ style: { flex: "1 1 360px" },
1354
+ children: [
1355
+ /* @__PURE__ */ jsxRuntime.jsxs(
1356
+ designSystem.Flex,
1357
+ {
1358
+ justifyContent: "space-between",
1359
+ alignItems: "center",
1360
+ paddingBottom: 2,
1361
+ children: [
1362
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t(
1363
+ "page.ui.form_localization_header",
1364
+ "Form Localization (es / en / ar)"
1365
+ ) }),
1366
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: SUPPORTED_FORM_LOCALES.map((loc) => /* @__PURE__ */ jsxRuntime.jsx(
1367
+ designSystem.Button,
1368
+ {
1369
+ size: "S",
1370
+ variant: activeLocale === loc ? "default" : "tertiary",
1371
+ onClick: () => onActiveLocaleChange(loc),
1372
+ children: loc.toUpperCase()
1373
+ },
1374
+ loc
1375
+ )) })
1376
+ ]
1377
+ }
1378
+ ),
1379
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
1380
+ /* @__PURE__ */ jsxRuntime.jsx(
1381
+ designSystem.TextInput,
1382
+ {
1383
+ name: "localizedTitle",
1384
+ placeholder: `${t("placeholder.localized_title", "Localized title")} (${activeLocale})`,
1385
+ value: currentTranslation.title || "",
1386
+ onChange: (e) => onUpdateTranslationField("title", e.target.value)
1387
+ }
1388
+ ),
1389
+ /* @__PURE__ */ jsxRuntime.jsx(
1390
+ designSystem.TextInput,
1391
+ {
1392
+ name: "localizedDescription",
1393
+ placeholder: `${t("placeholder.localized_description", "Localized description")} (${activeLocale})`,
1394
+ value: currentTranslation.description || "",
1395
+ onChange: (e) => onUpdateTranslationField("description", e.target.value)
1396
+ }
1397
+ ),
1398
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
1399
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
1400
+ designSystem.TextInput,
1401
+ {
1402
+ name: "localizedSubmit",
1403
+ placeholder: `${t("placeholder.localized_submit_label", "Submit label")} (${activeLocale})`,
1404
+ value: currentTranslation.submitButtonLabel || "",
1405
+ onChange: (e) => onUpdateTranslationField("submitButtonLabel", e.target.value)
1406
+ }
1407
+ ) }),
1408
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
1409
+ designSystem.TextInput,
1410
+ {
1411
+ name: "localizedSuccess",
1412
+ placeholder: `${t("placeholder.localized_success_message", "Success message")} (${activeLocale})`,
1413
+ value: currentTranslation.successMessage || "",
1414
+ onChange: (e) => onUpdateTranslationField("successMessage", e.target.value)
1415
+ }
1416
+ ) })
1417
+ ] }),
1418
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, paddingTop: 1, children: SUPPORTED_FORM_LOCALES.map(
1419
+ (loc) => translations[loc]?.title ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { children: [
1420
+ loc.toUpperCase(),
1421
+ " ",
1422
+ t("page.ui.ready", "Ready")
1423
+ ] }, loc) : null
1424
+ ) })
1425
+ ] })
1426
+ ]
1427
+ }
1428
+ )
1429
+ ] });
1430
+ };
1431
+ const FormRoutingDrawer = ({
1432
+ t,
1433
+ form,
1434
+ post,
1435
+ onStatusMessage,
1436
+ onReload,
1437
+ onClose
1438
+ }) => {
1439
+ const [editCategory, setEditCategory] = React__namespace.useState(
1440
+ form.category || "contact"
1441
+ );
1442
+ const [editDepartment, setEditDepartment] = React__namespace.useState(
1443
+ form.settings?.department || "general"
1444
+ );
1445
+ const [editPriority, setEditPriority] = React__namespace.useState(
1446
+ form.settings?.defaultPriority || "normal"
1447
+ );
1448
+ const [editBookingBridge, setEditBookingBridge] = React__namespace.useState(
1449
+ Boolean(form.settings?.enableBookingBridge)
1450
+ );
1451
+ const [editCertBridge, setEditCertBridge] = React__namespace.useState(
1452
+ Boolean(form.settings?.enableCertificateBridge)
1453
+ );
1454
+ const [editChecklistItems, setEditChecklistItems] = React__namespace.useState(form.checklistTemplate || []);
1455
+ const [newChecklistLabel, setNewChecklistLabel] = React__namespace.useState("");
1456
+ const [activeLocale, setActiveLocale] = React__namespace.useState("es");
1457
+ const [translations, setTranslations] = React__namespace.useState(form.translations || {});
1458
+ React__namespace.useEffect(() => {
1459
+ setEditCategory(form.category || "contact");
1460
+ setEditDepartment(form.settings?.department || "general");
1461
+ setEditPriority(form.settings?.defaultPriority || "normal");
1462
+ setEditBookingBridge(Boolean(form.settings?.enableBookingBridge));
1463
+ setEditCertBridge(Boolean(form.settings?.enableCertificateBridge));
1464
+ setEditChecklistItems(form.checklistTemplate || []);
1465
+ setTranslations(form.translations || {});
1466
+ setNewChecklistLabel("");
1467
+ }, [form]);
1468
+ const updateTranslationField = (key, value) => {
1469
+ setTranslations((prev) => ({
1470
+ ...prev,
1471
+ [activeLocale]: {
1472
+ ...prev[activeLocale],
1473
+ [key]: value
1474
+ }
1475
+ }));
1476
+ };
1477
+ const handleAddChecklistItem = () => {
1478
+ const trimmed = newChecklistLabel.trim();
1479
+ if (!trimmed) return;
1480
+ setEditChecklistItems([
1481
+ ...editChecklistItems,
1482
+ {
1483
+ id: `chk_${Date.now()}`,
1484
+ label: trimmed,
1485
+ required: true,
1486
+ verified: false,
1487
+ localizedLabels: {
1488
+ [activeLocale]: trimmed
1489
+ }
1490
+ }
1491
+ ]);
1492
+ setNewChecklistLabel("");
1493
+ };
1494
+ const handleUpdateChecklistItemLabel = (id, value) => {
1495
+ setEditChecklistItems(
1496
+ (prev) => prev.map((item) => {
1497
+ if (item.id !== id) return item;
1498
+ return {
1499
+ ...item,
1500
+ label: activeLocale === "es" || !item.label ? value : item.label,
1501
+ localizedLabels: {
1502
+ ...item.localizedLabels,
1503
+ [activeLocale]: value
1504
+ }
1505
+ };
1506
+ })
1507
+ );
1508
+ };
1509
+ const handleRemoveChecklistItem = (id) => {
1510
+ setEditChecklistItems(editChecklistItems.filter((item) => item.id !== id));
1511
+ };
1512
+ const handleSave = async () => {
1513
+ await post(`/${index.PLUGIN_ID}/forms`, {
1514
+ ...form,
1515
+ category: editCategory,
1516
+ checklistTemplate: editChecklistItems,
1517
+ translations,
1518
+ settings: {
1519
+ ...form.settings,
1520
+ department: editDepartment,
1521
+ defaultPriority: editPriority,
1522
+ enableBookingBridge: editBookingBridge,
1523
+ enableCertificateBridge: editCertBridge
1524
+ }
1525
+ });
1526
+ onStatusMessage(
1527
+ `Saved routing, checklist & translations (es/en/ar) on Form Builder form "${form.title}"`
1528
+ );
1529
+ onClose();
1530
+ await onReload();
1531
+ };
1532
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1533
+ designSystem.Box,
1534
+ {
1535
+ padding: 5,
1536
+ marginBottom: 5,
1537
+ background: "neutral0",
1538
+ hasRadius: true,
1539
+ shadow: "filterShadow",
1540
+ style: { border: "1px solid rgba(128, 128, 128, 0.22)" },
1541
+ children: [
1542
+ /* @__PURE__ */ jsxRuntime.jsxs(
1543
+ designSystem.Flex,
1544
+ {
1545
+ justifyContent: "space-between",
1546
+ alignItems: "center",
1547
+ paddingBottom: 4,
1548
+ wrap: "wrap",
1549
+ gap: 2,
1550
+ children: [
1551
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
1552
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "delta", tag: "h3", fontWeight: "bold", children: [
1553
+ t(
1554
+ "page.ui.routing_checklist_localization",
1555
+ "Routing, Checklist & Localization"
1556
+ ),
1557
+ " ",
1558
+ "— ",
1559
+ form.slug
1560
+ ] }),
1561
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
1562
+ "page.ui.routing_drawer_subtitle",
1563
+ "Stored directly on Form Builder CMS (`settings.inbox`). Configure casework routing, document checklist, and es/en/ar translations."
1564
+ ) })
1565
+ ] }),
1566
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
1567
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "tertiary", onClick: onClose, children: t("page.ui.close", "Close") }),
1568
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", onClick: handleSave, children: t("page.ui.save_form_config", "Save Form Config") })
1569
+ ] })
1570
+ ]
1571
+ }
1572
+ ),
1573
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", children: [
1574
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 200px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "editCategory", children: [
1575
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.workflow_category", "Workflow Category") }),
1576
+ /* @__PURE__ */ jsxRuntime.jsx(
1577
+ designSystem.SingleSelect,
1578
+ {
1579
+ value: editCategory,
1580
+ onChange: (val) => setEditCategory(String(val)),
1581
+ children: index.FORM_CATEGORIES.map((cat) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: cat, children: cat }, cat))
1582
+ }
1583
+ )
1584
+ ] }) }),
1585
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 200px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "editDepartment", children: [
1586
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.target_department", "Target Department") }),
1587
+ /* @__PURE__ */ jsxRuntime.jsx(
1588
+ designSystem.TextInput,
1589
+ {
1590
+ name: "editDepartment",
1591
+ value: editDepartment,
1592
+ onChange: (e) => setEditDepartment(e.target.value),
1593
+ placeholder: t(
1594
+ "placeholder.target_department",
1595
+ "e.g., imamate, nikah_family, general"
1596
+ )
1597
+ }
1598
+ )
1599
+ ] }) }),
1600
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 200px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "editPriority", children: [
1601
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.default_priority", "Default Priority") }),
1602
+ /* @__PURE__ */ jsxRuntime.jsx(
1603
+ designSystem.SingleSelect,
1604
+ {
1605
+ value: editPriority,
1606
+ onChange: (val) => setEditPriority(String(val)),
1607
+ children: index.SUBMISSION_PRIORITIES.map((pr) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: pr, children: pr }, pr))
1608
+ }
1609
+ )
1610
+ ] }) })
1611
+ ] }),
1612
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 6, paddingTop: 4, paddingBottom: 4, wrap: "wrap", children: [
1613
+ /* @__PURE__ */ jsxRuntime.jsx(
1614
+ designSystem.Checkbox,
1615
+ {
1616
+ checked: editBookingBridge,
1617
+ onCheckedChange: (checked) => setEditBookingBridge(Boolean(checked)),
1618
+ children: t(
1619
+ "checkbox.enable_1_click_booking",
1620
+ "Enable 1-Click Appointment Booking"
1621
+ )
1622
+ }
1623
+ ),
1624
+ /* @__PURE__ */ jsxRuntime.jsx(
1625
+ designSystem.Checkbox,
1626
+ {
1627
+ checked: editCertBridge,
1628
+ onCheckedChange: (checked) => setEditCertBridge(Boolean(checked)),
1629
+ children: t(
1630
+ "checkbox.enable_1_click_certificate",
1631
+ "Enable 1-Click Certificate Issuance"
1632
+ )
1633
+ }
1634
+ )
1635
+ ] }),
1636
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
1637
+ /* @__PURE__ */ jsxRuntime.jsx(
1638
+ FormChecklistAndLocalePanels,
1639
+ {
1640
+ t,
1641
+ checklistItems: editChecklistItems,
1642
+ newChecklistLabel,
1643
+ onNewChecklistLabelChange: setNewChecklistLabel,
1644
+ onAddChecklistItem: handleAddChecklistItem,
1645
+ onRemoveChecklistItem: handleRemoveChecklistItem,
1646
+ onUpdateChecklistItemLabel: handleUpdateChecklistItemLabel,
1647
+ activeLocale,
1648
+ onActiveLocaleChange: setActiveLocale,
1649
+ translations,
1650
+ onUpdateTranslationField: updateTranslationField
1651
+ }
1652
+ )
1653
+ ]
1654
+ }
1655
+ );
1656
+ };
1657
+ const drawerCardStyle = {
1658
+ border: "1px solid rgba(128, 128, 128, 0.22)"
1659
+ };
1660
+ const FormBuilderTab = ({
1661
+ t,
1662
+ forms,
1663
+ post,
1664
+ onStatusMessage,
1665
+ onReload
1666
+ }) => {
1667
+ const navigate = reactRouterDom.useNavigate();
1668
+ const [editingFormSlug, setEditingFormSlug] = React__namespace.useState(
1669
+ null
1670
+ );
1671
+ const [showTemplates, setShowTemplates] = React__namespace.useState(false);
1672
+ const selectedForm = React__namespace.useMemo(
1673
+ () => forms.find((f) => f.slug === editingFormSlug) || null,
1674
+ [forms, editingFormSlug]
1675
+ );
1676
+ const handleCreateTemplate = async (templateId) => {
1677
+ await post(`/${index.PLUGIN_ID}/forms/from-template`, { templateId });
1678
+ onStatusMessage(`Created form from "${templateId}" in Visual Form Builder`);
1679
+ setShowTemplates(false);
1680
+ await onReload();
1681
+ };
1682
+ const handleSyncFormBuilder = async () => {
1683
+ const res = await post(`/${index.PLUGIN_ID}/forms/sync-builder`, {});
1684
+ const info = res?.data?.data;
1685
+ onStatusMessage(
1686
+ `Refreshed Visual Form Builder (${info?.forms?.length ?? 0} forms)`
1687
+ );
1688
+ await onReload();
1689
+ };
1690
+ const handleOpenInVisualBuilder = async (form) => {
1691
+ if (form.formBuilderId) {
1692
+ navigate(
1693
+ `/plugins/${index.FORM_BUILDER_CMS_PLUGIN_ID}/builder/${form.formBuilderId}`
1694
+ );
1695
+ return;
1696
+ }
1697
+ const res = await post(`/${index.PLUGIN_ID}/forms/sync-builder`, {});
1698
+ const syncedForms = res?.data?.data?.forms || [];
1699
+ const matched = syncedForms.find((f) => f.slug === form.slug);
1700
+ if (matched?.formBuilderId) {
1701
+ navigate(
1702
+ `/plugins/${index.FORM_BUILDER_CMS_PLUGIN_ID}/builder/${matched.formBuilderId}`
1703
+ );
1704
+ } else {
1705
+ navigate(`/plugins/${index.FORM_BUILDER_CMS_PLUGIN_ID}`);
1706
+ }
1707
+ };
1708
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingTop: 5, children: [
1709
+ /* @__PURE__ */ jsxRuntime.jsxs(
1710
+ designSystem.Flex,
1711
+ {
1712
+ justifyContent: "space-between",
1713
+ alignItems: "center",
1714
+ paddingBottom: 4,
1715
+ wrap: "wrap",
1716
+ gap: 3,
1717
+ children: [
1718
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", wrap: "wrap", children: [
1719
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", children: t("page.ui.active_forms", "Forms & Service-Desk Workflows") }),
1720
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: t("page.ui.formcraft_visual_builder", "FormCraft Visual Builder") })
1721
+ ] }),
1722
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
1723
+ /* @__PURE__ */ jsxRuntime.jsx(
1724
+ designSystem.Button,
1725
+ {
1726
+ variant: "tertiary",
1727
+ size: "S",
1728
+ onClick: () => setShowTemplates(!showTemplates),
1729
+ children: showTemplates ? t("page.ui.hide_templates", "Hide Templates") : t("page.ui.starter_templates", "Starter Templates")
1730
+ }
1731
+ ),
1732
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", size: "S", onClick: handleSyncFormBuilder, children: t("page.ui.sync_form_builder", "Refresh Forms") }),
1733
+ /* @__PURE__ */ jsxRuntime.jsx(
1734
+ designSystem.Button,
1735
+ {
1736
+ variant: "default",
1737
+ size: "S",
1738
+ onClick: () => navigate(`/plugins/${index.FORM_BUILDER_CMS_PLUGIN_ID}/builder/new`),
1739
+ children: t("page.ui.new_visual_form", "+ New Visual Form")
1740
+ }
1741
+ )
1742
+ ] })
1743
+ ]
1744
+ }
1745
+ ),
1746
+ showTemplates ? /* @__PURE__ */ jsxRuntime.jsx(
1747
+ designSystem.Box,
1748
+ {
1749
+ padding: 4,
1750
+ marginBottom: 4,
1751
+ background: "neutral100",
1752
+ hasRadius: true,
1753
+ style: drawerCardStyle,
1754
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1755
+ designSystem.Flex,
1756
+ {
1757
+ justifyContent: "space-between",
1758
+ alignItems: "center",
1759
+ wrap: "wrap",
1760
+ gap: 3,
1761
+ children: [
1762
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
1763
+ "page.ui.seed_starter_form_hint",
1764
+ "Quickly seed a pre-configured multilingual mosque form:"
1765
+ ) }),
1766
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", children: STARTER_FORM_TEMPLATES.map((tpl) => /* @__PURE__ */ jsxRuntime.jsxs(
1767
+ designSystem.Button,
1768
+ {
1769
+ size: "S",
1770
+ variant: "secondary",
1771
+ onClick: () => handleCreateTemplate(tpl.id),
1772
+ children: [
1773
+ "+ ",
1774
+ tpl.name
1775
+ ]
1776
+ },
1777
+ tpl.id
1778
+ )) })
1779
+ ]
1780
+ }
1781
+ )
1782
+ }
1783
+ ) : null,
1784
+ selectedForm ? /* @__PURE__ */ jsxRuntime.jsx(
1785
+ FormRoutingDrawer,
1786
+ {
1787
+ t,
1788
+ form: selectedForm,
1789
+ post,
1790
+ onStatusMessage,
1791
+ onReload,
1792
+ onClose: () => setEditingFormSlug(null)
1793
+ }
1794
+ ) : null,
1795
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 6, rowCount: forms.length + 1, children: [
1796
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
1797
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.title", "Form") }) }),
1798
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.category", "Category & Dept") }) }),
1799
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.fields", "Fields & Locales") }) }),
1800
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.checklist", "Checklist") }) }),
1801
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.submissions", "Submissions") }) }),
1802
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.actions", "Actions") }) })
1803
+ ] }) }),
1804
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: forms.map((form) => {
1805
+ const localeKeys = Object.keys(form.translations || {});
1806
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
1807
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
1808
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: form.title }),
1809
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: [
1810
+ "/",
1811
+ form.slug
1812
+ ] })
1813
+ ] }) }),
1814
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
1815
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: form.category }),
1816
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: form.settings?.department || "general" })
1817
+ ] }) }),
1818
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
1819
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { children: [
1820
+ (form.fields || []).length,
1821
+ " ",
1822
+ t("page.ui.fields_label", "fields")
1823
+ ] }),
1824
+ localeKeys.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: [
1825
+ t("page.ui.locales_label", "Locales"),
1826
+ ":",
1827
+ " ",
1828
+ localeKeys.join(", ").toUpperCase()
1829
+ ] }) : null
1830
+ ] }) }),
1831
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: (form.checklistTemplate || []).length }) }),
1832
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: form.submissionCount || 0 }) }),
1833
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
1834
+ /* @__PURE__ */ jsxRuntime.jsx(
1835
+ designSystem.Button,
1836
+ {
1837
+ size: "S",
1838
+ variant: "secondary",
1839
+ onClick: () => handleOpenInVisualBuilder(form),
1840
+ children: t(
1841
+ "page.ui.design_fields",
1842
+ "Design Fields (Drag & Drop)"
1843
+ )
1844
+ }
1845
+ ),
1846
+ /* @__PURE__ */ jsxRuntime.jsx(
1847
+ designSystem.Button,
1848
+ {
1849
+ size: "S",
1850
+ variant: editingFormSlug === form.slug ? "default" : "tertiary",
1851
+ onClick: () => setEditingFormSlug(
1852
+ editingFormSlug === form.slug ? null : form.slug
1853
+ ),
1854
+ children: t(
1855
+ "page.ui.casework_checklist",
1856
+ "Routing, Checklist & i18n"
1857
+ )
1858
+ }
1859
+ )
1860
+ ] }) })
1861
+ ] }, form.slug);
1862
+ }) })
1863
+ ] })
1864
+ ] });
1865
+ };
1866
+ const cardBorderStyle = {
1867
+ border: "1px solid rgba(128, 128, 128, 0.2)"
1868
+ };
1869
+ const SubscribersTab = ({
1870
+ t,
1871
+ subscribers,
1872
+ post,
1873
+ onStatusMessage,
1874
+ onReload
1875
+ }) => {
1876
+ const [showAddForm, setShowAddForm] = React__namespace.useState(false);
1877
+ const [newSubEmail, setNewSubEmail] = React__namespace.useState("");
1878
+ const [newSubName, setNewSubName] = React__namespace.useState("");
1879
+ const [newSubLocale, setNewSubLocale] = React__namespace.useState("es");
1880
+ const [newSubTopics, setNewSubTopics] = React__namespace.useState([
1881
+ "announcements",
1882
+ "events"
1883
+ ]);
1884
+ const handleAddSubscriber = async () => {
1885
+ if (!newSubEmail.trim()) return;
1886
+ await post(`/api/${index.PLUGIN_ID}/subscribers`, {
1887
+ email: newSubEmail.trim(),
1888
+ fullName: newSubName.trim(),
1889
+ locale: newSubLocale,
1890
+ topics: newSubTopics.length > 0 ? newSubTopics : ["announcements"]
1891
+ });
1892
+ setNewSubEmail("");
1893
+ setNewSubName("");
1894
+ setShowAddForm(false);
1895
+ onStatusMessage(`Subscriber "${newSubEmail.trim()}" added`);
1896
+ await onReload();
1897
+ };
1898
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingTop: 5, children: [
1899
+ /* @__PURE__ */ jsxRuntime.jsxs(
1900
+ designSystem.Flex,
1901
+ {
1902
+ justifyContent: "space-between",
1903
+ alignItems: "center",
1904
+ paddingBottom: 4,
1905
+ wrap: "wrap",
1906
+ gap: 3,
1907
+ children: [
1908
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", children: t("page.ui.subscribers_list", "Community Subscribers") }),
1909
+ /* @__PURE__ */ jsxRuntime.jsx(
1910
+ designSystem.Button,
1911
+ {
1912
+ size: "S",
1913
+ variant: showAddForm ? "tertiary" : "default",
1914
+ onClick: () => setShowAddForm(!showAddForm),
1915
+ children: showAddForm ? t("page.ui.cancel", "Cancel") : t("page.ui.add_subscriber", "+ Add Subscriber")
1916
+ }
1917
+ )
1918
+ ]
1919
+ }
1920
+ ),
1921
+ showAddForm ? /* @__PURE__ */ jsxRuntime.jsx(
1922
+ designSystem.Box,
1923
+ {
1924
+ padding: 5,
1925
+ marginBottom: 5,
1926
+ background: "neutral0",
1927
+ hasRadius: true,
1928
+ shadow: "filterShadow",
1929
+ style: cardBorderStyle,
1930
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1931
+ designSystem.Box,
1932
+ {
1933
+ style: {
1934
+ display: "grid",
1935
+ gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))",
1936
+ gap: 16,
1937
+ alignItems: "end"
1938
+ },
1939
+ children: [
1940
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "newSubEmail", required: true, children: [
1941
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.subscriber_email", "Email") }),
1942
+ /* @__PURE__ */ jsxRuntime.jsx(
1943
+ designSystem.TextInput,
1944
+ {
1945
+ name: "newSubEmail",
1946
+ type: "email",
1947
+ placeholder: t(
1948
+ "placeholder.subscriber_email",
1949
+ "fatima@example.org"
1950
+ ),
1951
+ value: newSubEmail,
1952
+ onChange: (e) => setNewSubEmail(e.target.value)
1953
+ }
1954
+ )
1955
+ ] }),
1956
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "newSubName", children: [
1957
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.full_name", "Full Name") }),
1958
+ /* @__PURE__ */ jsxRuntime.jsx(
1959
+ designSystem.TextInput,
1960
+ {
1961
+ name: "newSubName",
1962
+ placeholder: t("placeholder.subscriber_name", "Fatima Zahra"),
1963
+ value: newSubName,
1964
+ onChange: (e) => setNewSubName(e.target.value)
1965
+ }
1966
+ )
1967
+ ] }),
1968
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "newSubLocale", children: [
1969
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.preferred_locale", "Locale") }),
1970
+ /* @__PURE__ */ jsxRuntime.jsx(
1971
+ designSystem.SingleSelect,
1972
+ {
1973
+ value: newSubLocale,
1974
+ onChange: (val) => setNewSubLocale(String(val)),
1975
+ children: index.LOCALE_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: opt.value, children: opt.label }, opt.value))
1976
+ }
1977
+ )
1978
+ ] }),
1979
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: "newSubTopics", children: [
1980
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("field.topics", "Topics") }),
1981
+ /* @__PURE__ */ jsxRuntime.jsx(
1982
+ designSystem.MultiSelect,
1983
+ {
1984
+ name: "newSubTopics",
1985
+ withTags: true,
1986
+ placeholder: t(
1987
+ "placeholder.subscriber_topics",
1988
+ "Select topics..."
1989
+ ),
1990
+ value: newSubTopics,
1991
+ onChange: (nextValues) => setNewSubTopics(
1992
+ nextValues.length > 0 ? nextValues : ["announcements"]
1993
+ ),
1994
+ onClear: () => setNewSubTopics(["announcements"]),
1995
+ children: LocalizationRoutingTab.TOPIC_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MultiSelectOption, { value: opt.value, children: opt.label }, opt.value))
1996
+ }
1997
+ )
1998
+ ] }),
1999
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleAddSubscriber, children: t("page.ui.save_subscriber", "Save Subscriber") }) })
2000
+ ]
2001
+ }
2002
+ )
2003
+ }
2004
+ ) : null,
2005
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: subscribers.length + 1, children: [
2006
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
2007
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.email", "Email") }) }),
2008
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.name", "Name") }) }),
2009
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.locale", "Locale") }) }),
2010
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.topics", "Topics") }) }),
2011
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: t("page.ui.status", "Status") }) })
2012
+ ] }) }),
2013
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: subscribers.map((sub) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
2014
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: sub.email }) }),
2015
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: sub.fullName || "-" }) }),
2016
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: sub.locale }) }),
2017
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: (sub.topics || []).join(", ") }) }),
2018
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: sub.status }) })
2019
+ ] }, sub.email)) })
2020
+ ] })
2021
+ ] });
2022
+ };
2023
+ const InboxHomePage = () => {
2024
+ const { formatMessage } = reactIntl.useIntl();
2025
+ const t = (id, defaultMessage) => formatMessage({ id: `${index.PLUGIN_ID}.${id}`, defaultMessage });
2026
+ const { get, post, put } = admin.useFetchClient();
2027
+ const [activeTab, setActiveTab] = React__namespace.useState("submissions");
2028
+ const [forms, setForms] = React__namespace.useState([]);
2029
+ const [submissions, setSubmissions] = React__namespace.useState([]);
2030
+ const [subscribers, setSubscribers] = React__namespace.useState([]);
2031
+ const [alerts, setAlerts] = React__namespace.useState([]);
2032
+ const [statusMessage, setStatusMessage] = React__namespace.useState("");
2033
+ const loadAll = async () => {
2034
+ try {
2035
+ const [formsRes, subsRes, subscRes, alertsRes] = await Promise.all([
2036
+ get(`/${index.PLUGIN_ID}/forms?activeOnly=false&admin=true`),
2037
+ get(`/${index.PLUGIN_ID}/submissions`),
2038
+ get(`/${index.PLUGIN_ID}/subscribers`),
2039
+ get(`/${index.PLUGIN_ID}/alerts`)
2040
+ ]);
2041
+ setForms(formsRes?.data?.data || []);
2042
+ setSubmissions(subsRes?.data?.data || []);
2043
+ setSubscribers(subscRes?.data?.data || []);
2044
+ setAlerts(alertsRes?.data?.data || []);
2045
+ } catch {
2046
+ }
2047
+ };
2048
+ React__namespace.useEffect(() => {
2049
+ void loadAll();
2050
+ }, []);
2051
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Main, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 8, children: [
2052
+ /* @__PURE__ */ jsxRuntime.jsxs(
2053
+ designSystem.Flex,
2054
+ {
2055
+ justifyContent: "space-between",
2056
+ alignItems: "center",
2057
+ paddingBottom: 4,
2058
+ wrap: "wrap",
2059
+ gap: 3,
2060
+ children: [
2061
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
2062
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: t("page.ui.inbox_service_desk", "Inbox & Service Desk") }),
2063
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: t(
2064
+ "page.ui.inbox_service_desk_subtitle",
2065
+ "Casework submissions, visual forms, subscribers, and site-wide alert banners"
2066
+ ) })
2067
+ ] }),
2068
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
2069
+ /* @__PURE__ */ jsxRuntime.jsxs(
2070
+ designSystem.Button,
2071
+ {
2072
+ variant: activeTab === "submissions" ? "default" : "tertiary",
2073
+ onClick: () => setActiveTab("submissions"),
2074
+ children: [
2075
+ t("page.ui.casework_inbox", "Casework Inbox"),
2076
+ " (",
2077
+ submissions.length,
2078
+ ")"
2079
+ ]
2080
+ }
2081
+ ),
2082
+ /* @__PURE__ */ jsxRuntime.jsxs(
2083
+ designSystem.Button,
2084
+ {
2085
+ variant: activeTab === "forms" ? "default" : "tertiary",
2086
+ onClick: () => setActiveTab("forms"),
2087
+ children: [
2088
+ t("page.ui.form_builder", "Form Builder"),
2089
+ " (",
2090
+ forms.length,
2091
+ ")"
2092
+ ]
2093
+ }
2094
+ ),
2095
+ /* @__PURE__ */ jsxRuntime.jsxs(
2096
+ designSystem.Button,
2097
+ {
2098
+ variant: activeTab === "subscribers" ? "default" : "tertiary",
2099
+ onClick: () => setActiveTab("subscribers"),
2100
+ children: [
2101
+ t("page.ui.subscribers", "Subscribers"),
2102
+ " (",
2103
+ subscribers.length,
2104
+ ")"
2105
+ ]
2106
+ }
2107
+ ),
2108
+ /* @__PURE__ */ jsxRuntime.jsxs(
2109
+ designSystem.Button,
2110
+ {
2111
+ variant: activeTab === "alerts" ? "default" : "tertiary",
2112
+ onClick: () => setActiveTab("alerts"),
2113
+ children: [
2114
+ t("page.ui.alert_banners", "Alert Banners"),
2115
+ " (",
2116
+ alerts.length,
2117
+ ")"
2118
+ ]
2119
+ }
2120
+ )
2121
+ ] })
2122
+ ]
2123
+ }
2124
+ ),
2125
+ statusMessage ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, marginBottom: 4, background: "success100", hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success700", fontWeight: "semiBold", children: statusMessage }) }) : null,
2126
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
2127
+ activeTab === "submissions" && /* @__PURE__ */ jsxRuntime.jsx(
2128
+ CaseworkSubmissionsTab,
2129
+ {
2130
+ t,
2131
+ submissions,
2132
+ forms,
2133
+ post,
2134
+ put,
2135
+ onStatusMessage: setStatusMessage,
2136
+ onReload: loadAll
2137
+ }
2138
+ ),
2139
+ activeTab === "forms" && /* @__PURE__ */ jsxRuntime.jsx(
2140
+ FormBuilderTab,
2141
+ {
2142
+ t,
2143
+ forms,
2144
+ post,
2145
+ onStatusMessage: setStatusMessage,
2146
+ onReload: loadAll
2147
+ }
2148
+ ),
2149
+ activeTab === "subscribers" && /* @__PURE__ */ jsxRuntime.jsx(
2150
+ SubscribersTab,
2151
+ {
2152
+ t,
2153
+ subscribers,
2154
+ post,
2155
+ onStatusMessage: setStatusMessage,
2156
+ onReload: loadAll
2157
+ }
2158
+ ),
2159
+ activeTab === "alerts" && /* @__PURE__ */ jsxRuntime.jsx(
2160
+ AlertBannersTab,
2161
+ {
2162
+ t,
2163
+ alerts,
2164
+ post,
2165
+ onStatusMessage: setStatusMessage,
2166
+ onReload: loadAll
2167
+ }
2168
+ )
2169
+ ] }) });
2170
+ };
2171
+ exports.InboxHomePage = InboxHomePage;