@argusoft/medplat-core 1.0.29 → 1.0.31

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 (217) hide show
  1. package/dist/AccessRights-DUgY6ewy.js +1031 -0
  2. package/dist/AccessRights-DUgY6ewy.js.map +1 -0
  3. package/dist/AddEditQueryBuilder-D-iQiVIe.js +365 -0
  4. package/dist/AddEditQueryBuilder-D-iQiVIe.js.map +1 -0
  5. package/dist/{AddFeatures-v3TmGQee.js → AddFeatures-D1sU8RjY.js} +2 -2
  6. package/dist/{AddFeatures-v3TmGQee.js.map → AddFeatures-D1sU8RjY.js.map} +1 -1
  7. package/dist/AddLabelModal-Bq-wRqv9.js +631 -0
  8. package/dist/AddLabelModal-Bq-wRqv9.js.map +1 -0
  9. package/dist/AddMenuConfiguration-c6ZKiN0i.js +8898 -0
  10. package/dist/AddMenuConfiguration-c6ZKiN0i.js.map +1 -0
  11. package/dist/AppModal-CCtrQ5Tr.js +394 -0
  12. package/dist/AppModal-CCtrQ5Tr.js.map +1 -0
  13. package/dist/BrandsPage-DMw2vT0u-BVhvhc6J.js +387 -0
  14. package/dist/BrandsPage-DMw2vT0u-BVhvhc6J.js.map +1 -0
  15. package/dist/CategoriesPage-D3ihx9Gi-CT58g0ry.js +398 -0
  16. package/dist/CategoriesPage-D3ihx9Gi-CT58g0ry.js.map +1 -0
  17. package/dist/{ChangePasswordModalCore-DutQAZOx.js → ChangePasswordModalCore-lQ9GamH1.js} +1605 -1610
  18. package/dist/ChangePasswordModalCore-lQ9GamH1.js.map +1 -0
  19. package/dist/ConditionConfig-BQBmBHaM.js +408 -0
  20. package/dist/ConditionConfig-BQBmBHaM.js.map +1 -0
  21. package/dist/DashboardPage-asr2XDRu-uOOlX9Vq.js +435 -0
  22. package/dist/DashboardPage-asr2XDRu-uOOlX9Vq.js.map +1 -0
  23. package/dist/EventConfig-BY2cgGyx.js +27 -0
  24. package/dist/EventConfig-BY2cgGyx.js.map +1 -0
  25. package/dist/EventConfigurations-CUPEN5BV.js +544 -0
  26. package/dist/EventConfigurations-CUPEN5BV.js.map +1 -0
  27. package/dist/EventConfigurations.css +1 -1
  28. package/dist/EventsExceptionModal-BX-ArkBE.js +188 -0
  29. package/dist/EventsExceptionModal-BX-ArkBE.js.map +1 -0
  30. package/dist/EventsUi-D6O9S7BK.js +258 -0
  31. package/dist/EventsUi-D6O9S7BK.js.map +1 -0
  32. package/dist/FacilityPicker-DYl_PDyt-Cbwo2tAY.js +79 -0
  33. package/dist/FacilityPicker-DYl_PDyt-Cbwo2tAY.js.map +1 -0
  34. package/dist/FeatureMenu-CHsBbw3W.js +525 -0
  35. package/dist/FeatureMenu-CHsBbw3W.js.map +1 -0
  36. package/dist/{FhirServerList-Dkq7Kbes.js → FhirServerList-iXBPkRVF.js} +22 -22
  37. package/dist/{FhirServerList-Dkq7Kbes.js.map → FhirServerList-iXBPkRVF.js.map} +1 -1
  38. package/dist/{FhirServerWizard-Db6Hm4bQ.js → FhirServerWizard-DZI8Olku.js} +15 -15
  39. package/dist/{FhirServerWizard-Db6Hm4bQ.js.map → FhirServerWizard-DZI8Olku.js.map} +1 -1
  40. package/dist/FlywayQuery-CQygj51V.js +179 -0
  41. package/dist/FlywayQuery-CQygj51V.js.map +1 -0
  42. package/dist/GrantPermissionModal-D7iNZd0M.js +239 -0
  43. package/dist/GrantPermissionModal-D7iNZd0M.js.map +1 -0
  44. package/dist/ImmunizationConfigurationBase-aUtx0JEe.js +8019 -0
  45. package/dist/ImmunizationConfigurationBase-aUtx0JEe.js.map +1 -0
  46. package/dist/ImmunizationConfigurationBase.css +1 -1
  47. package/dist/ImmunizationConfigurationsList-TZcLDEci.js +369 -0
  48. package/dist/ImmunizationConfigurationsList-TZcLDEci.js.map +1 -0
  49. package/dist/InventoryPage-DOotGZrj-CoPjOJEI.js +665 -0
  50. package/dist/InventoryPage-DOotGZrj-CoPjOJEI.js.map +1 -0
  51. package/dist/LanguagesModal-B3NTebYT.js +352 -0
  52. package/dist/LanguagesModal-B3NTebYT.js.map +1 -0
  53. package/dist/ManageDynamicFeature-BU0I45dd.js +4475 -0
  54. package/dist/ManageDynamicFeature-BU0I45dd.js.map +1 -0
  55. package/dist/ManageEventConfiguration-DqW3krT6.js +1216 -0
  56. package/dist/ManageEventConfiguration-DqW3krT6.js.map +1 -0
  57. package/dist/ManageEventConfiguration.css +1 -1
  58. package/dist/{ManageNotification-CfhHlfxA.js → ManageNotification-C5MhV77Q.js} +2 -2
  59. package/dist/{ManageNotification-CfhHlfxA.js.map → ManageNotification-C5MhV77Q.js.map} +1 -1
  60. package/dist/{ManageRole-4Y2PP4dQ.js → ManageRole-CNZBRKGU.js} +2 -2
  61. package/dist/{ManageRole-4Y2PP4dQ.js.map → ManageRole-CNZBRKGU.js.map} +1 -1
  62. package/dist/ManageTranslation-vRiptUAP.js +833 -0
  63. package/dist/ManageTranslation-vRiptUAP.js.map +1 -0
  64. package/dist/ManageTranslation.css +1 -1
  65. package/dist/{ManageUser-DDzyd9jm.js → ManageUser-DZltBina.js} +224 -224
  66. package/dist/{ManageUser-DDzyd9jm.js.map → ManageUser-DZltBina.js.map} +1 -1
  67. package/dist/MemberProfileCard-D5CgkTdJ-D2NgDJl3.js +272 -0
  68. package/dist/MemberProfileCard-D5CgkTdJ-D2NgDJl3.js.map +1 -0
  69. package/dist/MobileAnalytics-BLOionG_.js +17301 -0
  70. package/dist/MobileAnalytics-BLOionG_.js.map +1 -0
  71. package/dist/MobileMenuManagement-68Wijb0X.js +220 -0
  72. package/dist/MobileMenuManagement-68Wijb0X.js.map +1 -0
  73. package/dist/MobileTypeEventConfigModal-CMcj7Ozp.js +752 -0
  74. package/dist/MobileTypeEventConfigModal-CMcj7Ozp.js.map +1 -0
  75. package/dist/NotificationFlywayQuery-BAHVjf6N.js +247 -0
  76. package/dist/NotificationFlywayQuery-BAHVjf6N.js.map +1 -0
  77. package/dist/{NotificationList-BMFpNUJG.js → NotificationList-DEyRZEuM.js} +2 -2
  78. package/dist/{NotificationList-BMFpNUJG.js.map → NotificationList-DEyRZEuM.js.map} +1 -1
  79. package/dist/OtherTypeEventConfigModal-stNmuSv_.js +1812 -0
  80. package/dist/OtherTypeEventConfigModal-stNmuSv_.js.map +1 -0
  81. package/dist/PaymentCreatePage-DfvSZ-kB-CckogYoe.js +482 -0
  82. package/dist/PaymentCreatePage-DfvSZ-kB-CckogYoe.js.map +1 -0
  83. package/dist/PaymentsPage-DMNjYWAJ-ChO9IXmk.js +157 -0
  84. package/dist/PaymentsPage-DMNjYWAJ-ChO9IXmk.js.map +1 -0
  85. package/dist/PermissionsModal-CCYkcKlC.js +151 -0
  86. package/dist/PermissionsModal-CCYkcKlC.js.map +1 -0
  87. package/dist/PickupBatchLinesEditor-CE2RuyJT-BPceiJr8.js +119 -0
  88. package/dist/PickupBatchLinesEditor-CE2RuyJT-BPceiJr8.js.map +1 -0
  89. package/dist/PickupCreatePage-B4O_-vE5-DoOo9nJO.js +783 -0
  90. package/dist/PickupCreatePage-B4O_-vE5-DoOo9nJO.js.map +1 -0
  91. package/dist/PickupsPage-D7zyioJB-bHKnARYw.js +818 -0
  92. package/dist/PickupsPage-D7zyioJB-bHKnARYw.js.map +1 -0
  93. package/dist/PmGuard-BZE-y4In-D_pUm5MP.js +599 -0
  94. package/dist/PmGuard-BZE-y4In-D_pUm5MP.js.map +1 -0
  95. package/dist/ProductEditPage-BVlVUCtD-BR-tJ5Wb.js +1305 -0
  96. package/dist/ProductEditPage-BVlVUCtD-BR-tJ5Wb.js.map +1 -0
  97. package/dist/ProductsPage-DvNHIeZt-BoOOJJtk.js +253 -0
  98. package/dist/ProductsPage-DvNHIeZt-BoOOJJtk.js.map +1 -0
  99. package/dist/PurchaseCreatePage-Cq_i9snz-DRtHHFWw.js +675 -0
  100. package/dist/PurchaseCreatePage-Cq_i9snz-DRtHHFWw.js.map +1 -0
  101. package/dist/PurchaseRequestDetailPage-CA9KFOfE-CtjG4Gx6.js +1577 -0
  102. package/dist/PurchaseRequestDetailPage-CA9KFOfE-CtjG4Gx6.js.map +1 -0
  103. package/dist/PurchaseRequestsPage-DS9i4o0--TpoxA5Kd.js +279 -0
  104. package/dist/PurchaseRequestsPage-DS9i4o0--TpoxA5Kd.js.map +1 -0
  105. package/dist/PurchasesPage-DgL5T6BY-DePUuE9l.js +293 -0
  106. package/dist/PurchasesPage-DgL5T6BY-DePUuE9l.js.map +1 -0
  107. package/dist/QueryBuilder-CXaBe6sr.js +478 -0
  108. package/dist/QueryBuilder-CXaBe6sr.js.map +1 -0
  109. package/dist/{RoleManagement-DEiBNfT8.js → RoleManagement-s8iNx2Mu.js} +145 -155
  110. package/dist/RoleManagement-s8iNx2Mu.js.map +1 -0
  111. package/dist/Roles-BIyiic67.js +14 -0
  112. package/dist/Roles-BIyiic67.js.map +1 -0
  113. package/dist/SaleCreatePage-CZnIOydv-DKBw-qp7.js +544 -0
  114. package/dist/SaleCreatePage-CZnIOydv-DKBw-qp7.js.map +1 -0
  115. package/dist/SalesPage-DPIRrC_O-M8rqnK7z.js +315 -0
  116. package/dist/SalesPage-DPIRrC_O-M8rqnK7z.js.map +1 -0
  117. package/dist/SettingsPage-BC_R6Z-Q-CKNt9zRu.js +676 -0
  118. package/dist/SettingsPage-BC_R6Z-Q-CKNt9zRu.js.map +1 -0
  119. package/dist/ShowFlywayQuery-D10Olk5Z.js +154 -0
  120. package/dist/ShowFlywayQuery-D10Olk5Z.js.map +1 -0
  121. package/dist/{ShowFlywayQuery-DVRCd384.js → ShowFlywayQuery-DIOUdYfG.js} +170 -123
  122. package/dist/ShowFlywayQuery-DIOUdYfG.js.map +1 -0
  123. package/dist/ShowQueryHistory-DRBKYDKk.js +313 -0
  124. package/dist/ShowQueryHistory-DRBKYDKk.js.map +1 -0
  125. package/dist/StorageUnitsPage-BDRkdCjW-UF64rf7q.js +728 -0
  126. package/dist/StorageUnitsPage-BDRkdCjW-UF64rf7q.js.map +1 -0
  127. package/dist/SubMenu-BdMTYtC1.js +319 -0
  128. package/dist/SubMenu-BdMTYtC1.js.map +1 -0
  129. package/dist/TransactionsPage-CqWTMNU8-Df6eGFDW.js +746 -0
  130. package/dist/TransactionsPage-CqWTMNU8-Df6eGFDW.js.map +1 -0
  131. package/dist/TransferCreatePage-DF7FZaTJ-CL79V3aR.js +315 -0
  132. package/dist/TransferCreatePage-DF7FZaTJ-CL79V3aR.js.map +1 -0
  133. package/dist/TransfersPage-CGrRFaBF-cTwBUv0o.js +476 -0
  134. package/dist/TransfersPage-CGrRFaBF-cTwBUv0o.js.map +1 -0
  135. package/dist/TypeConfiguration-JbRCN6GR.js +114 -0
  136. package/dist/TypeConfiguration-JbRCN6GR.js.map +1 -0
  137. package/dist/{UserList-Bc8gYxRL.js → UserList-L41Xw0Q6.js} +253 -236
  138. package/dist/{UserList-Bc8gYxRL.js.map → UserList-L41Xw0Q6.js.map} +1 -1
  139. package/dist/Users-CsJ08Kjm.js.map +1 -1
  140. package/dist/VialsPage-rvvXjgZG-Oqo1v6kQ.js +321 -0
  141. package/dist/VialsPage-rvvXjgZG-Oqo1v6kQ.js.map +1 -0
  142. package/dist/constants-DpXnLsAB-D6lN5cjK.js +445 -0
  143. package/dist/constants-DpXnLsAB-D6lN5cjK.js.map +1 -0
  144. package/dist/{dashboardLayoutUtils-D1xCAxp3.js → dashboardLayoutUtils-CJivzaU1.js} +95 -92
  145. package/dist/dashboardLayoutUtils-CJivzaU1.js.map +1 -0
  146. package/dist/format-UOyOu75i-D0GyylyQ.js +63 -0
  147. package/dist/format-UOyOu75i-D0GyylyQ.js.map +1 -0
  148. package/dist/index.css +1 -1
  149. package/dist/index.js +1 -1
  150. package/dist/index.lib-ETRQOzvE.js +894 -0
  151. package/dist/index.lib-ETRQOzvE.js.map +1 -0
  152. package/dist/listValueStore-BFQtDYIR-Bj0yX145.js +36 -0
  153. package/dist/listValueStore-BFQtDYIR-Bj0yX145.js.map +1 -0
  154. package/dist/useFieldErrors-hDG8ox_x-DbSAzrGo.js +28 -0
  155. package/dist/useFieldErrors-hDG8ox_x-DbSAzrGo.js.map +1 -0
  156. package/dist/validation-BzlHnL-r-CCJm2utQ.js +125 -0
  157. package/dist/validation-BzlHnL-r-CCJm2utQ.js.map +1 -0
  158. package/package.json +4 -3
  159. package/dist/AccessRights-Zm8Obm4N.js +0 -1284
  160. package/dist/AccessRights-Zm8Obm4N.js.map +0 -1
  161. package/dist/AddEditQueryBuilder-Brdnm6rQ.js +0 -313
  162. package/dist/AddEditQueryBuilder-Brdnm6rQ.js.map +0 -1
  163. package/dist/AddLabelModal-DFllBVcd.js +0 -734
  164. package/dist/AddLabelModal-DFllBVcd.js.map +0 -1
  165. package/dist/AddMenuConfiguration-Ce91MhnU.js +0 -8547
  166. package/dist/AddMenuConfiguration-Ce91MhnU.js.map +0 -1
  167. package/dist/AppModal-CtG2GjD_.js +0 -428
  168. package/dist/AppModal-CtG2GjD_.js.map +0 -1
  169. package/dist/ChangePasswordModalCore-DutQAZOx.js.map +0 -1
  170. package/dist/ConditionConfig-B4Ffpgj3.js +0 -395
  171. package/dist/ConditionConfig-B4Ffpgj3.js.map +0 -1
  172. package/dist/ConditionConfig.css +0 -1
  173. package/dist/EventConfigurations-BJcURufo.js +0 -449
  174. package/dist/EventConfigurations-BJcURufo.js.map +0 -1
  175. package/dist/EventsExceptionModal-BlZtBQoR.js +0 -200
  176. package/dist/EventsExceptionModal-BlZtBQoR.js.map +0 -1
  177. package/dist/EventsSkeleton-DK6JDKAK.js +0 -83
  178. package/dist/EventsSkeleton-DK6JDKAK.js.map +0 -1
  179. package/dist/FeatureMenu-C3503UIX.js +0 -265
  180. package/dist/FeatureMenu-C3503UIX.js.map +0 -1
  181. package/dist/FlywayQuery-Cx2sly6g.js +0 -169
  182. package/dist/FlywayQuery-Cx2sly6g.js.map +0 -1
  183. package/dist/ImmunizationConfigurationBase-DLQVSNnt.js +0 -5895
  184. package/dist/ImmunizationConfigurationBase-DLQVSNnt.js.map +0 -1
  185. package/dist/ImmunizationConfigurationsList-DdSZicTP.js +0 -344
  186. package/dist/ImmunizationConfigurationsList-DdSZicTP.js.map +0 -1
  187. package/dist/LanguagesModal-D6VfaGrl.js +0 -394
  188. package/dist/LanguagesModal-D6VfaGrl.js.map +0 -1
  189. package/dist/ManageDynamicFeature-dt096fyj.js +0 -4189
  190. package/dist/ManageDynamicFeature-dt096fyj.js.map +0 -1
  191. package/dist/ManageEventConfiguration-BpSJszSX.js +0 -1017
  192. package/dist/ManageEventConfiguration-BpSJszSX.js.map +0 -1
  193. package/dist/ManageTranslation-B4C9-lWD.js +0 -625
  194. package/dist/ManageTranslation-B4C9-lWD.js.map +0 -1
  195. package/dist/MobileMenuManagement-Cf8IZlla.js +0 -108
  196. package/dist/MobileMenuManagement-Cf8IZlla.js.map +0 -1
  197. package/dist/MobileTypeEventConfigModal-DUkUYACe.js +0 -783
  198. package/dist/MobileTypeEventConfigModal-DUkUYACe.js.map +0 -1
  199. package/dist/NotificationFlywayQuery-BY8Zzml_.js +0 -244
  200. package/dist/NotificationFlywayQuery-BY8Zzml_.js.map +0 -1
  201. package/dist/OtherTypeEventConfigModal-CYBfr2XE.js +0 -2046
  202. package/dist/OtherTypeEventConfigModal-CYBfr2XE.js.map +0 -1
  203. package/dist/QueryBuilder-z7eqfd7D.js +0 -383
  204. package/dist/QueryBuilder-z7eqfd7D.js.map +0 -1
  205. package/dist/RoleManagement-DEiBNfT8.js.map +0 -1
  206. package/dist/ShowFlywayQuery-DVRCd384.js.map +0 -1
  207. package/dist/ShowFlywayQuery-tj42YQAS.js +0 -130
  208. package/dist/ShowFlywayQuery-tj42YQAS.js.map +0 -1
  209. package/dist/ShowQueryHistory-BDN0tzHg.js +0 -190
  210. package/dist/ShowQueryHistory-BDN0tzHg.js.map +0 -1
  211. package/dist/SubMenu-B072oEGb.js +0 -191
  212. package/dist/SubMenu-B072oEGb.js.map +0 -1
  213. package/dist/TypeConfiguration-C3xoP2Nb.js +0 -117
  214. package/dist/TypeConfiguration-C3xoP2Nb.js.map +0 -1
  215. package/dist/dashboardLayoutUtils-D1xCAxp3.js.map +0 -1
  216. package/dist/index.lib-C3fwoM3y.js +0 -820
  217. package/dist/index.lib-C3fwoM3y.js.map +0 -1
@@ -1,4189 +0,0 @@
1
- import { jsx as t, jsxs as s, Fragment as fe } from "react/jsx-runtime";
2
- import { executeAll as Ft, execute as G } from "@/common/services/QueryBuilder";
3
- import { useDebounceFn as fn } from "@/hooks/useDebounceFn.js";
4
- import Ve from "@/views/custom-components/CustomDropdown";
5
- import zi from "@/views/custom-components/CustomSvgUpload";
6
- import ne from "@/views/custom-components/CustomTextField";
7
- import { yupResolver as vn } from "@hookform/resolvers/yup";
8
- import { Editor as Li } from "@monaco-editor/react";
9
- import { generateUUID as hn } from "@/utils/UUIDgenerator";
10
- import { getRoleList as $i, executeQuery as Qi } from "@/common/services/GlobalApis";
11
- import { Dialog as Fn, DialogTitle as Tn, DialogContent as _n, DialogContentText as Ji, Grid2 as xe, Divider as Ye, Chip as ot, FormControl as te, TextField as Vn, IconButton as qe, Box as c, Alert as ji, DialogActions as En, Button as U, useTheme as Dn, debounce as Gi, Step as Hi, Typography as f, Accordion as kt, AccordionSummary as It, AccordionDetails as wt, Tooltip as Yi, RadioGroup as pn, FormControlLabel as lt, Radio as dt, Checkbox as gn, FormGroup as Ki, TableContainer as yn, Table as bn, TableHead as xn, TableRow as ct, TableCell as ee, TableBody as Sn, Stack as Pn, Select as Zi, MenuItem as Cn, Modal as Xi, Card as er, alpha as tr } from "@mui/material";
12
- import H from "@mui/material/Grid2";
13
- import { t as ut } from "./i18next-CTOWN_jH.js";
14
- import nr, { useState as x, useRef as ir, useMemo as Nn, useEffect as ae, useCallback as rr } from "react";
15
- import { useForm as ft, Controller as $, useWatch as mt } from "react-hook-form";
16
- import { useSelector as ar } from "react-redux";
17
- import { useLocation as sr, useNavigate as or } from "react-router";
18
- import * as O from "yup";
19
- import { showToast as me } from "@/common/toaster/toaster";
20
- import { FormConfiguratorService as kn } from "@/common/services/FormConfiguratorService";
21
- import I from "prop-types";
22
- import { useDebounceFn as lr } from "@/hooks/useDebounceFn";
23
- import le from "@/common/fontAwesomeIcons/FontAwesomeIcons";
24
- import Ee from "@/views/custom-components/CustomAutoComplete.jsx";
25
- import { a as In, b as dr, u as cr } from "./Features-Dne21RWu.js";
26
- import Ie from "@/views/custom-components/CustomSwitch";
27
- import ur from "@/views/custom-components/CustomTextArea";
28
- import vt from "@/views/custom-components/CustomCheckBox";
29
- import wn from "@/views/custom-components/CustomDatePicker";
30
- import ge from "@/views/custom-components/FieldDescription";
31
- import { useTranslateProvider as mr } from "@/common/languageTranslator/TranslationContext";
32
- import fr from "@/views/custom-components/CustomRadioComponent";
33
- function An({
34
- mainFormCtrl: m,
35
- openAddFormModal: M,
36
- setModal: A,
37
- reloadForms: E
38
- }) {
39
- const [l, b] = x(""), [C, Y] = x([]), [ie, R] = x(!0), W = O.object().shape({
40
- formName: O.string().required("Enter form name"),
41
- formCode: O.string().required("Enter form code").matches(
42
- /^[A-Z_]*$/,
43
- "Only uppercase letters and underscores are allowed"
44
- ),
45
- state: O.string().required("Select state"),
46
- formType: O.string().required("Select form type"),
47
- description: O.string().required("Enter description")
48
- }), v = ft({
49
- defaultValues: {
50
- formName: "",
51
- formCode: "",
52
- state: "ACTIVE",
53
- description: "",
54
- menuConfigId: null,
55
- pageParams: "",
56
- formType: null,
57
- navigationState: "medplat.form"
58
- },
59
- resolver: vn(W),
60
- mode: "onChange"
61
- }), de = () => {
62
- if (l.trim() && !C.includes(l)) {
63
- const N = [...C, l];
64
- Y(N), b(""), v.setValue("pageParams", N.join(","));
65
- }
66
- }, Z = (N) => {
67
- const S = C.filter((D) => D !== N);
68
- Y(S), v.setValue("pageParams", S.join(","));
69
- }, z = (N) => {
70
- const S = N.target.value;
71
- /^[a-zA-Z_]*$/.test(S) && b(S);
72
- }, he = () => {
73
- A(!1);
74
- }, Q = (N) => {
75
- J(N);
76
- }, J = (N) => {
77
- if (!ie) {
78
- me({ message: "Form Code is already taken!", type: "error" });
79
- return;
80
- }
81
- const S = () => {
82
- const D = new FormData();
83
- return D.append(
84
- "form",
85
- new Blob([JSON.stringify(N)], {
86
- type: "application/json"
87
- })
88
- ), console.log(D), D;
89
- };
90
- N.isSeparateFeature = !0, kn.saveForm(S()).then(() => {
91
- me({
92
- message: "Configuration created sucessfully!",
93
- type: "success"
94
- });
95
- let D = [];
96
- N.formName && N.formName.length > 0 && D.push({
97
- code: "medplat_form_insert_into_translation_master",
98
- parameters: {
99
- translation_key: N.formName.replaceAll(" ", ""),
100
- translation_value: N.formName,
101
- form_code: N.formCode
102
- },
103
- sequence: 1
104
- }), D.length > 0 && Ft(D), m.setValue("formCode", N.formCode), m.setValue("version", "DRAFT"), m.setValue("navigationState", N.navigationState), he(), v.reset({
105
- formName: "",
106
- formCode: "",
107
- state: "ACTIVE",
108
- description: "",
109
- menuConfigId: null,
110
- pageParams: "",
111
- formType: null,
112
- navigationState: "medplat.form"
113
- }), E();
114
- });
115
- }, pe = lr(async (N) => {
116
- if (!(N != null && N.trim())) return;
117
- const S = (await kn.checkFormCodeAvailability(N)).data;
118
- return R(S), S;
119
- }, 500);
120
- return /* @__PURE__ */ t(
121
- Fn,
122
- {
123
- open: M,
124
- fullWidth: !0,
125
- maxWidth: "lg",
126
- onClose: he,
127
- slotProps: {
128
- paper: {
129
- style: {
130
- borderRadius: "8px"
131
- }
132
- }
133
- },
134
- children: /* @__PURE__ */ s(
135
- "form",
136
- {
137
- noValidate: !0,
138
- onSubmit: (N) => {
139
- N.preventDefault(), N.stopPropagation(), v.handleSubmit(Q)();
140
- },
141
- children: [
142
- /* @__PURE__ */ t(Tn, { children: "Add new form" }),
143
- /* @__PURE__ */ s(_n, { children: [
144
- /* @__PURE__ */ t(Ji, { id: "alert-dialog-slide-description", children: "Please enter all details" }),
145
- /* @__PURE__ */ s(xe, { container: !0, spacing: 2, columns: 12, sx: { mt: 1 }, children: [
146
- /* @__PURE__ */ t(xe, { size: 12, children: /* @__PURE__ */ t(Ye, { children: /* @__PURE__ */ t(ot, { label: "Basic Details", size: "small" }) }) }),
147
- /* @__PURE__ */ t(xe, { size: 4, children: /* @__PURE__ */ t(
148
- ne,
149
- {
150
- control: v.control,
151
- name: "formName",
152
- id: "formName",
153
- fullWidth: !0,
154
- size: "small",
155
- label: "Name",
156
- errors: v.formState.errors,
157
- required: !0
158
- }
159
- ) }),
160
- /* @__PURE__ */ t(xe, { size: 4, children: /* @__PURE__ */ t(
161
- ne,
162
- {
163
- control: v.control,
164
- name: "formCode",
165
- id: "formCode",
166
- fullWidth: !0,
167
- size: "small",
168
- label: "Code",
169
- errors: {
170
- ...v.formState.errors,
171
- ...ie === !1 && {
172
- formCode: { message: "Form Code is already taken!" }
173
- }
174
- },
175
- required: !0,
176
- onChange: (N) => {
177
- const S = N.target.value.toUpperCase().replace(/[^A-Z_]/g, "");
178
- v.setValue("formCode", S), v.setValue(
179
- "navigationState",
180
- `medplat.form.${S}`
181
- ), pe(S);
182
- }
183
- }
184
- ) }),
185
- /* @__PURE__ */ t(xe, { size: 2, children: /* @__PURE__ */ t(te, { required: !0, fullWidth: !0, size: "small", children: /* @__PURE__ */ t(
186
- Ve,
187
- {
188
- control: v.control,
189
- name: "state",
190
- id: "state",
191
- options: ["ACTIVE", "INACTIVE"],
192
- errors: v.formState.errors,
193
- size: "small",
194
- placeholder: "",
195
- label: "State",
196
- required: !0
197
- }
198
- ) }) }),
199
- /* @__PURE__ */ t(xe, { size: 2, children: /* @__PURE__ */ t(te, { required: !0, fullWidth: !0, size: "small", children: /* @__PURE__ */ t(
200
- Ve,
201
- {
202
- control: v.control,
203
- name: "formType",
204
- id: "formType",
205
- options: ["FORM", "SEARCH", "WRAPPER"],
206
- errors: v.formState.errors,
207
- size: "small",
208
- placeholder: "",
209
- label: "Type",
210
- required: !0
211
- }
212
- ) }) }),
213
- /* @__PURE__ */ t(xe, { size: 12, children: /* @__PURE__ */ t(
214
- ne,
215
- {
216
- control: v.control,
217
- name: "description",
218
- id: "description",
219
- fullWidth: !0,
220
- multiline: !0,
221
- rows: 2,
222
- size: "small",
223
- label: "Description",
224
- errors: v.formState.errors,
225
- required: !0
226
- }
227
- ) }),
228
- /* @__PURE__ */ t(xe, { size: 12, children: /* @__PURE__ */ t(Ye, { children: /* @__PURE__ */ t(ot, { label: "Page Param Details", size: "small" }) }) }),
229
- /* @__PURE__ */ s(xe, { size: 12, children: [
230
- /* @__PURE__ */ t(
231
- $,
232
- {
233
- name: "pageParams",
234
- control: v.control,
235
- render: ({ field: N }) => /* @__PURE__ */ t(
236
- Vn,
237
- {
238
- ...N,
239
- label: "Page Params",
240
- size: "small",
241
- placeholder: "Add Page Params",
242
- value: l,
243
- onChange: z,
244
- onKeyDown: (S) => {
245
- S.key === "Enter" && (S.preventDefault(), de());
246
- },
247
- fullWidth: !0,
248
- slotProps: {
249
- input: {
250
- endAdornment: /* @__PURE__ */ t(qe, { color: "primary", onClick: de, children: /* @__PURE__ */ t(
251
- le,
252
- {
253
- iconName: "faArrowRightToBracket",
254
- size: "xs"
255
- }
256
- ) })
257
- }
258
- }
259
- }
260
- )
261
- }
262
- ),
263
- /* @__PURE__ */ t(c, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mt: 2 }, children: C.map((N, S) => /* @__PURE__ */ t(
264
- ot,
265
- {
266
- label: N,
267
- onDelete: () => Z(N),
268
- color: "primary"
269
- },
270
- S + 1
271
- )) }),
272
- C.length === 0 && /* @__PURE__ */ t(ji, { severity: "info", variant: "outlined", children: "No page params added" })
273
- ] }),
274
- ["FORM", "SEARCH"].includes(v.getValues("formType")) && /* @__PURE__ */ s(fe, { children: [
275
- /* @__PURE__ */ t(xe, { size: 12, children: /* @__PURE__ */ t(Ye, { children: /* @__PURE__ */ t(ot, { label: "Route Details", size: "small" }) }) }),
276
- /* @__PURE__ */ t(
277
- ne,
278
- {
279
- control: v.control,
280
- name: "navigationState",
281
- id: "navigationState",
282
- fullWidth: !0,
283
- size: "small",
284
- label: "Navigation State",
285
- errors: v.formState.errors,
286
- disabled: !0
287
- }
288
- )
289
- ] })
290
- ] })
291
- ] }),
292
- /* @__PURE__ */ s(En, { children: [
293
- /* @__PURE__ */ t(U, { type: "submit", color: "success", children: "Create" }),
294
- /* @__PURE__ */ t(U, { onClick: he, children: "Close" })
295
- ] })
296
- ]
297
- }
298
- )
299
- }
300
- );
301
- }
302
- An.propTypes = {
303
- mainFormCtrl: I.any,
304
- openAddFormModal: I.any,
305
- setModal: I.any,
306
- reloadForms: I.any
307
- };
308
- const Tt = ({
309
- permission: m,
310
- index: M,
311
- depth: A = 0,
312
- onEdit: E,
313
- onRemove: l,
314
- handleAddChildClick: b,
315
- isLastChild: C = !1,
316
- isDynamicFeature: Y
317
- }) => {
318
- var W;
319
- const ie = Dn(), R = (v) => v.replaceAll(".child.", ".");
320
- return /* @__PURE__ */ s(c, { sx: { position: "relative", pl: A * 3 }, children: [
321
- A > 0 && /* @__PURE__ */ s(fe, { children: [
322
- /* @__PURE__ */ t(
323
- c,
324
- {
325
- sx: {
326
- position: "absolute",
327
- left: 16,
328
- top: 0,
329
- bottom: C ? "50%" : 0,
330
- width: 2,
331
- bgcolor: ie.palette.divider
332
- }
333
- }
334
- ),
335
- /* @__PURE__ */ t(
336
- c,
337
- {
338
- sx: {
339
- position: "absolute",
340
- left: 16,
341
- top: 22,
342
- width: 24,
343
- height: 2,
344
- bgcolor: ie.palette.divider
345
- }
346
- }
347
- )
348
- ] }),
349
- /* @__PURE__ */ s(
350
- c,
351
- {
352
- sx: {
353
- display: "flex",
354
- alignItems: "center",
355
- gap: 1.5,
356
- border: `1px solid ${ie.palette.divider}`,
357
- borderRadius: 2,
358
- padding: "8px 12px",
359
- backgroundColor: A === 0 ? ie.palette.background.paper : tr(ie.palette.background.paper, 0.8),
360
- ml: A > 0 ? 3 : 0,
361
- position: "relative"
362
- },
363
- children: [
364
- A === 0 && /* @__PURE__ */ s(f, { sx: { width: 24, color: "text.secondary" }, children: [
365
- M + 1,
366
- "."
367
- ] }),
368
- /* @__PURE__ */ t(f, { sx: { flexGrow: 1, fontWeight: 500 }, children: R(m.permissionId) }),
369
- A === 0 && /* @__PURE__ */ t(
370
- U,
371
- {
372
- variant: "outlined",
373
- size: "small",
374
- startIcon: /* @__PURE__ */ t(le, { iconName: "faPlus" }),
375
- onClick: () => b(m),
376
- children: "Add Child"
377
- }
378
- ),
379
- (!m.isDefault || m.isDefault && !Y) && /* @__PURE__ */ t(
380
- qe,
381
- {
382
- color: "secondary",
383
- onClick: () => E(m, M),
384
- children: /* @__PURE__ */ t(le, { iconName: "faEdit", size: "sm" })
385
- }
386
- ),
387
- !m.isDefault && /* @__PURE__ */ t(qe, { color: "error", onClick: () => l(m), children: /* @__PURE__ */ t(le, { iconName: "faTrash", size: "sm" }) })
388
- ]
389
- }
390
- ),
391
- ((W = m.childPermissions) == null ? void 0 : W.length) > 0 && /* @__PURE__ */ t(Pn, { spacing: 1, sx: { mt: 1 }, children: m.childPermissions.map((v, de) => /* @__PURE__ */ t(
392
- Tt,
393
- {
394
- permission: v,
395
- index: de,
396
- depth: A + 1,
397
- onEdit: E,
398
- onRemove: l,
399
- handleAddChildClick: b,
400
- isLastChild: de === m.childPermissions.length - 1,
401
- isDynamicFeature: Y
402
- },
403
- de
404
- )) })
405
- ] });
406
- }, Wn = ({
407
- permissions: m,
408
- onEdit: M,
409
- onRemove: A,
410
- handleAddChildClick: E,
411
- isDynamicFeature: l
412
- }) => /* @__PURE__ */ t(Pn, { spacing: 1, children: m.map((b, C) => /* @__PURE__ */ t(
413
- Tt,
414
- {
415
- permission: b,
416
- index: C,
417
- depth: 0,
418
- onEdit: M,
419
- onRemove: A,
420
- handleAddChildClick: E,
421
- isLastChild: C === m.length - 1,
422
- isDynamicFeature: l
423
- },
424
- C
425
- )) }), qn = ({
426
- open: m,
427
- onClose: M,
428
- onSave: A,
429
- formCtrl: E,
430
- editData: l,
431
- parentPermissionId: b = null,
432
- mode: C = "add-parent",
433
- permissionTypes: Y,
434
- setPermissionTypes: ie,
435
- existingPermissionIds: R,
436
- isDynamicFeature: W = !0
437
- }) => {
438
- var Be, Oe, be;
439
- const [v, de] = x(""), [Z, z] = x([]), [he, Q] = x(""), J = {
440
- permissionType: "",
441
- permissionId: "--",
442
- permissionName: "",
443
- permissionDesc: "",
444
- enabled: !0,
445
- permissionSuffix: "",
446
- parentPermissionSuffix: ""
447
- }, pe = {
448
- backendUrl: "",
449
- urlType: "",
450
- queryCodeRequired: l ? (Be = l == null ? void 0 : l.backendUrl) != null && Be.trim() && ((Oe = l == null ? void 0 : l.urlType) != null && Oe.trim()) ? !1 : (be = l == null ? void 0 : l.queryCode) != null && be.trim() ? !0 : void 0 : void 0,
451
- queryCode: ""
452
- }, N = W ? J : { ...J, ...pe }, {
453
- control: S,
454
- watch: D,
455
- handleSubmit: Ke,
456
- reset: Se,
457
- setValue: B,
458
- getValues: De,
459
- setError: ye,
460
- clearErrors: we,
461
- formState: Pe
462
- } = ft({
463
- mode: "onChange",
464
- defaultValues: N
465
- }), j = D("queryCodeRequired"), V = D("permissionType"), Re = D("permissionSuffix"), Ze = D("backendUrl"), ve = D("queryCode"), ht = [
466
- { label: "Query", value: !0 },
467
- { label: "API", value: !1 }
468
- ], L = (p = {}) => ({ ...W ? J : { ...J, ...pe }, ...p }), Ce = D("parentPermissionSuffix"), Ae = (p) => p.trim().toLowerCase().split(/\s+/).map(
469
- (g, w) => w === 0 ? g : g.charAt(0).toUpperCase() + g.slice(1)
470
- ).join(""), Xe = async (p) => {
471
- const g = (await G({
472
- code: "GET_ALL_QUERY_CODE",
473
- parameters: { search: p }
474
- })).data;
475
- z((g == null ? void 0 : g.result) || []);
476
- };
477
- ae(() => {
478
- !W && (async () => {
479
- const g = (await G({
480
- code: "GET_ALL_QUERY_CODE",
481
- parameters: {
482
- search: De("queryCode") ? De("queryCode") : ""
483
- }
484
- })).data;
485
- z((g == null ? void 0 : g.result) || []), Q(De("queryCode"));
486
- })();
487
- }, [ve]), ae(() => {
488
- j === !0 && !Ze ? (B("backendUrl", ""), B("urlType", "")) : j === !1 && !ve && B("queryCode", "");
489
- }, [j]), ae(() => {
490
- var p, g, w;
491
- if (m) {
492
- if (C === "edit" && l) {
493
- const T = {
494
- permissionType: l.permissionType || "",
495
- permissionId: l.permissionId || "--",
496
- permissionName: l.permissionName || "",
497
- permissionDesc: l.permissionDesc || "",
498
- enabled: !!l.enabled,
499
- permissionSuffix: ""
500
- };
501
- if (W)
502
- Se(T);
503
- else {
504
- const re = ((p = l == null ? void 0 : l.backendUrl) == null ? void 0 : p.trim()) && ((g = l == null ? void 0 : l.urlType) == null ? void 0 : g.trim()), _ = (w = l == null ? void 0 : l.queryCode) == null ? void 0 : w.trim();
505
- Se({
506
- ...T,
507
- urlType: l.urlType || "",
508
- backendUrl: l.backendUrl || "",
509
- queryCode: l.queryCode || "",
510
- queryCodeRequired: l ? re ? !1 : _ ? !0 : void 0 : void 0
511
- });
512
- }
513
- return;
514
- }
515
- if (C === "add-child" && b) {
516
- const T = b.split(".")[0] || "";
517
- Se(
518
- L({
519
- permissionType: T,
520
- permissionId: b,
521
- permissionName: "",
522
- permissionDesc: "",
523
- enabled: !0,
524
- permissionSuffix: "",
525
- urlType: "",
526
- backendUrl: "",
527
- queryCodeRequired: void 0,
528
- queryCode: ""
529
- })
530
- );
531
- return;
532
- }
533
- Se(L());
534
- }
535
- }, [m, C, l, b, Se]), ae(() => {
536
- if (C === "add-parent") {
537
- const p = (V == null ? void 0 : V.type) === "menu" ? "view" : V == null ? void 0 : V.type;
538
- if (!p) {
539
- B("permissionId", "--");
540
- return;
541
- }
542
- const g = E.getValues("menuType") || "menuType", w = E.getValues("featureConstant") || "feature";
543
- let T;
544
- if (W)
545
- T = `${p}.${g}.${w}`;
546
- else {
547
- const re = E.getValues("menuName");
548
- T = `${p}.${g}.${Ae(re)}`;
549
- }
550
- Ce != null && Ce.trim() && (T = `${T}.${Ce.trim()}`), B("permissionId", T);
551
- }
552
- }, [V, Ce, C]), ae(() => {
553
- j === !0 && !Ze ? (B("backendUrl", ""), B("urlType", "")) : j === !1 && !ve && B("queryCode", "");
554
- }, [j]), ae(() => {
555
- if (C === "add-child" && b !== null) {
556
- const p = b.split(".")[0] || "", g = `${b}.child`, w = Re ? `${g}.${Re}` : g;
557
- B("permissionId", w), B("permissionType", p);
558
- }
559
- }, [Re, C, b, B]);
560
- const et = (p) => {
561
- const g = {
562
- permissionId: p.permissionId,
563
- permissionType: p.permissionType || (b ? b.split(".")[0] : ""),
564
- permissionName: p.permissionName,
565
- permissionDesc: p.permissionDesc,
566
- enabled: p.enabled,
567
- backendUrl: p != null && p.backendUrl && !j ? p.backendUrl : null,
568
- urlType: p != null && p.urlType && !j ? p.urlType : null,
569
- queryCode: p != null && p.queryCode && j ? p.queryCode : null,
570
- childPermissions: [],
571
- isDefault: l != null && l.isDefault ? l == null ? void 0 : l.isDefault : !1
572
- };
573
- A(g), Se(), M();
574
- }, Me = async (p) => !p || p === "--" ? void 0 : (await G({
575
- code: "CHECK_UNIQUE_PERMISSION_ID",
576
- parameters: { permissionId: p }
577
- })).data.result[0].exists;
578
- return /* @__PURE__ */ s(Fn, { open: m, onClose: M, fullWidth: !0, maxWidth: "sm", children: [
579
- /* @__PURE__ */ t(Tn, { children: C === "edit" ? "Edit Permission" : "Add Permission" }),
580
- /* @__PURE__ */ s(
581
- _n,
582
- {
583
- sx: { display: "flex", flexDirection: "column", gap: 2, mt: 1 },
584
- children: [
585
- C !== "add-child" && C !== "edit" && /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
586
- /* @__PURE__ */ s(
587
- f,
588
- {
589
- sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
590
- children: [
591
- "Permission Type",
592
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
593
- ]
594
- }
595
- ),
596
- /* @__PURE__ */ t(te, { fullWidth: !0, size: "small", children: /* @__PURE__ */ t(
597
- $,
598
- {
599
- name: "permissionType",
600
- control: S,
601
- rules: { required: !0 },
602
- render: ({ field: p }) => /* @__PURE__ */ t(
603
- Ee,
604
- {
605
- id: "permissionType",
606
- name: "permissionType",
607
- control: S,
608
- singleSelect: !0,
609
- checkEquality: "type",
610
- freeSolo: !0,
611
- disableClearable: !1,
612
- placeholder: "Choose permission type",
613
- options: Y ? !v || Y.some(
614
- (g) => g.type.toLowerCase() === v.toLowerCase()
615
- ) ? Y : [
616
- ...Y,
617
- { type: `__add_new__${v}`, isNew: !0 }
618
- ] : [],
619
- getOptionLabel: (g) => g.isNew ? `Add "${g.type.replace("__add_new__", "")}"` : g.type,
620
- onInputChange: (g, w) => de(w),
621
- onChange: (g, w) => {
622
- if (!w) {
623
- p.onChange(null), B("permissionId", "--");
624
- return;
625
- }
626
- if (w.isNew) {
627
- const T = w.type.replace("__add_new__", ""), re = { type: T };
628
- ie(
629
- (_) => _.some((Fe) => Fe.type === T) ? _ : [..._, re]
630
- ), p.onChange(re);
631
- return;
632
- }
633
- p.onChange(w);
634
- }
635
- }
636
- )
637
- }
638
- ) })
639
- ] }),
640
- C === "add-child" ? /* @__PURE__ */ t(fe, { children: /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
641
- /* @__PURE__ */ s(
642
- f,
643
- {
644
- sx: {
645
- minWidth: 160,
646
- fontWeight: 500,
647
- color: "text.secondary"
648
- },
649
- children: [
650
- "Permission ID",
651
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
652
- ]
653
- }
654
- ),
655
- /* @__PURE__ */ s(c, { sx: { display: "flex", gap: 1, flexGrow: 1 }, children: [
656
- /* @__PURE__ */ t(
657
- ne,
658
- {
659
- control: S,
660
- name: "parentPermissionDisplay",
661
- value: `${b}.child.`,
662
- disabled: !0,
663
- fullWidth: !0
664
- }
665
- ),
666
- /* @__PURE__ */ t(
667
- ne,
668
- {
669
- control: S,
670
- name: "permissionSuffix",
671
- placeholder: "Enter child suffix",
672
- errors: Pe.errors,
673
- fullWidth: !0,
674
- onChange: async (p) => {
675
- const g = p.target.value.trim();
676
- if (B("permissionSuffix", g), g.toLowerCase() === "child") {
677
- ye("permissionSuffix", {
678
- type: "manual",
679
- message: "Suffix cannot be 'child'"
680
- });
681
- return;
682
- }
683
- we("permissionSuffix");
684
- const w = `${b}.child.${g}`;
685
- if (B("permissionId", w), R != null && R.has(w)) {
686
- ye("permissionSuffix", {
687
- type: "manual",
688
- message: "Permission ID already exists"
689
- });
690
- return;
691
- }
692
- await Me(w) ? ye("permissionSuffix", {
693
- type: "manual",
694
- message: "Permission ID already exists in DB"
695
- }) : we("permissionSuffix");
696
- }
697
- }
698
- )
699
- ] })
700
- ] }) }) : C === "add-parent" ? V != null && V.type ? /* @__PURE__ */ t(fe, { children: /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
701
- /* @__PURE__ */ s(
702
- f,
703
- {
704
- sx: {
705
- minWidth: 160,
706
- fontWeight: 500,
707
- color: "text.secondary"
708
- },
709
- children: [
710
- "Permission ID",
711
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
712
- ]
713
- }
714
- ),
715
- /* @__PURE__ */ t(
716
- ne,
717
- {
718
- control: S,
719
- name: "baseId",
720
- value: `${(V == null ? void 0 : V.type) === "menu" ? "view" : V == null ? void 0 : V.type}.${E.getValues("menuType")}.${W ? E.getValues("featureConstant") : Ae(E.getValues("menuName"))}.`,
721
- disabled: !0,
722
- fullWidth: !0
723
- }
724
- ),
725
- /* @__PURE__ */ t(
726
- ne,
727
- {
728
- control: S,
729
- name: "parentPermissionSuffix",
730
- placeholder: "Enter suffix",
731
- errors: Pe.errors,
732
- fullWidth: !0,
733
- onChange: async (p) => {
734
- const g = p.target.value.trim();
735
- if (B("parentPermissionSuffix", g), g.toLowerCase() === "child") {
736
- ye("parentPermissionSuffix", {
737
- type: "manual",
738
- message: "Suffix cannot be 'child'"
739
- });
740
- return;
741
- }
742
- we("parentPermissionSuffix");
743
- const w = (V == null ? void 0 : V.type) === "menu" ? "view" : (V == null ? void 0 : V.type) || V || "", T = E.getValues("menuType"), re = E.getValues("featureConstant");
744
- let _;
745
- if (W ? _ = `${w}.${T}.${re}.${g}` : _ = `${w}.${T}.${Ae(E.getValues("menuName"))}.${g}`, B("permissionId", _), R != null && R.has(_)) {
746
- ye("parentPermissionSuffix", {
747
- type: "manual",
748
- message: "Permission ID already exists"
749
- });
750
- return;
751
- }
752
- await Me(_) ? ye("parentPermissionSuffix", {
753
- type: "manual",
754
- message: "Permission ID already exists in DB"
755
- }) : we("parentPermissionSuffix");
756
- }
757
- }
758
- )
759
- ] }) }) : /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
760
- /* @__PURE__ */ s(
761
- f,
762
- {
763
- sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
764
- children: [
765
- "Permission ID",
766
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
767
- ]
768
- }
769
- ),
770
- /* @__PURE__ */ t(
771
- ne,
772
- {
773
- control: S,
774
- name: "permissionId",
775
- value: "--",
776
- disabled: !0,
777
- fullWidth: !0
778
- }
779
- )
780
- ] }) : /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
781
- /* @__PURE__ */ s(
782
- f,
783
- {
784
- sx: {
785
- minWidth: 160,
786
- fontWeight: 500,
787
- color: "text.secondary"
788
- },
789
- children: [
790
- "Permission ID",
791
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
792
- ]
793
- }
794
- ),
795
- /* @__PURE__ */ t(
796
- ne,
797
- {
798
- control: S,
799
- name: "permissionId",
800
- label: "Permission ID",
801
- disabled: !0,
802
- fullWidth: !0
803
- }
804
- )
805
- ] }),
806
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
807
- /* @__PURE__ */ s(
808
- f,
809
- {
810
- sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
811
- children: [
812
- "Permission Name",
813
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
814
- ]
815
- }
816
- ),
817
- /* @__PURE__ */ t(
818
- $,
819
- {
820
- name: "permissionName",
821
- control: S,
822
- rules: { required: !0 },
823
- render: ({ field: p }) => /* @__PURE__ */ t(
824
- ne,
825
- {
826
- control: S,
827
- ...p,
828
- placeholder: "Enter name"
829
- }
830
- )
831
- }
832
- )
833
- ] }),
834
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "flex-start", gap: 2, children: [
835
- /* @__PURE__ */ t(
836
- f,
837
- {
838
- sx: {
839
- minWidth: 160,
840
- fontWeight: 500,
841
- color: "text.secondary",
842
- mt: 1
843
- },
844
- children: "Description"
845
- }
846
- ),
847
- /* @__PURE__ */ t(
848
- $,
849
- {
850
- name: "permissionDesc",
851
- control: S,
852
- render: ({ field: p }) => /* @__PURE__ */ t(
853
- ur,
854
- {
855
- control: S,
856
- ...p,
857
- placeholder: "Enter description (optional)",
858
- minRows: 2
859
- }
860
- )
861
- }
862
- )
863
- ] }),
864
- !W && /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
865
- /* @__PURE__ */ s(
866
- f,
867
- {
868
- sx: {
869
- minWidth: 160,
870
- fontWeight: 500,
871
- color: "text.secondary"
872
- },
873
- children: [
874
- "Type",
875
- " "
876
- ]
877
- }
878
- ),
879
- /* @__PURE__ */ t(
880
- fr,
881
- {
882
- name: "queryCodeRequired",
883
- control: S,
884
- options: ht,
885
- direction: "row",
886
- dataTestId: "queryOrApi"
887
- }
888
- )
889
- ] }),
890
- !W && j !== void 0 && /* @__PURE__ */ t(fe, { children: j === !1 ? /* @__PURE__ */ s(fe, { children: [
891
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
892
- /* @__PURE__ */ t(
893
- f,
894
- {
895
- sx: {
896
- minWidth: 160,
897
- fontWeight: 500,
898
- color: "text.secondary"
899
- },
900
- children: "URL Type"
901
- }
902
- ),
903
- /* @__PURE__ */ t(te, { fullWidth: !0, size: "small", children: /* @__PURE__ */ t(
904
- $,
905
- {
906
- name: "urlType",
907
- control: S,
908
- render: ({ field: p }) => /* @__PURE__ */ s(Zi, { ...p, displayEmpty: !0, children: [
909
- /* @__PURE__ */ t(Cn, { value: "", children: /* @__PURE__ */ t("em", { children: "Select Type" }) }),
910
- ["GET", "POST", "PUT", "DELETE"].map((g) => /* @__PURE__ */ t(Cn, { value: g, children: g }, g))
911
- ] })
912
- }
913
- ) })
914
- ] }),
915
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
916
- /* @__PURE__ */ t(
917
- f,
918
- {
919
- sx: {
920
- minWidth: 160,
921
- fontWeight: 500,
922
- color: "text.secondary"
923
- },
924
- children: "Backend URL"
925
- }
926
- ),
927
- /* @__PURE__ */ t(
928
- $,
929
- {
930
- name: "backendUrl",
931
- control: S,
932
- render: ({ field: p }) => /* @__PURE__ */ t(
933
- ne,
934
- {
935
- control: S,
936
- ...p,
937
- placeholder: "Enter URL"
938
- }
939
- )
940
- }
941
- )
942
- ] })
943
- ] }) : /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
944
- /* @__PURE__ */ t(
945
- f,
946
- {
947
- sx: {
948
- minWidth: 160,
949
- fontWeight: 500,
950
- color: "text.secondary"
951
- },
952
- children: "Query Code"
953
- }
954
- ),
955
- /* @__PURE__ */ t(
956
- $,
957
- {
958
- name: "queryCode",
959
- control: S,
960
- render: ({ field: p, fieldState: { error: g } }) => /* @__PURE__ */ t(
961
- Ee,
962
- {
963
- id: "queryCode",
964
- name: "queryCode",
965
- control: S,
966
- options: Z,
967
- getOptionLabel: (w) => (w == null ? void 0 : w.code) || "",
968
- checkEquality: "code",
969
- inputValue: he,
970
- disableClearable: !1,
971
- value: (Z == null ? void 0 : Z.find((w) => w.code === p.value)) || null,
972
- onInputChange: (w, T, re) => {
973
- re === "input" && (Q(T), Xe(T));
974
- },
975
- singleSelect: !0,
976
- onChange: (w, T) => {
977
- p.onChange((T == null ? void 0 : T.code) || ""), Q((T == null ? void 0 : T.code) || "");
978
- },
979
- placeholder: "Search Query Code...",
980
- errors: g,
981
- fullWidth: !0,
982
- freeSolo: !1
983
- }
984
- )
985
- }
986
- )
987
- ] }) }),
988
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
989
- /* @__PURE__ */ s(
990
- f,
991
- {
992
- sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
993
- children: [
994
- "Is Active",
995
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
996
- ]
997
- }
998
- ),
999
- /* @__PURE__ */ t(
1000
- $,
1001
- {
1002
- name: "enabled",
1003
- control: S,
1004
- render: ({ field: p }) => /* @__PURE__ */ t(
1005
- Ie,
1006
- {
1007
- ...p,
1008
- disabled: (l == null ? void 0 : l.isDefault) && !W,
1009
- checked: p.value,
1010
- onChange: (g) => p.onChange(g.target.checked)
1011
- }
1012
- )
1013
- }
1014
- )
1015
- ] })
1016
- ]
1017
- }
1018
- ),
1019
- /* @__PURE__ */ s(En, { children: [
1020
- /* @__PURE__ */ t(U, { onClick: M, children: "Cancel" }),
1021
- /* @__PURE__ */ t(
1022
- U,
1023
- {
1024
- onClick: Ke(et),
1025
- variant: "contained",
1026
- disabled: !Pe.isValid || Object.keys(Pe.errors).length > 0,
1027
- children: C === "edit" ? "Update" : C === "add-child" ? "Add Child" : "Add"
1028
- }
1029
- )
1030
- ] })
1031
- ] });
1032
- }, Rn = ({
1033
- open: m,
1034
- onClose: M,
1035
- onSave: A,
1036
- entityData: E,
1037
- permissions: l = []
1038
- }) => {
1039
- const { control: b, watch: C, getValues: Y } = ft({
1040
- defaultValues: {
1041
- noStartDate: !0,
1042
- noEndDate: !0,
1043
- startDate: null,
1044
- endDate: null,
1045
- isBackendOnly: !1
1046
- }
1047
- }), ie = C("noStartDate"), R = C("noEndDate"), W = C("startDate"), v = C("endDate"), de = () => {
1048
- const z = Y();
1049
- Z(z);
1050
- }, Z = (z) => {
1051
- const he = [];
1052
- E.forEach((Q) => {
1053
- if (Q.type === "user") {
1054
- const J = Array.isArray(Q.id) ? Q.id : [Q.id];
1055
- he.push(
1056
- ...J.map((pe) => ({
1057
- entityType: "user",
1058
- user_id: pe,
1059
- name: Q.name,
1060
- startDate: z.noStartDate ? null : z.startDate,
1061
- endDate: z.noEndDate ? null : z.endDate,
1062
- isBackendOnly: z.isBackendOnly,
1063
- permissions: JSON.parse(JSON.stringify(l))
1064
- }))
1065
- );
1066
- }
1067
- Q.type === "role" && Q.ids.forEach((J, pe) => {
1068
- he.push({
1069
- entityType: "role",
1070
- role_id: J,
1071
- name: Q.names[pe],
1072
- startDate: z.noStartDate ? null : z.startDate,
1073
- endDate: z.noEndDate ? null : z.endDate,
1074
- isBackendOnly: z.isBackendOnly,
1075
- permissions: JSON.parse(JSON.stringify(l))
1076
- });
1077
- });
1078
- }), he.forEach((Q) => A(Q)), M();
1079
- };
1080
- return /* @__PURE__ */ t(Xi, { open: m, onClose: M, children: /* @__PURE__ */ t(c, { className: "fixed inset-0 flex items-start justify-center z-50 bg-opacity-10 overflow-y-auto", children: /* @__PURE__ */ s(er, { className: "relative mt-10 p-4 shadow-lg flex flex-col rounded-xl", children: [
1081
- /* @__PURE__ */ s(H, { className: "flex justify-between items-center mb-4", children: [
1082
- /* @__PURE__ */ t(f, { variant: "h6", children: "Grant Access" }),
1083
- /* @__PURE__ */ t(qe, { onClick: M, children: /* @__PURE__ */ t(le, { iconName: "faXmark", size: "sm" }) })
1084
- ] }),
1085
- /* @__PURE__ */ t(H, { container: !0, spacing: 2, children: /* @__PURE__ */ s(H, { item: !0, xs: 12, display: "flex", gap: 2, children: [
1086
- /* @__PURE__ */ s(c, { display: "flex", flexDirection: "column", flex: 1, children: [
1087
- /* @__PURE__ */ t(
1088
- vt,
1089
- {
1090
- label: "No Start Date",
1091
- name: "noStartDate",
1092
- control: b,
1093
- sx: { mb: 1 }
1094
- }
1095
- ),
1096
- /* @__PURE__ */ t(
1097
- wn,
1098
- {
1099
- name: "startDate",
1100
- control: b,
1101
- disabled: ie,
1102
- maxDate: v || void 0
1103
- }
1104
- )
1105
- ] }),
1106
- /* @__PURE__ */ s(c, { display: "flex", flexDirection: "column", flex: 1, children: [
1107
- /* @__PURE__ */ t(
1108
- vt,
1109
- {
1110
- label: "No End Date",
1111
- name: "noEndDate",
1112
- control: b,
1113
- sx: { mb: 1 }
1114
- }
1115
- ),
1116
- /* @__PURE__ */ t(
1117
- wn,
1118
- {
1119
- name: "endDate",
1120
- control: b,
1121
- disabled: R,
1122
- minDate: W || void 0
1123
- }
1124
- )
1125
- ] })
1126
- ] }) }),
1127
- /* @__PURE__ */ t(c, { mt: 2, children: /* @__PURE__ */ t(
1128
- vt,
1129
- {
1130
- label: "Is Backend Only?",
1131
- name: "isBackendOnly",
1132
- control: b
1133
- }
1134
- ) }),
1135
- /* @__PURE__ */ s(H, { className: "flex justify-end gap-2 mt-4", children: [
1136
- /* @__PURE__ */ t(U, { type: "button", variant: "outlined", onClick: M, children: "Cancel" }),
1137
- /* @__PURE__ */ t(U, { variant: "contained", type: "button", onClick: de, children: "Save" })
1138
- ] })
1139
- ] }) }) });
1140
- }, _t = ({ permissions: m, onToggle: M, isChild: A = !1 }) => {
1141
- const E = (l) => l.replaceAll(".child", "");
1142
- return m.map((l, b) => {
1143
- var C;
1144
- return /* @__PURE__ */ s(
1145
- c,
1146
- {
1147
- display: "flex",
1148
- flexDirection: "column",
1149
- gap: 1,
1150
- ml: A ? 2 : 0,
1151
- children: [
1152
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 1, children: [
1153
- /* @__PURE__ */ t(
1154
- Ie,
1155
- {
1156
- sx: {
1157
- transform: "scale(0.75)",
1158
- transformOrigin: "left center"
1159
- },
1160
- checked: !!l.enabled,
1161
- disabled: A,
1162
- onChange: () => {
1163
- A || M(l);
1164
- }
1165
- }
1166
- ),
1167
- /* @__PURE__ */ t(f, { variant: "subtitle1", children: E(l.permissionId) })
1168
- ] }),
1169
- ((C = l.childPermissions) == null ? void 0 : C.length) > 0 && /* @__PURE__ */ t(
1170
- _t,
1171
- {
1172
- permissions: l.childPermissions,
1173
- onToggle: M,
1174
- isChild: !0
1175
- }
1176
- )
1177
- ]
1178
- },
1179
- b
1180
- );
1181
- });
1182
- };
1183
- function Qr() {
1184
- var tn, nn, rn, an, sn, on, ln, dn, cn, un, mn;
1185
- const { translate: m } = mr(), M = ir(null), A = sr(), E = or(), { isNew: l } = A.state || {}, b = Nn(
1186
- () => new URLSearchParams(A.search),
1187
- [A.search]
1188
- ), C = Dn(), [Y, ie] = x([]), [R, W] = x(!1), [v, de] = x([]), [Z, z] = x([]), [he, Q] = x(), [J, pe] = x({}), [N, S] = x(!1), [D, Ke] = x(!1), [Se, B] = x(""), [De, ye] = x(""), [we, Pe] = x(""), [j, V] = x(), [Re, Ze] = x([]), [ve, ht] = x(!1), [L, Ce] = x(0), [Ae, Xe] = x(!1), [et, Me] = x([]), [Be, Oe] = x([]), [be, p] = x([]), [g, w] = x([]), [T, re] = x([]), [_, Fe] = x({}), [Ue, ze] = x([]), [Le, Mn] = x({}), [ce, $e] = x([]), [Bn, Qe] = x(!1), [Je, tt] = x("add-parent"), [pt, nt] = x(null), [On, it] = x(null), [Un, rt] = x(null), [zn, gt] = x(!1), [Ln, $n] = x(null), [Ne, We] = x([]), [Qn, Vt] = x(!1), [Te, at] = x(!1), [Et, Jn] = x(!1), [K, Dt] = x({ value: !1, length: 0 }), [jn, Gn] = x([
1189
- { type: "update" },
1190
- { type: "menu" },
1191
- { type: "create" },
1192
- { type: "download" },
1193
- { type: "execute" }
1194
- ]), [ke, Hn] = x([]), [Yn, je] = x(""), [Kn, Ge] = x(""), [yt, bt] = x({
1195
- basicConfig: !0,
1196
- trainingConfig: !1,
1197
- notificationConfig: !1
1198
- }), [Pt, Zn] = nr.useState(null), Xn = (e) => et.includes(e), [ei, At] = x(/* @__PURE__ */ new Set()), ti = ar((e) => e.theme.mode), q = [
1199
- { key: "featureDetails", label: "Feature Details" },
1200
- { key: "mobileConfig", label: "Mobile Config" },
1201
- { key: "formLinking", label: "Form Linking" },
1202
- { key: "additionalPermissions", label: "Permission Management" },
1203
- { key: "assignFeatures", label: "Assignment" },
1204
- { key: "submit", label: "Submit" }
1205
- ], ni = O.object().shape({
1206
- menuName: O.string().required("Enter Feature Name"),
1207
- featureConstant: O.string().when("isDynamicFeature", {
1208
- is: !0,
1209
- then: (e) => e.required("Enter Feature Constant"),
1210
- otherwise: (e) => e.notRequired()
1211
- }),
1212
- navigationState: O.string().when("isDynamicFeature", {
1213
- is: !1,
1214
- then: (e) => e.required("Enter Navigation State").matches(
1215
- /^(techo\.[a-zA-Z]+\.[a-zA-Z]+|medplat(\.form\.[a-zA-Z_]+|\..+))$/,
1216
- "invalid format for state"
1217
- ),
1218
- otherwise: (e) => e.notRequired()
1219
- }),
1220
- menuType: O.string().required("Enter Feature Type"),
1221
- icon: O.string().when("$showMobileFields", {
1222
- is: !0,
1223
- then: (e) => e.required("Please upload an icon"),
1224
- otherwise: (e) => e.notRequired()
1225
- }),
1226
- conditions: O.string().transform((e) => e ? e.trim() : ""),
1227
- mobileMode: O.string().when("$showMobileFields", {
1228
- is: !0,
1229
- then: (e) => e.required("Please select a mode"),
1230
- otherwise: (e) => e.notRequired()
1231
- }),
1232
- trainingQuery: O.string().when("trainingRequired", {
1233
- is: !0,
1234
- then: (e) => e.required("Please select a training query"),
1235
- otherwise: (e) => e.notRequired()
1236
- }),
1237
- notificationBadgeType: O.string().when("notificationBadgeEnabled", {
1238
- is: !0,
1239
- then: (e) => e.required("Please select a badge type"),
1240
- otherwise: (e) => e.notRequired()
1241
- }),
1242
- notificationBadgeQuery: O.string().when(
1243
- ["notificationBadgeEnabled", "notificationBadgeType"],
1244
- (e, n) => {
1245
- const [i, r] = e;
1246
- return i && r ? n.required(
1247
- r === "COUNT" ? "Please select a count query" : "Please select a nudge query"
1248
- ) : n.notRequired();
1249
- }
1250
- ),
1251
- updatedFields: O.array().when(
1252
- ["isDynamicFeature", "isNew", "isUpdate", "showFields"],
1253
- (e, n) => {
1254
- const [i, r, o, u] = e;
1255
- return i === !1 && (r == null ? void 0 : r.val) === !1 && (o == null ? void 0 : o.value) === !0 && u === !0 ? n.of(
1256
- O.object().shape({
1257
- value: O.string().required("Right is required")
1258
- })
1259
- ) : n.optional();
1260
- }
1261
- )
1262
- }), a = ft({
1263
- defaultValues: {
1264
- menuName: "",
1265
- featureConstant: "",
1266
- navigationState: "medplat.form",
1267
- menuType: "",
1268
- menuGroup: "",
1269
- isDynamicFeature: !0,
1270
- isWebFeature: !1,
1271
- isMobileFeature: !1,
1272
- accessRights: [],
1273
- entityName: null,
1274
- mobileEntitiesSync: [],
1275
- icon: "",
1276
- mobileMode: null,
1277
- conditions: "",
1278
- formCode: "",
1279
- version: null,
1280
- additionalPermissions: [],
1281
- fields: [],
1282
- updatedFields: [],
1283
- trainingRequired: !1,
1284
- trainingQuery: "",
1285
- notificationBadgeEnabled: !1,
1286
- notificationBadgeType: "",
1287
- notificationBadgeQuery: ""
1288
- },
1289
- resolver: vn(ni),
1290
- mode: "onChange"
1291
- }), P = mt({
1292
- control: a.control,
1293
- name: "isDynamicFeature"
1294
- }), Wt = mt({
1295
- control: a.control,
1296
- name: "isMobileFeature"
1297
- }), qt = mt({
1298
- control: a.control,
1299
- name: "isWebFeature"
1300
- }), ii = mt({
1301
- control: a.control,
1302
- name: ai((tn = q[L]) == null ? void 0 : tn.key)
1303
- }), ri = a.watch();
1304
- function ai(e) {
1305
- switch (e) {
1306
- case "featureDetails":
1307
- return P ? ["menuName", "featureConstant", "menuType"] : ["menuName", "navigationState", "menuType"];
1308
- case "mobileConfig":
1309
- return R ? [
1310
- "icon",
1311
- "mobileMode",
1312
- "trainingRequired",
1313
- "trainingQuery",
1314
- "notificationBadgeEnabled",
1315
- "notificationBadgeType",
1316
- "notificationBadgeQuery"
1317
- ] : [];
1318
- case "formLinking":
1319
- return P ? ["formCode", "version"] : [];
1320
- case "additionalPermissions":
1321
- return !P && (l == null ? void 0 : l.val) === !1 ? ["updatedFields"] : ["additionalPermissions"];
1322
- default:
1323
- return [];
1324
- }
1325
- }
1326
- const Rt = Nn(() => {
1327
- var n;
1328
- switch ((n = q[L]) == null ? void 0 : n.key) {
1329
- case "featureDetails": {
1330
- const i = !!a.formState.errors.navigationState, r = !!a.formState.errors.featureConstant;
1331
- return a.formState.isValid && !!a.getValues("menuName") && (P ? !!a.getValues("featureConstant") && !r : !!a.getValues("navigationState") && !i) && !!a.getValues("menuType");
1332
- }
1333
- case "mobileConfig": {
1334
- if (!R) return !0;
1335
- const i = !!a.getValues("icon"), r = !!a.getValues("mobileMode"), o = a.getValues("trainingRequired"), u = a.getValues("trainingQuery"), d = a.getValues("notificationBadgeEnabled"), h = a.getValues("notificationBadgeType"), y = a.getValues("notificationBadgeQuery");
1336
- return i && r && (!o || !!u) && (!d || !!h) && (!d || !h || !!y);
1337
- }
1338
- case "formLinking": {
1339
- if (!P) return !0;
1340
- const i = a.getValues("formCode"), r = a.getValues("version");
1341
- return !!i && !!r;
1342
- }
1343
- case "additionalPermissions": {
1344
- if (!P && (l == null ? void 0 : l.val) === !1 && Te)
1345
- return (a.getValues("updatedFields") || []).every(
1346
- (o) => o.value && o.value.trim()
1347
- );
1348
- {
1349
- const i = a.getValues("additionalPermissions") || [];
1350
- return i.length > 0 && i.every(
1351
- (o) => {
1352
- var u, d, h, y;
1353
- return ((u = o.permissionId) == null ? void 0 : u.trim()) && ((d = o.permissionName) == null ? void 0 : d.trim()) && ((y = (h = o.permissionType) == null ? void 0 : h.type) == null ? void 0 : y.trim());
1354
- }
1355
- );
1356
- }
1357
- }
1358
- default:
1359
- return !0;
1360
- }
1361
- }, [
1362
- ii,
1363
- a.formState.isValid,
1364
- L,
1365
- R
1366
- ]), He = q.filter(
1367
- (e) => (e.key !== "mobileConfig" || R) && (e.key !== "formLinking" || P)
1368
- ), xt = async () => {
1369
- const e = q[L].key;
1370
- if (Xn(e)) {
1371
- Mt();
1372
- return;
1373
- }
1374
- await a.trigger(Bt(e)) && (At((i) => new Set(i).add(e)), Me((i) => i.filter((r) => r !== e)), Mt());
1375
- }, Mt = () => {
1376
- const e = q[L].key, n = He.findIndex(
1377
- (r) => r.key === e
1378
- ), i = He[n + 1];
1379
- if (i) {
1380
- i.key === "additionalPermissions" && ce.length === 0 && ci(), e === "additionalPermissions" && i.key === "assignFeatures" && We(
1381
- li(ce, Ne)
1382
- );
1383
- const r = q.findIndex(
1384
- (o) => o.key === i.key
1385
- );
1386
- Ce(r);
1387
- }
1388
- };
1389
- ae(() => {
1390
- if (D === !0) {
1391
- const e = a.getValues("mobileMode");
1392
- Zn(e);
1393
- }
1394
- }, [D, a]), ae(() => {
1395
- P ? a.setValue("navigationState", "medplat.form") : (b.get("featureId") === null && a.setValue("navigationState", ""), a.setValue("featureConstant", ""), B(""), a.clearErrors("featureConstant"));
1396
- }, [P]);
1397
- const Bt = (e) => {
1398
- switch (e) {
1399
- case "formLinking":
1400
- return ["formCode", "version"];
1401
- case "additionalPermissions":
1402
- return ["permissionId", "permissionName", "permissionType"];
1403
- default:
1404
- return [];
1405
- }
1406
- }, si = () => {
1407
- L === 0 && E("/ui/medplat/manage/menu");
1408
- const e = q[L].key, n = He.findIndex(
1409
- (r) => r.key === e
1410
- ), i = He[n - 1];
1411
- if (i) {
1412
- const r = q.findIndex(
1413
- (o) => o.key === i.key
1414
- );
1415
- Ce(r);
1416
- }
1417
- }, oi = (e) => {
1418
- const n = q[e].key;
1419
- return ei.has(n);
1420
- };
1421
- ae(() => {
1422
- (async () => {
1423
- var e;
1424
- if (await hi(), await pi(), await gi(), ht(!0), await Lt(), await yi(), await _e(), b.get("featureId") && P) {
1425
- const { data: n } = await In(b.get("featureId"));
1426
- if (n != null && n.permissions) {
1427
- const i = Ot(
1428
- n.permissions
1429
- );
1430
- if (((e = n == null ? void 0 : n.userMenuItemDtos) == null ? void 0 : e.length) > 0) {
1431
- const o = Ut(
1432
- i,
1433
- n.userMenuItemDtos
1434
- ).map((u) => ({
1435
- ...u,
1436
- permissions: St(u.permissions)
1437
- }));
1438
- We(o);
1439
- }
1440
- $e(i);
1441
- }
1442
- }
1443
- })();
1444
- }, []), ae(() => {
1445
- if (Le != null && Le.userMenuItemDtos) {
1446
- const e = a.getValues("updatedFields") || [], n = e == null ? void 0 : e.reduce((r, o) => (r[o.name] = o.enabled, r), {}), i = Le.userMenuItemDtos.map((r) => {
1447
- let o = {};
1448
- try {
1449
- o = r.featureJson ? JSON.parse(r.featureJson) : {};
1450
- } catch (d) {
1451
- console.warn("Invalid JSON in featureJson:", d);
1452
- }
1453
- const u = {
1454
- ...n,
1455
- ...o
1456
- };
1457
- return {
1458
- ...r,
1459
- featureJson: JSON.stringify(u)
1460
- };
1461
- });
1462
- ze(i);
1463
- }
1464
- }, [Le]), ae(() => {
1465
- try {
1466
- const e = b.get("featureId");
1467
- if (b.get("featureType") && e) {
1468
- const i = async () => {
1469
- var r;
1470
- if (l != null && l.val) {
1471
- const { data: o } = await In(e);
1472
- if (Vt(!0), await zt(), o != null && o.permissions) {
1473
- const u = Ot(
1474
- o.permissions
1475
- );
1476
- if (((r = o == null ? void 0 : o.userMenuItemDtos) == null ? void 0 : r.length) > 0) {
1477
- const h = Ut(
1478
- u,
1479
- o.userMenuItemDtos
1480
- ).map((y) => ({
1481
- ...y,
1482
- permissions: St(y.permissions)
1483
- }));
1484
- We(h);
1485
- }
1486
- $e(u);
1487
- }
1488
- Dt((u) => ({ ...u, value: !0, length: 0 }));
1489
- } else {
1490
- const { data: o } = await dr(e);
1491
- Mn(o), await zt();
1492
- const u = JSON.parse(o.featureJson || "{}"), d = Object.keys(u).map((h, y) => ({
1493
- id: y + 1,
1494
- value: h,
1495
- checkbox: u[h],
1496
- updated: !0
1497
- }));
1498
- a.setValue("updatedFields", d), at(d.length > 0), d.length > 0 && Vt(!0), Dt((h) => ({ ...h, value: !0, length: u.length || 0 })), Jn(o == null ? void 0 : o.isSeparateFeature);
1499
- }
1500
- };
1501
- Ct(), i();
1502
- }
1503
- } catch (e) {
1504
- me({
1505
- type: "error",
1506
- message: `error :${e == null ? void 0 : e.message}`
1507
- });
1508
- }
1509
- }, [b, a.setValue, ve, j]);
1510
- const Ot = (e) => {
1511
- const n = a.getValues("menuType"), i = a.getValues("featureConstant"), r = (d) => d.trim().toLowerCase().split(/\s+/).map(
1512
- (h, y) => y === 0 ? h : h.charAt(0).toUpperCase() + h.slice(1)
1513
- ).join("");
1514
- let o;
1515
- if (!P || (i == null ? void 0 : i.length) === 0) {
1516
- const d = a.getValues("menuName");
1517
- o = `view.${n}.${r(d)}`;
1518
- } else
1519
- o = `view.${n}.${i}`;
1520
- const u = (d) => {
1521
- const h = d.id === o;
1522
- return {
1523
- permissionId: d.id,
1524
- permissionType: { type: d.type },
1525
- permissionName: d.name,
1526
- permissionDesc: d.desc || "",
1527
- enabled: d.is_active,
1528
- isDefault: h,
1529
- childPermissions: d.child ? d.child.map((y) => u(y)) : [],
1530
- urlType: (d == null ? void 0 : d.httpMethod) || "",
1531
- backendUrl: (d == null ? void 0 : d.url) || "",
1532
- queryCodeRequired: !(d != null && d.url),
1533
- queryCode: (d == null ? void 0 : d.queryCodes) || ""
1534
- };
1535
- };
1536
- return e.map(u);
1537
- }, Ut = (e, n) => {
1538
- if (!Array.isArray(n)) return [];
1539
- const i = (r, o) => {
1540
- var y;
1541
- const u = ((y = r.childPermissions) == null ? void 0 : y.map(
1542
- (F) => i(F, o)
1543
- )) || [], d = u.some((F) => F.enabled), h = o.includes(r.permissionId) || d;
1544
- return { ...r, enabled: h, childPermissions: u };
1545
- };
1546
- return n.map((r) => {
1547
- var y, F, k, ue, X, se, oe;
1548
- const o = ((y = r.permissions) == null ? void 0 : y.map((Nt) => Nt.id)) || [], u = !!r.roleName || !!r.designationId || !!r.roleId, d = !!r.userId || !!r.fullName, h = e.map(
1549
- (Nt) => i(Nt, o)
1550
- );
1551
- return {
1552
- entityType: u ? "role" : "user",
1553
- user_id: d && r.userId || null,
1554
- role_id: u && (r.designationId || r.roleId) || null,
1555
- name: d ? r.fullName || "" : r.roleName || "",
1556
- startDate: ((k = (F = r.permissions) == null ? void 0 : F[0]) == null ? void 0 : k.startDate) || null,
1557
- endDate: ((X = (ue = r.permissions) == null ? void 0 : ue[0]) == null ? void 0 : X.endDate) || null,
1558
- isBackendOnly: ((oe = (se = r.permissions) == null ? void 0 : se[0]) == null ? void 0 : oe.isBackendOnly) || !1,
1559
- permissions: h
1560
- };
1561
- });
1562
- }, St = (e) => {
1563
- const n = (i) => {
1564
- var o, u;
1565
- let r = [];
1566
- if ((o = i.childPermissions) != null && o.length) {
1567
- r = i.childPermissions.map(n);
1568
- const d = r.every((h) => h.enabled);
1569
- i.enabled = i.enabled || d;
1570
- }
1571
- return i.enabled && ((u = i.childPermissions) != null && u.length) && (r = r.map((d) => {
1572
- var h;
1573
- return {
1574
- ...d,
1575
- enabled: !0,
1576
- childPermissions: (h = d.childPermissions) != null && h.length ? St(d.childPermissions) : []
1577
- };
1578
- })), {
1579
- ...i,
1580
- childPermissions: r
1581
- };
1582
- };
1583
- return e.map(n);
1584
- }, li = (e, n) => {
1585
- const i = /* @__PURE__ */ new Map(), r = (u) => {
1586
- u.forEach((d) => {
1587
- var h;
1588
- i.set(d.permissionId, d), (h = d.childPermissions) != null && h.length && r(d.childPermissions);
1589
- });
1590
- };
1591
- r(e);
1592
- const o = (u, d) => u.map((h) => {
1593
- const y = (d == null ? void 0 : d.find((k) => k.permissionId === h.permissionId)) || {}, F = o(
1594
- h.childPermissions || [],
1595
- y.childPermissions || []
1596
- );
1597
- return {
1598
- ...h,
1599
- enabled: y.enabled ?? h.enabled,
1600
- childPermissions: F
1601
- };
1602
- });
1603
- return n.map((u) => ({
1604
- ...u,
1605
- permissions: o(e, u.permissions)
1606
- }));
1607
- }, di = async () => {
1608
- try {
1609
- const e = (await G({
1610
- code: "RETREIVE_DYNAMIC_FEATURE_INFO",
1611
- parameters: {
1612
- id: parseInt(b.get("featureId")),
1613
- menuType: b.get("featureType")
1614
- }
1615
- })).data;
1616
- if (e.result) {
1617
- let n = e.result[0];
1618
- const i = (() => {
1619
- try {
1620
- return n.mobile_config ? JSON.parse(n.mobile_config) : {};
1621
- } catch {
1622
- return {};
1623
- }
1624
- })(), o = ((i == null ? void 0 : i.mobile_entities_sync) ?? []).map(
1625
- (h) => Z == null ? void 0 : Z.find((y) => y.tableName === h)
1626
- ).filter(Boolean);
1627
- a.reset({
1628
- menuName: n.menuName ? n.menuName : "",
1629
- featureConstant: n.featureConstant ? n.featureConstant : "",
1630
- navigationState: n.navigationState ? n.navigationState : "medplat.form",
1631
- isDynamicFeature: n.isDynamicFeature !== void 0 && n.isDynamicFeature !== null ? n.isDynamicFeature : !1,
1632
- menuType: n.menuType ? n.menuType : "",
1633
- menuGroup: n.group_id ? n.group_id.toString() : "",
1634
- isWebFeature: n.isWebFeature ? n.isWebFeature : !1,
1635
- isMobileFeature: n.isMobileFeature ? n.isMobileFeature : !1,
1636
- entityName: (i == null ? void 0 : i.entity_name) ?? "",
1637
- mobileMode: (i == null ? void 0 : i.mobile_mode) ?? null,
1638
- icon: (i == null ? void 0 : i.icon) ?? "",
1639
- mobileEntitiesSync: i != null && i.mobile_entities_sync ? i.mobile_entities_sync : [],
1640
- conditions: (i == null ? void 0 : i.conditions) ?? "",
1641
- formCode: n.formCode ? n.formCode : "",
1642
- version: n.currentVersion ? n.currentVersion : "",
1643
- trainingRequired: (i == null ? void 0 : i.training_required) ?? !1,
1644
- trainingQuery: (i == null ? void 0 : i.training_query) ?? "",
1645
- notificationBadgeEnabled: (i == null ? void 0 : i.notification_badge_enabled) ?? !1,
1646
- notificationBadgeType: (i == null ? void 0 : i.notification_badge_type) ?? "",
1647
- notificationBadgeQuery: (i == null ? void 0 : i.notification_badge_query) ?? ""
1648
- }), re(o), n.isMobileFeature && W(!0);
1649
- const u = (i == null ? void 0 : i.training_query) ?? "", d = (i == null ? void 0 : i.notification_badge_query) ?? "";
1650
- u && (je(u), _e(u)), d && (Ge(d), _e(d)), n.formCode && (ye(n.formCode), Pe(n.formCode)), Ct(), Ke(!0);
1651
- }
1652
- } catch (e) {
1653
- me({
1654
- message: e.message,
1655
- type: "error"
1656
- });
1657
- }
1658
- }, zt = async () => {
1659
- try {
1660
- const e = (await G({
1661
- code: "RETREIVE_DYNAMIC_FEATURE_INFO",
1662
- parameters: {
1663
- id: parseInt(b.get("featureId")),
1664
- menuType: b.get("featureType")
1665
- }
1666
- })).data;
1667
- if (e.result) {
1668
- let n = e.result[0];
1669
- const i = (() => {
1670
- try {
1671
- return n.mobile_config ? JSON.parse(n.mobile_config) : {};
1672
- } catch {
1673
- return {};
1674
- }
1675
- })(), r = (y, F = null) => {
1676
- try {
1677
- return !y || typeof y != "string" ? F : JSON.parse(y);
1678
- } catch {
1679
- return F;
1680
- }
1681
- }, u = ((i == null ? void 0 : i.mobile_entities_sync) ?? []).map(
1682
- (y) => Z == null ? void 0 : Z.find((F) => F.tableName === y)
1683
- ).filter(Boolean);
1684
- a.setValue("menuName", n.menuName ? n.menuName : ""), a.setValue(
1685
- "navigationState",
1686
- n.navigationState ? n.navigationState : ""
1687
- ), a.setValue(
1688
- "isDynamicFeature",
1689
- n.isDynamicFeature !== void 0 && n.isDynamicFeature !== null ? n.isDynamicFeature : !1
1690
- ), a.setValue("menuType", n.menuType ? n.menuType : ""), a.setValue(
1691
- "menuGroup",
1692
- n.group_id ? n.group_id.toString() : ""
1693
- ), a.setValue(
1694
- "isWebFeature",
1695
- n.isWebFeature ? n.isWebFeature : !1
1696
- ), a.setValue(
1697
- "isMobileFeature",
1698
- n.isMobileFeature ? n.isMobileFeature : !1
1699
- ), a.setValue("entityName", (i == null ? void 0 : i.entity_name) ?? ""), a.setValue("mobileMode", (i == null ? void 0 : i.mobile_mode) ?? null), a.setValue("icon", (i == null ? void 0 : i.icon) ?? ""), a.setValue(
1700
- "mobileEntitiesSync",
1701
- (i == null ? void 0 : i.mobile_entities_sync) ?? []
1702
- ), a.setValue("conditions", (i == null ? void 0 : i.conditions) ?? ""), a.setValue(
1703
- "trainingRequired",
1704
- (i == null ? void 0 : i.training_required) ?? !1
1705
- ), a.setValue("trainingQuery", (i == null ? void 0 : i.training_query) ?? ""), a.setValue(
1706
- "notificationBadgeEnabled",
1707
- (i == null ? void 0 : i.notification_badge_enabled) ?? !1
1708
- ), a.setValue(
1709
- "notificationBadgeType",
1710
- (i == null ? void 0 : i.notification_badge_type) ?? ""
1711
- ), a.setValue(
1712
- "notificationBadgeQuery",
1713
- (i == null ? void 0 : i.notification_badge_query) ?? ""
1714
- ), re(u), n.isMobileFeature && W(!0);
1715
- const d = (i == null ? void 0 : i.training_query) ?? "", h = (i == null ? void 0 : i.notification_badge_query) ?? "";
1716
- d && (je(d), _e(d)), h && (Ge(h), _e(h)), Ke(!0);
1717
- }
1718
- } catch (e) {
1719
- me({
1720
- message: e.message,
1721
- type: "error"
1722
- });
1723
- }
1724
- }, ci = () => {
1725
- const e = a.getValues("menuType") || "menuType", n = a.getValues("featureConstant") || "feature", i = (u) => u.trim().toLowerCase().split(/\s+/).map(
1726
- (d, h) => h === 0 ? d : d.charAt(0).toUpperCase() + d.slice(1)
1727
- ).join("");
1728
- let r;
1729
- if (P)
1730
- r = `view.${e}.${n}`;
1731
- else {
1732
- const u = a.getValues("menuName");
1733
- r = `view.${e}.${i(u)}`;
1734
- }
1735
- const o = {
1736
- permissionId: r,
1737
- permissionType: { type: "menu" },
1738
- permissionName: `view ${n}`,
1739
- permissionDesc: "",
1740
- enabled: !0,
1741
- isDefault: !0,
1742
- childPermissions: [],
1743
- ...P === !1 && {
1744
- backendUrl: "",
1745
- urlType: "",
1746
- queryCode: ""
1747
- }
1748
- };
1749
- $e([o]);
1750
- }, ui = (e) => {
1751
- w(e);
1752
- }, mi = (e) => {
1753
- const n = (e == null ? void 0 : e.map((i) => i == null ? void 0 : i.tableName)) || [];
1754
- re(e), a.setValue("mobileEntitiesSync", n);
1755
- }, fi = (e, n) => {
1756
- Fe(n);
1757
- };
1758
- ae(() => {
1759
- const e = (b == null ? void 0 : b.get("staticOrDynamic")) === "STATIC";
1760
- ve && j && b.get("featureId") && !e && di();
1761
- }, [ve, j]);
1762
- const hi = async () => {
1763
- const e = (await G({
1764
- code: "fetch_menu_groups"
1765
- })).data;
1766
- Ze(e.result.map((n) => n.menu_type)), V(e.result);
1767
- }, pi = async () => {
1768
- const e = (await G({
1769
- code: "mfa_retreive_all_table_names"
1770
- })).data;
1771
- de(e.result.map((n) => n.table_name));
1772
- }, gi = async () => {
1773
- const e = (await G({
1774
- code: "retrieve_synced_tables"
1775
- })).data;
1776
- z(e == null ? void 0 : e.result);
1777
- }, Lt = async () => {
1778
- const e = (await G({
1779
- code: "mfa_retrieve_separate_feature_forms"
1780
- })).data;
1781
- if (e.result) {
1782
- let n = e.result;
1783
- Q(n);
1784
- let i = {};
1785
- return n.forEach((r) => {
1786
- try {
1787
- const o = JSON.parse(r.versions);
1788
- i[r.form_code] = o;
1789
- } catch (o) {
1790
- console.error("Invalid JSON in form.versions:", r.versions, o), i[r.form_code] = [];
1791
- }
1792
- }), pe(i), i;
1793
- }
1794
- }, yi = async () => {
1795
- try {
1796
- const { data: e } = await G({
1797
- code: "user_search_for_selectize",
1798
- parameters: {
1799
- searchString: ""
1800
- }
1801
- });
1802
- Oe(e == null ? void 0 : e.result);
1803
- const n = await $i();
1804
- p(n.data);
1805
- } catch (e) {
1806
- console.error("Error fetching users or roles:", e);
1807
- }
1808
- }, _e = async (e = "") => {
1809
- try {
1810
- const n = (await G({
1811
- code: "GET_ALL_QUERY_CODE",
1812
- parameters: { search: e }
1813
- })).data;
1814
- Hn((n == null ? void 0 : n.result) || []);
1815
- } catch (n) {
1816
- console.error("Error fetching query codes:", n);
1817
- }
1818
- }, $t = () => a.getValues("isMobileFeature") && a.getValues("isWebFeature") ? be : be.filter((e) => {
1819
- const { roleType: n } = e;
1820
- return !!(n === null || a.getValues("isMobileFeature") && (n === "MOBILE" || n === "BOTH") || a.getValues("isWebFeature") && (n === "WEB" || n === "BOTH"));
1821
- });
1822
- ae(() => {
1823
- if (!(be != null && be.length)) return;
1824
- const e = Ue.filter((n) => {
1825
- if (!n.roleName) return !0;
1826
- const i = be.find((o) => o.name === n.roleName);
1827
- if (!i) return !0;
1828
- const { roleType: r } = i;
1829
- return !(!Wt && r === "MOBILE" || !qt && r === "WEB");
1830
- });
1831
- ze(e);
1832
- }, [Wt, qt, be]);
1833
- const bi = (e) => {
1834
- const { firstName: n, lastName: i, userName: r } = e;
1835
- return !n && !i && !r ? "" : n && !i && !r ? n : `${n} ${i} (${r})`;
1836
- }, Ct = () => {
1837
- ie(() => {
1838
- const e = a.getValues("menuType") ? JSON.parse(
1839
- j == null ? void 0 : j.find(
1840
- (i) => i.menu_type === a.getValues("menuType")
1841
- ).groupNames
1842
- ) : null, n = e == null ? void 0 : e.filter((i) => i.id !== null);
1843
- return n != null && n.length || a.setValue("menuGroup", ""), n;
1844
- });
1845
- }, xi = (e) => {
1846
- a.setValue("menuGroup", e.target.value);
1847
- }, Si = (e) => {
1848
- e.target.checked ? W(!0) : (W(!1), a.setValue("entityName", null), a.setValue("icon", null), a.setValue("mobileEntitiesSync", null), a.setValue("conditions", null), a.setValue("mobileMode", null));
1849
- }, Ci = (e) => {
1850
- e.target.checked || (a.setValue("formCode", null), a.setValue("version", null));
1851
- }, Ni = () => {
1852
- tt("add-parent"), nt(null), it(null), rt(null), Qe(!0);
1853
- }, ki = (e) => {
1854
- tt("add-child"), nt(e.permissionId), it(null), rt(null), Qe(!0);
1855
- }, Ii = (e) => {
1856
- tt("edit"), nt(null), it(e), rt(e.permissionId), Qe(!0);
1857
- }, Qt = (e, n, i) => e.map((r) => r.permissionId === n ? {
1858
- ...r,
1859
- childPermissions: [...r.childPermissions || [], i]
1860
- } : {
1861
- ...r,
1862
- childPermissions: Qt(
1863
- r.childPermissions || [],
1864
- n,
1865
- i
1866
- )
1867
- }), Jt = (e, n, i) => e.map((r) => r.permissionId === n ? {
1868
- ...i,
1869
- childPermissions: r.childPermissions || []
1870
- } : {
1871
- ...r,
1872
- childPermissions: Jt(
1873
- r.childPermissions || [],
1874
- n,
1875
- i
1876
- )
1877
- }), jt = (e, n) => e.filter((i) => i.permissionId !== n).map((i) => ({
1878
- ...i,
1879
- childPermissions: jt(
1880
- i.childPermissions || [],
1881
- n
1882
- )
1883
- })), wi = (e) => {
1884
- $e((n) => {
1885
- let i = [...n];
1886
- if (Je === "add-parent")
1887
- i = [...n, e];
1888
- else if (Je === "add-child") {
1889
- const r = (d, h) => {
1890
- var y;
1891
- for (const F of d) {
1892
- if (F.permissionId === h) return F;
1893
- if ((y = F.childPermissions) != null && y.length) {
1894
- const k = r(F.childPermissions, h);
1895
- if (k) return k;
1896
- }
1897
- }
1898
- return null;
1899
- }, o = r(n, pt), u = {
1900
- ...e,
1901
- permissionType: typeof o.permissionType == "string" ? { type: o.permissionType } : o.permissionType
1902
- };
1903
- i = Qt(
1904
- n,
1905
- pt,
1906
- u
1907
- );
1908
- } else Je === "edit" && (i = Jt(
1909
- n,
1910
- Un,
1911
- e
1912
- ));
1913
- return i;
1914
- }), Qe(!1), tt("add-parent"), nt(null), it(null), rt(null);
1915
- }, vi = (e) => {
1916
- const n = typeof e == "string" ? e : e.permissionId;
1917
- $e((i) => jt(i, n));
1918
- };
1919
- ae(() => {
1920
- a.setValue("additionalPermissions", ce);
1921
- }, [ce, a]);
1922
- const st = (e, n = null) => {
1923
- let i = [];
1924
- return e.forEach((r) => {
1925
- const {
1926
- permissionId: o,
1927
- permissionType: u,
1928
- permissionName: d,
1929
- permissionDesc: h,
1930
- enabled: y,
1931
- backendUrl: F,
1932
- urlType: k,
1933
- queryCode: ue
1934
- } = r;
1935
- i.push({
1936
- permissionId: o,
1937
- permissionType: u == null ? void 0 : u.type,
1938
- permissionName: d,
1939
- permissionDesc: h,
1940
- parentPermissionId: n,
1941
- enabled: y,
1942
- backendUrl: F,
1943
- urlType: k,
1944
- queryCode: ue
1945
- }), r.childPermissions && r.childPermissions.length > 0 && (i = i.concat(
1946
- st(r.childPermissions, o)
1947
- ));
1948
- }), i;
1949
- }, Fi = () => {
1950
- (async () => {
1951
- let e = await Lt();
1952
- pe(e), ye(a.getValues("formCode"));
1953
- })();
1954
- }, Gt = JSON.stringify(
1955
- (nn = K.value ? a.getValues("updatedFields") : a.getValues("fields")) == null ? void 0 : nn.reduce((e, n) => {
1956
- var i;
1957
- return (i = n.value) != null && i.trim() && (e[n.value.trim()] = n.checkbox), e;
1958
- }, {})
1959
- ), Ti = () => {
1960
- if (!P && (l == null ? void 0 : l.val) === !1)
1961
- try {
1962
- const e = [];
1963
- _ != null && _.id && e.push({
1964
- designationId: null,
1965
- userId: _.id,
1966
- fullName: `${_.firstName || ""} ${_.lastName || ""}`.trim(),
1967
- featureJson: Gt
1968
- }), (g == null ? void 0 : g.length) > 0 && e.push(
1969
- ...g.map((n) => ({
1970
- designationId: n.id,
1971
- roleName: n.name,
1972
- featureJson: Gt
1973
- }))
1974
- ), ze((n) => [...n, ...e]), me({
1975
- message: "Menu item added successfully",
1976
- type: "success"
1977
- }), w([]), Fe({});
1978
- } catch (e) {
1979
- console.error(e), me({
1980
- message: "Cannot add menu item",
1981
- type: "error"
1982
- });
1983
- }
1984
- else {
1985
- const e = [];
1986
- if (_ != null && _.id && e.push({
1987
- type: "user",
1988
- id: _.id,
1989
- name: _.firstName + " " + _.lastName
1990
- }), g.length > 0 && e.push({
1991
- type: "role",
1992
- ids: g.map((n) => n.id),
1993
- names: g.map((n) => n.name)
1994
- }), e.length === 0) return;
1995
- $n(e), gt(!0), Fe(null), w([]);
1996
- }
1997
- }, Ht = (e) => {
1998
- const n = [], i = (r, o) => {
1999
- for (const u of r)
2000
- u.enabled && n.push({
2001
- permission_id: u.permissionId,
2002
- user_id: o.user_id || null,
2003
- role_id: o.role_id || null,
2004
- is_backend_only: o.isBackendOnly || !1,
2005
- start_date: o.startDate || null,
2006
- end_date: o.endDate || null
2007
- });
2008
- };
2009
- for (const r of e)
2010
- i(r.permissions || [], r);
2011
- return n;
2012
- }, _i = (e, n) => {
2013
- We((i) => {
2014
- const r = [...i];
2015
- return r[e] = {
2016
- ...r[e],
2017
- permissions: Yt(
2018
- r[e].permissions,
2019
- n.permissionId,
2020
- !n.enabled
2021
- )
2022
- }, r;
2023
- });
2024
- }, Yt = (e, n, i) => e.map((o) => {
2025
- var u, d;
2026
- if (o.permissionId === n)
2027
- return {
2028
- ...o,
2029
- enabled: i,
2030
- childPermissions: (u = o.childPermissions) != null && u.length ? Kt(o.childPermissions, i) : []
2031
- };
2032
- if ((d = o.childPermissions) != null && d.length) {
2033
- const h = Yt(
2034
- o.childPermissions,
2035
- n,
2036
- i
2037
- ), y = h.length > 0 && h.every((F) => F.enabled === !0);
2038
- return {
2039
- ...o,
2040
- enabled: y,
2041
- childPermissions: h
2042
- };
2043
- }
2044
- return o;
2045
- }), Kt = (e, n) => e.map((i) => {
2046
- var r;
2047
- return {
2048
- ...i,
2049
- enabled: n,
2050
- childPermissions: (r = i.childPermissions) != null && r.length ? Kt(i.childPermissions, n) : []
2051
- };
2052
- }), Vi = async (e) => {
2053
- (await G({
2054
- code: "check_unique_feature_constant",
2055
- parameters: {
2056
- featureConstant: e
2057
- }
2058
- })).data.result[0].exists ? a.setError("featureConstant", {
2059
- type: "manual",
2060
- message: "Feature constant already exists"
2061
- }) : B(`${e} Feature constant is available`);
2062
- }, Ei = async (e) => {
2063
- (await G({
2064
- code: "CHECK_UNIQUE_NAVIGATION_STATE",
2065
- parameters: {
2066
- featureState: e
2067
- }
2068
- })).data.result[0].exists ? a.setError("navigationState", {
2069
- type: "manual",
2070
- message: "Feature State already exists"
2071
- }) : B(`${e} Feature State is available`);
2072
- }, Di = fn(Vi, 500), Pi = fn(
2073
- Ei,
2074
- 500
2075
- ), Zt = Gi(
2076
- async (e, n, i) => {
2077
- const { data: r } = await G({
2078
- code: "user_search_for_selectize",
2079
- parameters: {
2080
- searchString: e
2081
- }
2082
- });
2083
- n(r.result), i({ firstName: e, lastName: "", userName: "" });
2084
- },
2085
- 500
2086
- ), Ai = async (e) => {
2087
- const n = st(ce);
2088
- let i = {
2089
- code: "insert_dynamic_feature_into_menu_config",
2090
- parameters: {
2091
- menuName: e.menuName ? e.menuName : null,
2092
- featureConstant: e.featureConstant ? e.featureConstant : null,
2093
- formCode: e.formCode && e.formCode !== "" ? e.formCode : null,
2094
- prevFormCode: we || null,
2095
- deLinkPrevForm: we !== e.formCode,
2096
- menuType: e.menuType ? e.menuType : null,
2097
- menuGroup: e.menuGroup ? parseInt(e.menuGroup) : null,
2098
- navigationState: e.navigationState && e.formCode && e.formCode !== "" ? e.navigationState : null,
2099
- formVersion: e.version ? e.version : null,
2100
- isMobileFeature: e.isMobileFeature ? e.isMobileFeature : null,
2101
- isWebFeature: e.isWebFeature ? e.isWebFeature : null,
2102
- permissions: JSON.stringify(n),
2103
- mobileConfig: JSON.stringify({
2104
- entity_name: e.entityName ?? null,
2105
- mobile_mode: e.mobileMode ? e.mobileMode.toUpperCase() : null,
2106
- icon: e.icon ?? null,
2107
- mobile_entities_sync: e.mobileEntitiesSync ?? [],
2108
- conditions: e.conditions ?? null,
2109
- training_required: e.trainingRequired ?? !1,
2110
- training_query: e.trainingQuery ?? null,
2111
- notification_badge_enabled: e.notificationBadgeEnabled ?? !1,
2112
- notification_badge_type: e.notificationBadgeType ?? null,
2113
- notification_badge_query: e.notificationBadgeQuery ?? null
2114
- })
2115
- }
2116
- };
2117
- try {
2118
- if (await G(i)) {
2119
- let o = [];
2120
- e.menuName && e.menuName.length > 0 && o.push({
2121
- code: "medplat_form_insert_into_translation_master",
2122
- parameters: {
2123
- translation_key: e.menuName.replaceAll(" ", ""),
2124
- translation_value: e.menuName,
2125
- form_code: "General"
2126
- },
2127
- sequence: 1
2128
- }), o.length > 0 && await Ft(o);
2129
- const u = Ht(Ne);
2130
- u && await G({
2131
- code: "GRANT_PERMISSION_USER_MAP",
2132
- parameters: {
2133
- permissionUserMap: JSON.stringify(u)
2134
- }
2135
- });
2136
- }
2137
- me({
2138
- message: b.get("featureId") ? "Feature updated successfully" : "New Dynamic feature created successfully!",
2139
- type: "success"
2140
- }), Xe(!0);
2141
- } catch (r) {
2142
- me({
2143
- message: r.message,
2144
- type: "error"
2145
- });
2146
- }
2147
- }, Wi = async (e) => {
2148
- var n, i, r, o;
2149
- try {
2150
- let u = null, d = null, h = null;
2151
- const y = hn();
2152
- (n = e == null ? void 0 : e.menuGroup) != null && n.length && (u = hn());
2153
- const F = st(ce), k = {
2154
- code: "insert_menu_config",
2155
- parameters: {
2156
- UUID: y,
2157
- featureJson: null,
2158
- menuGroup: e.menuGroup ? parseInt(e.menuGroup) : null,
2159
- groupUUID: u,
2160
- menuName: e.menuName ? e.menuName : null,
2161
- menuType: e.menuType ? e.menuType : null,
2162
- navigationState: e.navigationState ? e.navigationState : null,
2163
- subgroupId: d,
2164
- subgroupUUID: h,
2165
- isMobileFeature: e != null && e.isMobileFeature ? e == null ? void 0 : e.isMobileFeature : null,
2166
- isWebFeature: e != null && e.isWebFeature ? e == null ? void 0 : e.isWebFeature : null,
2167
- permissions: JSON.stringify(F),
2168
- isNewFeature: "true",
2169
- mobileConfig: JSON.stringify({
2170
- entity_name: (e == null ? void 0 : e.entityName) ?? null,
2171
- mobile_mode: e != null && e.mobileMode ? e == null ? void 0 : e.mobileMode.toUpperCase() : null,
2172
- icon: (e == null ? void 0 : e.icon) ?? null,
2173
- mobile_entities_sync: (e == null ? void 0 : e.mobileEntitiesSync) ?? [],
2174
- conditions: (e == null ? void 0 : e.conditions) ?? null,
2175
- training_required: e.trainingRequired ?? !1,
2176
- training_query: e.trainingQuery ?? null,
2177
- notification_badge_enabled: e.notificationBadgeEnabled ?? !1,
2178
- notification_badge_type: e.notificationBadgeType ?? null,
2179
- notification_badge_query: e.notificationBadgeQuery ?? null
2180
- })
2181
- }
2182
- };
2183
- if (K.value && (l == null ? void 0 : l.val) === !1) {
2184
- k.code = "update_menu_config";
2185
- const { fields: X, updatedFields: se } = e, oe = K.value && Te ? en(se) : (i = X[0]) != null && i.value && Te ? en(X) : {};
2186
- a.setValue("featureJson", oe), delete k.parameters.UUID, delete k.parameters.groupUUID, delete k.parameters.subgroupUUID, delete k.parameters.permissions, delete k.parameters.isNewFeature, k.parameters.featureType = b.get("featureType"), k.parameters.featureId = b.get("featureId"), k.parameters.featureJson = oe;
2187
- }
2188
- let ue;
2189
- if (K.value && (l == null ? void 0 : l.val) === !1) {
2190
- const { data: X } = await Qi(k);
2191
- ue = X, await cr((r = X == null ? void 0 : X.result[0]) == null ? void 0 : r.id, Ue);
2192
- } else {
2193
- K.value && (delete k.parameters.UUID, delete k.parameters.groupUUID, delete k.parameters.subgroupUUID, delete k.parameters.isNewFeature, k.parameters.featureType = b.get("featureType"), k.parameters.featureId = b.get("featureId"));
2194
- const { data: X } = await G(k);
2195
- if (ue = X, X) {
2196
- let se = [];
2197
- e.menuName && e.menuName.length > 0 && se.push({
2198
- code: "medplat_form_insert_into_translation_master",
2199
- parameters: {
2200
- translation_key: e.menuName.replaceAll(" ", ""),
2201
- translation_value: e.menuName,
2202
- form_code: "General"
2203
- },
2204
- sequence: 1
2205
- }), se.length > 0 && await Ft(se);
2206
- const oe = Ht(Ne);
2207
- oe && await G({
2208
- code: "GRANT_PERMISSION_USER_MAP",
2209
- parameters: {
2210
- permissionUserMap: JSON.stringify(oe)
2211
- }
2212
- });
2213
- }
2214
- }
2215
- (o = ue == null ? void 0 : ue.result) != null && o.length ? me({
2216
- message: K.value ? "FEATURE EDITED SUCCESFULLY" : "FEATURE ADDED SUCCESFULLY",
2217
- type: "success"
2218
- }) : me({
2219
- message: "FEATURE CONFIGURATION ALREADY EXISTS ",
2220
- type: "error"
2221
- }), Xe(!0);
2222
- } catch (u) {
2223
- me({
2224
- message: u.message,
2225
- type: "error"
2226
- });
2227
- }
2228
- }, Xt = async (e) => {
2229
- P ? Ai(e) : Wi(e);
2230
- }, en = (e) => JSON.stringify(
2231
- e == null ? void 0 : e.reduce((n, i) => (n[i.value] = i.checkbox, n), {})
2232
- ), qi = (e, n) => {
2233
- e && e.type === "change" && Ri(n);
2234
- }, Ri = rr(
2235
- (e) => {
2236
- Zt(e, Oe, Fe);
2237
- },
2238
- [Zt]
2239
- ), Mi = () => {
2240
- at(!Te), Te || (K.value ? a.setValue("updatedFields", [
2241
- { id: 1, value: "", checkbox: !1 }
2242
- ]) : a.setValue("fields", [{ id: 1, value: "", checkbox: !1 }]));
2243
- }, Bi = (e) => {
2244
- const i = (K.value ? a.getValues("updatedFields") : a.getValues("fields")).map((r) => r.id === e ? { ...r, checkbox: !r.checkbox } : r);
2245
- K.value ? a.setValue("updatedFields", i) : a.setValue("fields", i);
2246
- }, Oi = () => {
2247
- const e = K.value ? a.getValues("updatedFields") : a.getValues("fields"), n = e[(e == null ? void 0 : e.length) - 1];
2248
- if ((n == null ? void 0 : n.value.trim()) === "") {
2249
- alert("Enter the right name before adding a new one.");
2250
- return;
2251
- }
2252
- const i = {
2253
- id: e.length + 1,
2254
- value: "",
2255
- checkbox: !1
2256
- };
2257
- K.value ? a.setValue("updatedFields", [...e, i]) : a.setValue("fields", [...e, i]);
2258
- }, Ui = (e) => {
2259
- const i = (K.value ? a.getValues("updatedFields") : a.getValues("fields")).filter((r) => r.id !== e);
2260
- K.value ? a.setValue("updatedFields", i) : a.setValue("fields", i), (i == null ? void 0 : i.length) === 0 && (K.value ? at(!0) : at(!1));
2261
- };
2262
- return /* @__PURE__ */ t(
2263
- "form",
2264
- {
2265
- noValidate: !0,
2266
- ref: M,
2267
- onSubmit: a.handleSubmit(Xt),
2268
- method: "POST",
2269
- children: /* @__PURE__ */ t(c, { sx: { width: "100%", p: 3, borderRadius: 2 }, children: /* @__PURE__ */ s(c, { sx: { display: "flex" }, children: [
2270
- /* @__PURE__ */ t(
2271
- c,
2272
- {
2273
- sx: {
2274
- width: "30%",
2275
- maxHeight: "87vh",
2276
- background: `linear-gradient(to right, ${C.palette.custom.featureList || "#3576BA"}, ${C.palette.custom.black2 || "#1C2128"})`,
2277
- p: 3,
2278
- borderTopLeftRadius: 16,
2279
- borderBottomLeftRadius: 16,
2280
- borderTopRightRadius: 0,
2281
- borderBottomRightRadius: 0,
2282
- display: "flex",
2283
- flexDirection: "column",
2284
- justifyContent: "center",
2285
- gap: 5
2286
- },
2287
- children: q.map((e, n) => {
2288
- const i = n === L, r = oi(n), o = He.some((F) => F.key === e.key) && !r && !i, u = !o && !r && !i;
2289
- let d = "transparent", h = "2px solid rgba(255,255,255,0.5)", y = "white";
2290
- return i ? (d = "#BEE2FD", y = "#1e3a8a", h = "2px solid #BEE2FD") : r ? (d = "white", y = "#4caf50", h = "2px solid #4caf50") : o ? (d = "transparent", y = "white", h = "2px solid #BEE2FD") : u && (d = "transparent", y = "rgba(255,255,255,0.5)", h = "2px solid rgba(255,255,255,0.2)"), /* @__PURE__ */ t(Hi, { sx: { p: 0, m: 0 }, children: /* @__PURE__ */ s(
2291
- c,
2292
- {
2293
- sx: {
2294
- display: "flex",
2295
- alignItems: "center",
2296
- position: "relative",
2297
- backgroundColor: i ? "custom.gray3" : "transparent",
2298
- px: 1,
2299
- py: 1,
2300
- transition: "all 0.3s ease",
2301
- borderRadius: 2,
2302
- minHeight: 64
2303
- },
2304
- children: [
2305
- n < (q == null ? void 0 : q.length) - 1 && /* @__PURE__ */ t(
2306
- c,
2307
- {
2308
- sx: {
2309
- position: "absolute",
2310
- top: "45%",
2311
- left: 22,
2312
- height: "calc(100% + -10px)",
2313
- width: 2,
2314
- backgroundColor: "white",
2315
- opacity: u ? 0.3 : 1,
2316
- zIndex: 0,
2317
- transform: "translateY(50%)"
2318
- }
2319
- }
2320
- ),
2321
- /* @__PURE__ */ t(
2322
- c,
2323
- {
2324
- sx: {
2325
- width: 32,
2326
- height: 32,
2327
- borderRadius: "50%",
2328
- backgroundColor: d,
2329
- border: h,
2330
- color: y,
2331
- fontWeight: "bold",
2332
- fontSize: 14,
2333
- display: "flex",
2334
- alignItems: "center",
2335
- justifyContent: "center",
2336
- zIndex: 1,
2337
- flexShrink: 0
2338
- },
2339
- children: r && !i ? /* @__PURE__ */ t(le, { iconName: "faCheck", size: "lg" }) : n + 1
2340
- }
2341
- ),
2342
- /* @__PURE__ */ s(c, { sx: { ml: 2 }, children: [
2343
- /* @__PURE__ */ s(
2344
- f,
2345
- {
2346
- variant: "caption",
2347
- sx: {
2348
- color: r ? "primary.main" : "white",
2349
- fontWeight: "bold",
2350
- textTransform: "uppercase",
2351
- fontSize: 14,
2352
- opacity: u ? 0.5 : 1
2353
- },
2354
- children: [
2355
- "STEP ",
2356
- n + 1
2357
- ]
2358
- }
2359
- ),
2360
- /* @__PURE__ */ t(
2361
- f,
2362
- {
2363
- variant: "subtitle2",
2364
- sx: {
2365
- color: r ? "primary.main" : "white",
2366
- fontWeight: "bold",
2367
- textTransform: "uppercase",
2368
- fontSize: 14,
2369
- opacity: u ? 0.5 : 1
2370
- },
2371
- children: e.label
2372
- }
2373
- )
2374
- ] })
2375
- ]
2376
- }
2377
- ) }, e.key);
2378
- })
2379
- }
2380
- ),
2381
- /* @__PURE__ */ s(
2382
- c,
2383
- {
2384
- sx: {
2385
- width: "80%",
2386
- backgroundColor: "background.paper",
2387
- padding: 2,
2388
- borderRadius: "10px",
2389
- display: "flex",
2390
- flexDirection: "column",
2391
- maxHeight: "87vh",
2392
- overflowY: "auto"
2393
- },
2394
- children: [
2395
- ((rn = q[L]) == null ? void 0 : rn.key) === "featureDetails" && /* @__PURE__ */ t(c, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ s(c, { width: "80%", children: [
2396
- /* @__PURE__ */ t(
2397
- f,
2398
- {
2399
- variant: "h5",
2400
- sx: {
2401
- fontWeight: "bold",
2402
- textAlign: "center",
2403
- marginBottom: 1,
2404
- marginTop: 2
2405
- },
2406
- children: m("Feature Details")
2407
- }
2408
- ),
2409
- /* @__PURE__ */ t(
2410
- f,
2411
- {
2412
- sx: { textAlign: "center", marginBottom: 4, color: "grey" },
2413
- children: "Please provide the necessary details for the new feature, including its name, constant, and where it should be linked in the menu."
2414
- }
2415
- ),
2416
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2417
- te,
2418
- {
2419
- variant: "outlined",
2420
- className: "m-3 flex flex-row items-center w-[80%] justify-between",
2421
- children: [
2422
- /* @__PURE__ */ s(
2423
- f,
2424
- {
2425
- variant: "subtitle1",
2426
- className: "whitespace-nowrap",
2427
- children: [
2428
- m("Is"),
2429
- " ",
2430
- m("dynamic"),
2431
- " ",
2432
- m("feature? "),
2433
- ":"
2434
- ]
2435
- }
2436
- ),
2437
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
2438
- $,
2439
- {
2440
- name: "isDynamicFeature",
2441
- control: a.control,
2442
- rules: { required: "Required field" },
2443
- render: ({ field: e }) => /* @__PURE__ */ t(
2444
- Ie,
2445
- {
2446
- checked: e.value,
2447
- disabled: !!b.get("featureId"),
2448
- onChange: (n) => {
2449
- e.onChange(n.target.checked), Ci(n);
2450
- }
2451
- }
2452
- )
2453
- }
2454
- ) })
2455
- ]
2456
- }
2457
- ) }),
2458
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2459
- te,
2460
- {
2461
- variant: "outlined",
2462
- className: " m-3 flex flex-row items-center w-[80%] justify-between",
2463
- children: [
2464
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2465
- m("Feature"),
2466
- " ",
2467
- m("Name"),
2468
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" }),
2469
- " :"
2470
- ] }),
2471
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
2472
- ne,
2473
- {
2474
- control: a.control,
2475
- id: "menuName",
2476
- name: "menuName",
2477
- errors: a.formState.errors,
2478
- disabled: Et,
2479
- placeholder: "Feature Name"
2480
- }
2481
- ) })
2482
- ]
2483
- }
2484
- ) }),
2485
- P ? /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2486
- te,
2487
- {
2488
- variant: "outlined",
2489
- className: " m-3 flex flex-row items-center w-[80%] justify-between",
2490
- children: [
2491
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2492
- m("Feature"),
2493
- " ",
2494
- m("Constant"),
2495
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" }),
2496
- " :"
2497
- ] }),
2498
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
2499
- ne,
2500
- {
2501
- control: a.control,
2502
- id: "featureConstant",
2503
- name: "featureConstant",
2504
- errors: a.formState.errors,
2505
- successMessage: Se,
2506
- placeholder: "Feature Constant",
2507
- disabled: D,
2508
- onChange: (e) => Di(e.target.value)
2509
- }
2510
- ) })
2511
- ]
2512
- }
2513
- ) }, "static-feature") : /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2514
- te,
2515
- {
2516
- variant: "outlined",
2517
- className: " m-2 flex flex-row items-center w-[80%] justify-between",
2518
- children: [
2519
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2520
- m("Feature"),
2521
- " ",
2522
- m("State"),
2523
- /* @__PURE__ */ t("span", { className: "text-red-500 mx-1", children: "*" }),
2524
- /* @__PURE__ */ t(
2525
- ge,
2526
- {
2527
- title: /* @__PURE__ */ t(
2528
- f,
2529
- {
2530
- fontSize: 12,
2531
- maxWidth: 200,
2532
- sx: { whiteSpace: "pre-line" },
2533
- children: `Must follow one of these formats:
2534
- • techo.*
2535
- • medplat.*
2536
- • medplat.form.*`
2537
- }
2538
- ),
2539
- size: "sm"
2540
- }
2541
- )
2542
- ] }),
2543
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
2544
- ne,
2545
- {
2546
- control: a.control,
2547
- id: "navigationState",
2548
- name: "navigationState",
2549
- placeholder: "Feature State",
2550
- disabled: Et || D,
2551
- successMessage: Se,
2552
- dataTestId: "managefeature-textfield-feature-state",
2553
- errors: a.formState.errors,
2554
- onChange: (e) => Pi(
2555
- e.target.value
2556
- )
2557
- }
2558
- ) })
2559
- ]
2560
- }
2561
- ) }, "dynamic-feature"),
2562
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2563
- te,
2564
- {
2565
- variant: "outlined",
2566
- className: " m-3 flex flex-row items-center w-[80%] justify-between",
2567
- children: [
2568
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2569
- m("Link"),
2570
- " ",
2571
- m("to"),
2572
- " ",
2573
- m("Menu"),
2574
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" }),
2575
- " :"
2576
- ] }),
2577
- /* @__PURE__ */ t(c, { className: " w-[60%]", children: /* @__PURE__ */ t(
2578
- Ve,
2579
- {
2580
- control: a.control,
2581
- name: "menuType",
2582
- options: Re,
2583
- errors: a.formState.errors,
2584
- disableClearable: !1,
2585
- onChange: (e) => {
2586
- a.setValue("menuType", e.target.value), Ct();
2587
- }
2588
- }
2589
- ) })
2590
- ]
2591
- }
2592
- ) }),
2593
- /* @__PURE__ */ t(H, { children: (Y == null ? void 0 : Y.length) > 0 && /* @__PURE__ */ s(
2594
- te,
2595
- {
2596
- variant: "outlined",
2597
- className: " m-3 flex flex-row items-center w-[80%] justify-between",
2598
- children: [
2599
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2600
- m("Menu"),
2601
- " ",
2602
- m("SubGroup"),
2603
- " :"
2604
- ] }),
2605
- /* @__PURE__ */ t(c, { className: " w-[60%]", children: /* @__PURE__ */ t(
2606
- Ve,
2607
- {
2608
- control: a.control,
2609
- name: "menuGroup",
2610
- errors: a.formState.errors,
2611
- displayName: "name",
2612
- optionValue: "id",
2613
- options: Y,
2614
- disableClearable: !1,
2615
- onChange: xi
2616
- }
2617
- ) })
2618
- ]
2619
- }
2620
- ) }),
2621
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2622
- te,
2623
- {
2624
- variant: "outlined",
2625
- className: "m-3 flex flex-row items-center w-[80%] justify-between",
2626
- children: [
2627
- /* @__PURE__ */ s(
2628
- f,
2629
- {
2630
- variant: "subtitle1",
2631
- className: "whitespace-nowrap",
2632
- children: [
2633
- m("Enable"),
2634
- " ",
2635
- m("feature"),
2636
- " ",
2637
- m("for"),
2638
- ":"
2639
- ]
2640
- }
2641
- ),
2642
- /* @__PURE__ */ s(c, { className: "w-[60%] flex flex-row gap-6 items-center", children: [
2643
- /* @__PURE__ */ s(c, { className: "flex items-center gap-1", children: [
2644
- /* @__PURE__ */ t(f, { variant: "subtitle1", children: m("Web") }),
2645
- /* @__PURE__ */ t(
2646
- $,
2647
- {
2648
- name: "isWebFeature",
2649
- control: a.control,
2650
- render: ({ field: e }) => /* @__PURE__ */ t(
2651
- Ie,
2652
- {
2653
- ...e,
2654
- checked: e.value,
2655
- onChange: (n) => e.onChange(n.target.checked)
2656
- }
2657
- )
2658
- }
2659
- )
2660
- ] }),
2661
- /* @__PURE__ */ s(c, { className: "flex items-center gap-1", children: [
2662
- /* @__PURE__ */ t(f, { variant: "subtitle1", children: m("Mobile") }),
2663
- /* @__PURE__ */ t(
2664
- $,
2665
- {
2666
- name: "isMobileFeature",
2667
- control: a.control,
2668
- render: ({ field: e }) => /* @__PURE__ */ t(
2669
- Ie,
2670
- {
2671
- ...e,
2672
- checked: e.value,
2673
- onChange: (n) => {
2674
- e.onChange(n.target.checked), Si(n);
2675
- }
2676
- }
2677
- )
2678
- }
2679
- )
2680
- ] })
2681
- ] })
2682
- ]
2683
- }
2684
- ) })
2685
- ] }) }),
2686
- ((an = q[L]) == null ? void 0 : an.key) === "mobileConfig" && R && /* @__PURE__ */ t(c, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ s(c, { width: "95%", children: [
2687
- /* @__PURE__ */ t(
2688
- f,
2689
- {
2690
- variant: "h5",
2691
- sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
2692
- children: m("Mobile Setup")
2693
- }
2694
- ),
2695
- /* @__PURE__ */ t(
2696
- f,
2697
- {
2698
- sx: { textAlign: "center", mb: 3, color: "grey" },
2699
- children: "Set up how this feature should behave and appear in the mobile app, including its entity, icon and condition query."
2700
- }
2701
- ),
2702
- /* @__PURE__ */ s(
2703
- kt,
2704
- {
2705
- expanded: yt.basicConfig,
2706
- onChange: () => bt((e) => ({
2707
- ...e,
2708
- basicConfig: !e.basicConfig
2709
- })),
2710
- sx: {
2711
- mb: 1.5,
2712
- borderRadius: 2,
2713
- boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
2714
- border: "1px solid rgba(33, 150, 243, 0.2)",
2715
- borderLeft: "4px solid #2196f3",
2716
- "&:before": { display: "none" },
2717
- overflow: "hidden"
2718
- },
2719
- children: [
2720
- /* @__PURE__ */ t(
2721
- It,
2722
- {
2723
- expandIcon: /* @__PURE__ */ t(le, { iconName: "faChevronDown", size: "sm" }),
2724
- sx: {
2725
- backgroundColor: "rgba(33, 150, 243, 0.06)",
2726
- "&:hover": {
2727
- backgroundColor: "rgba(33, 150, 243, 0.12)"
2728
- },
2729
- minHeight: 52
2730
- },
2731
- children: /* @__PURE__ */ t(f, { fontWeight: 700, fontSize: 15, children: "Basic Config" })
2732
- }
2733
- ),
2734
- /* @__PURE__ */ s(
2735
- wt,
2736
- {
2737
- sx: { display: "flex", flexDirection: "column", gap: 2 },
2738
- children: [
2739
- /* @__PURE__ */ s(
2740
- c,
2741
- {
2742
- display: "flex",
2743
- flexDirection: "row",
2744
- alignItems: "center",
2745
- children: [
2746
- /* @__PURE__ */ s(
2747
- c,
2748
- {
2749
- display: "flex",
2750
- alignItems: "center",
2751
- gap: 2,
2752
- sx: { width: "50%" },
2753
- children: [
2754
- /* @__PURE__ */ s(
2755
- f,
2756
- {
2757
- variant: "subtitle1",
2758
- sx: { minWidth: "140px", flexShrink: 0 },
2759
- children: [
2760
- m("Feature Icon"),
2761
- " ",
2762
- /* @__PURE__ */ t("span", { style: { color: "#d32f2f" }, children: "* " }),
2763
- /* @__PURE__ */ t(
2764
- ge,
2765
- {
2766
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Upload Feature Icon" }),
2767
- size: "sm"
2768
- }
2769
- )
2770
- ]
2771
- }
2772
- ),
2773
- /* @__PURE__ */ t(Yi, { title: "Upload Icon", children: /* @__PURE__ */ t(
2774
- c,
2775
- {
2776
- sx: {
2777
- transform: "scale(0.55)",
2778
- transformOrigin: "left center",
2779
- "& svg": {
2780
- fontSize: "2.5rem"
2781
- }
2782
- },
2783
- children: /* @__PURE__ */ t(
2784
- zi,
2785
- {
2786
- onUpload: (e) => a.setValue("icon", e),
2787
- formControl: a,
2788
- name: "icon",
2789
- accept: "image/svg+xml, image/svg",
2790
- errors: R ? a.formState.errors : null,
2791
- triggerType: "icon"
2792
- }
2793
- )
2794
- }
2795
- ) })
2796
- ]
2797
- }
2798
- ),
2799
- /* @__PURE__ */ s(
2800
- c,
2801
- {
2802
- display: "flex",
2803
- alignItems: "center",
2804
- gap: 2,
2805
- my: 4,
2806
- sx: { width: "50%" },
2807
- children: [
2808
- /* @__PURE__ */ s(
2809
- f,
2810
- {
2811
- variant: "subtitle1",
2812
- sx: { minWidth: "140px", flexShrink: 0 },
2813
- children: [
2814
- m("Mode"),
2815
- " ",
2816
- /* @__PURE__ */ t("span", { style: { color: "#d32f2f" }, children: "* " }),
2817
- /* @__PURE__ */ t(
2818
- ge,
2819
- {
2820
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Choose whether this feature should work online or offline" }),
2821
- size: "sm"
2822
- }
2823
- )
2824
- ]
2825
- }
2826
- ),
2827
- /* @__PURE__ */ t(c, { sx: { display: "flex", flex: 1 }, children: /* @__PURE__ */ t(
2828
- $,
2829
- {
2830
- name: "mobileMode",
2831
- control: a.control,
2832
- render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ s(fe, { children: [
2833
- /* @__PURE__ */ s(
2834
- pn,
2835
- {
2836
- value: e.value ?? "",
2837
- row: !0,
2838
- ...e,
2839
- children: [
2840
- /* @__PURE__ */ t(
2841
- lt,
2842
- {
2843
- value: "ONLINE",
2844
- control: /* @__PURE__ */ t(
2845
- dt,
2846
- {
2847
- disabled: D && Pt !== null
2848
- }
2849
- ),
2850
- label: "Online"
2851
- }
2852
- ),
2853
- /* @__PURE__ */ t(
2854
- lt,
2855
- {
2856
- value: "OFFLINE",
2857
- control: /* @__PURE__ */ t(
2858
- dt,
2859
- {
2860
- disabled: D && Pt !== null
2861
- }
2862
- ),
2863
- label: "Offline"
2864
- }
2865
- )
2866
- ]
2867
- }
2868
- ),
2869
- (n == null ? void 0 : n.message) && /* @__PURE__ */ t(
2870
- f,
2871
- {
2872
- variant: "caption",
2873
- color: "error",
2874
- sx: { mt: 0.5 },
2875
- children: n.message
2876
- }
2877
- )
2878
- ] })
2879
- }
2880
- ) })
2881
- ]
2882
- }
2883
- )
2884
- ]
2885
- }
2886
- ),
2887
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
2888
- /* @__PURE__ */ s(
2889
- f,
2890
- {
2891
- variant: "subtitle1",
2892
- sx: { minWidth: "140px", flexShrink: 0 },
2893
- children: [
2894
- m("Entity Name"),
2895
- " ",
2896
- /* @__PURE__ */ t(
2897
- ge,
2898
- {
2899
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Select Entity Name" }),
2900
- size: "sm"
2901
- }
2902
- )
2903
- ]
2904
- }
2905
- ),
2906
- /* @__PURE__ */ t(
2907
- c,
2908
- {
2909
- sx: {
2910
- display: "flex",
2911
- alignItems: "center",
2912
- gap: 2,
2913
- flex: 1
2914
- },
2915
- children: /* @__PURE__ */ t(
2916
- Ve,
2917
- {
2918
- control: a.control,
2919
- name: "entityName",
2920
- options: v || [],
2921
- errors: R ? a.formState.errors : null,
2922
- size: "small",
2923
- disableClearable: !1,
2924
- sx: { flex: 1 }
2925
- }
2926
- )
2927
- }
2928
- )
2929
- ] }),
2930
- a.getValues("entityName") && ((sn = a.getValues("entityName")) == null ? void 0 : sn.trim().length) > 0 && /* @__PURE__ */ s(
2931
- c,
2932
- {
2933
- display: "flex",
2934
- alignItems: "flex-start",
2935
- gap: 2,
2936
- my: 2,
2937
- children: [
2938
- /* @__PURE__ */ s(
2939
- f,
2940
- {
2941
- variant: "subtitle1",
2942
- sx: {
2943
- minWidth: "140px",
2944
- flexShrink: 0,
2945
- pt: 0.5
2946
- },
2947
- children: [
2948
- m("Condition Query"),
2949
- " :",
2950
- " ",
2951
- /* @__PURE__ */ t(
2952
- ge,
2953
- {
2954
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Write Condition Query in the editor" }),
2955
- size: "sm"
2956
- }
2957
- )
2958
- ]
2959
- }
2960
- ),
2961
- /* @__PURE__ */ t(
2962
- c,
2963
- {
2964
- flex: 1,
2965
- sx: {
2966
- border: "1px solid #bdbdbd",
2967
- borderRadius: 2,
2968
- height: "20vh",
2969
- overflow: "hidden",
2970
- boxShadow: "0 1px 6px rgba(0, 0, 0, 0.08)"
2971
- },
2972
- children: /* @__PURE__ */ t(
2973
- $,
2974
- {
2975
- name: "conditions",
2976
- control: a.control,
2977
- render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ s(fe, { children: [
2978
- /* @__PURE__ */ t(
2979
- Li,
2980
- {
2981
- height: "100%",
2982
- defaultLanguage: "sql",
2983
- theme: ti == "light" ? "light" : "vs-dark",
2984
- options: {
2985
- fontSize: 13,
2986
- minimap: { enabled: !1 },
2987
- automaticLayout: !0,
2988
- scrollBeyondLastLine: !1,
2989
- wordWrap: "on",
2990
- occurrencesHighlight: !1,
2991
- selectionHighlight: !1
2992
- },
2993
- value: e.value || "",
2994
- onChange: e.onChange,
2995
- editorProps: { $blockScrolling: !0 }
2996
- }
2997
- ),
2998
- (n == null ? void 0 : n.message) && /* @__PURE__ */ t(
2999
- f,
3000
- {
3001
- variant: "caption",
3002
- color: "error",
3003
- sx: { mt: 0.75, ml: 1 },
3004
- children: n.message
3005
- }
3006
- )
3007
- ] })
3008
- }
3009
- )
3010
- }
3011
- )
3012
- ]
3013
- }
3014
- ),
3015
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
3016
- /* @__PURE__ */ s(
3017
- f,
3018
- {
3019
- variant: "subtitle1",
3020
- sx: { minWidth: "140px", flexShrink: 0 },
3021
- children: [
3022
- m("Tables to sync"),
3023
- " ",
3024
- /* @__PURE__ */ t(
3025
- ge,
3026
- {
3027
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Select at least one table to sync" }),
3028
- size: "sm"
3029
- }
3030
- )
3031
- ]
3032
- }
3033
- ),
3034
- /* @__PURE__ */ t(
3035
- c,
3036
- {
3037
- sx: {
3038
- display: "flex",
3039
- alignItems: "center",
3040
- gap: 2,
3041
- flex: 1
3042
- },
3043
- children: /* @__PURE__ */ t(
3044
- Ee,
3045
- {
3046
- id: "mobileEntitiesSync",
3047
- name: "mobileEntitiesSync",
3048
- control: a.control,
3049
- options: Z,
3050
- onChange: (e, n) => mi(n),
3051
- getOptionLabel: (e) => e == null ? void 0 : e.tableName,
3052
- checkEquality: "tableName",
3053
- errors: R ? a.formState.errors : null,
3054
- dataTestId: "syncentities-select-table",
3055
- value: T,
3056
- fullWidth: !0
3057
- }
3058
- )
3059
- }
3060
- )
3061
- ] })
3062
- ]
3063
- }
3064
- )
3065
- ]
3066
- }
3067
- ),
3068
- /* @__PURE__ */ s(
3069
- kt,
3070
- {
3071
- expanded: yt.trainingConfig,
3072
- onChange: () => bt((e) => ({
3073
- ...e,
3074
- trainingConfig: !e.trainingConfig
3075
- })),
3076
- sx: {
3077
- mb: 1.5,
3078
- borderRadius: 2,
3079
- boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
3080
- border: "1px solid rgba(76, 175, 80, 0.2)",
3081
- borderLeft: "4px solid #4caf50",
3082
- "&:before": { display: "none" },
3083
- overflow: "hidden"
3084
- },
3085
- children: [
3086
- /* @__PURE__ */ t(
3087
- It,
3088
- {
3089
- expandIcon: /* @__PURE__ */ t(le, { iconName: "faChevronDown", size: "sm" }),
3090
- sx: {
3091
- backgroundColor: "rgba(76, 175, 80, 0.06)",
3092
- "&:hover": {
3093
- backgroundColor: "rgba(76, 175, 80, 0.12)"
3094
- },
3095
- minHeight: 52
3096
- },
3097
- children: /* @__PURE__ */ t(f, { fontWeight: 700, fontSize: 15, children: "Training Config" })
3098
- }
3099
- ),
3100
- /* @__PURE__ */ s(
3101
- wt,
3102
- {
3103
- sx: { display: "flex", flexDirection: "column", gap: 2 },
3104
- children: [
3105
- /* @__PURE__ */ s(
3106
- c,
3107
- {
3108
- display: "flex",
3109
- alignItems: "center",
3110
- justifyContent: "space-between",
3111
- children: [
3112
- /* @__PURE__ */ s(
3113
- f,
3114
- {
3115
- variant: "subtitle1",
3116
- sx: { minWidth: "200px", flexShrink: 0 },
3117
- children: [
3118
- m("Training Required"),
3119
- " ",
3120
- /* @__PURE__ */ t(
3121
- ge,
3122
- {
3123
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: ut(
3124
- "Enable if the user must complete training before accessing this feature"
3125
- ) }),
3126
- size: "sm"
3127
- }
3128
- )
3129
- ]
3130
- }
3131
- ),
3132
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3133
- $,
3134
- {
3135
- name: "trainingRequired",
3136
- control: a.control,
3137
- render: ({ field: e }) => /* @__PURE__ */ t(
3138
- Ie,
3139
- {
3140
- ...e,
3141
- checked: !!e.value,
3142
- onChange: (n) => {
3143
- e.onChange(n.target.checked), n.target.checked || (a.setValue("trainingQuery", ""), je(""));
3144
- }
3145
- }
3146
- )
3147
- }
3148
- ) })
3149
- ]
3150
- }
3151
- ),
3152
- a.watch("trainingRequired") && /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
3153
- /* @__PURE__ */ s(
3154
- f,
3155
- {
3156
- variant: "subtitle1",
3157
- sx: { minWidth: "200px", flexShrink: 0 },
3158
- children: [
3159
- m("Training Query"),
3160
- " ",
3161
- /* @__PURE__ */ t(
3162
- ge,
3163
- {
3164
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: ut(
3165
- "Select a query that returns a boolean — true if training is completed, false otherwise"
3166
- ) }),
3167
- size: "sm"
3168
- }
3169
- )
3170
- ]
3171
- }
3172
- ),
3173
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3174
- $,
3175
- {
3176
- name: "trainingQuery",
3177
- control: a.control,
3178
- render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ t(
3179
- Ee,
3180
- {
3181
- id: "trainingQuery",
3182
- name: "trainingQuery",
3183
- control: a.control,
3184
- options: ke,
3185
- getOptionLabel: (i) => (i == null ? void 0 : i.code) || "",
3186
- checkEquality: "code",
3187
- inputValue: Yn,
3188
- disableClearable: !1,
3189
- singleSelect: !0,
3190
- value: (ke == null ? void 0 : ke.find(
3191
- (i) => i.code === e.value
3192
- )) || null,
3193
- onInputChange: (i, r, o) => {
3194
- o === "input" && (je(r), _e(r));
3195
- },
3196
- onChange: (i, r) => {
3197
- e.onChange((r == null ? void 0 : r.code) || ""), je((r == null ? void 0 : r.code) || "");
3198
- },
3199
- placeholder: "Search training query code...",
3200
- errors: n,
3201
- fullWidth: !0,
3202
- freeSolo: !1
3203
- }
3204
- )
3205
- }
3206
- ) })
3207
- ] })
3208
- ]
3209
- }
3210
- )
3211
- ]
3212
- }
3213
- ),
3214
- /* @__PURE__ */ s(
3215
- kt,
3216
- {
3217
- expanded: yt.notificationConfig,
3218
- onChange: () => bt((e) => ({
3219
- ...e,
3220
- notificationConfig: !e.notificationConfig
3221
- })),
3222
- sx: {
3223
- mb: 1.5,
3224
- borderRadius: 2,
3225
- boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
3226
- border: "1px solid rgba(255, 152, 0, 0.2)",
3227
- borderLeft: "4px solid #ff9800",
3228
- "&:before": { display: "none" },
3229
- overflow: "hidden"
3230
- },
3231
- children: [
3232
- /* @__PURE__ */ t(
3233
- It,
3234
- {
3235
- expandIcon: /* @__PURE__ */ t(le, { iconName: "faChevronDown", size: "sm" }),
3236
- sx: {
3237
- backgroundColor: "rgba(255, 152, 0, 0.06)",
3238
- "&:hover": {
3239
- backgroundColor: "rgba(255, 152, 0, 0.12)"
3240
- },
3241
- minHeight: 52
3242
- },
3243
- children: /* @__PURE__ */ s(f, { fontWeight: 700, fontSize: 15, children: [
3244
- m("Notification Config"),
3245
- " "
3246
- ] })
3247
- }
3248
- ),
3249
- /* @__PURE__ */ s(
3250
- wt,
3251
- {
3252
- sx: { display: "flex", flexDirection: "column", gap: 2 },
3253
- children: [
3254
- /* @__PURE__ */ s(
3255
- c,
3256
- {
3257
- display: "flex",
3258
- alignItems: "center",
3259
- justifyContent: "space-between",
3260
- children: [
3261
- /* @__PURE__ */ s(
3262
- f,
3263
- {
3264
- variant: "subtitle1",
3265
- sx: { minWidth: "200px", flexShrink: 0 },
3266
- children: [
3267
- m("Enable Notification Badge"),
3268
- " ",
3269
- /* @__PURE__ */ t(
3270
- ge,
3271
- {
3272
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: ut(
3273
- "Show a count or nudge badge on this feature's icon in the mobile app"
3274
- ) }),
3275
- size: "sm"
3276
- }
3277
- )
3278
- ]
3279
- }
3280
- ),
3281
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3282
- $,
3283
- {
3284
- name: "notificationBadgeEnabled",
3285
- control: a.control,
3286
- render: ({ field: e }) => /* @__PURE__ */ t(
3287
- Ie,
3288
- {
3289
- ...e,
3290
- checked: !!e.value,
3291
- onChange: (n) => {
3292
- e.onChange(n.target.checked), n.target.checked || (a.setValue(
3293
- "notificationBadgeType",
3294
- ""
3295
- ), a.setValue(
3296
- "notificationBadgeQuery",
3297
- ""
3298
- ), Ge(""));
3299
- }
3300
- }
3301
- )
3302
- }
3303
- ) })
3304
- ]
3305
- }
3306
- ),
3307
- a.watch("notificationBadgeEnabled") && /* @__PURE__ */ s(fe, { children: [
3308
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
3309
- /* @__PURE__ */ s(
3310
- f,
3311
- {
3312
- variant: "subtitle1",
3313
- sx: { minWidth: "200px", flexShrink: 0 },
3314
- children: [
3315
- m("Badge Type"),
3316
- " ",
3317
- /* @__PURE__ */ t(
3318
- ge,
3319
- {
3320
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: ut(
3321
- `Count Based: query returns a number.
3322
-
3323
- Nudge Based: query returns true/false.`
3324
- ) }),
3325
- size: "sm"
3326
- }
3327
- )
3328
- ]
3329
- }
3330
- ),
3331
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3332
- $,
3333
- {
3334
- name: "notificationBadgeType",
3335
- control: a.control,
3336
- render: ({ field: e }) => /* @__PURE__ */ s(pn, { row: !0, ...e, children: [
3337
- /* @__PURE__ */ t(
3338
- lt,
3339
- {
3340
- value: "COUNT",
3341
- control: /* @__PURE__ */ t(dt, {}),
3342
- label: "Count Based"
3343
- }
3344
- ),
3345
- /* @__PURE__ */ t(
3346
- lt,
3347
- {
3348
- value: "NUDGE",
3349
- control: /* @__PURE__ */ t(dt, {}),
3350
- label: "Nudge Based"
3351
- }
3352
- )
3353
- ] })
3354
- }
3355
- ) })
3356
- ] }),
3357
- a.watch("notificationBadgeType") && /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
3358
- /* @__PURE__ */ s(
3359
- f,
3360
- {
3361
- variant: "subtitle1",
3362
- sx: { minWidth: "200px", flexShrink: 0 },
3363
- children: [
3364
- a.watch("notificationBadgeType") === "COUNT" ? "Count Query" : "Nudge Query",
3365
- " ",
3366
- /* @__PURE__ */ t(
3367
- ge,
3368
- {
3369
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: a.watch(
3370
- "notificationBadgeType"
3371
- ) === "COUNT" ? "Select a query that returns a numeric count for the badge" : "Select a query that returns true/false to show or hide the badge" }),
3372
- size: "sm"
3373
- }
3374
- )
3375
- ]
3376
- }
3377
- ),
3378
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3379
- $,
3380
- {
3381
- name: "notificationBadgeQuery",
3382
- control: a.control,
3383
- render: ({
3384
- field: e,
3385
- fieldState: { error: n }
3386
- }) => /* @__PURE__ */ t(
3387
- Ee,
3388
- {
3389
- id: "notificationBadgeQuery",
3390
- name: "notificationBadgeQuery",
3391
- control: a.control,
3392
- options: ke,
3393
- getOptionLabel: (i) => (i == null ? void 0 : i.code) || "",
3394
- checkEquality: "code",
3395
- inputValue: Kn,
3396
- disableClearable: !1,
3397
- singleSelect: !0,
3398
- value: (ke == null ? void 0 : ke.find(
3399
- (i) => i.code === e.value
3400
- )) || null,
3401
- onInputChange: (i, r, o) => {
3402
- o === "input" && (Ge(r), _e(r));
3403
- },
3404
- onChange: (i, r) => {
3405
- e.onChange((r == null ? void 0 : r.code) || ""), Ge(
3406
- (r == null ? void 0 : r.code) || ""
3407
- );
3408
- },
3409
- placeholder: a.watch(
3410
- "notificationBadgeType"
3411
- ) === "COUNT" ? "Search count query code..." : "Search nudge query code...",
3412
- errors: n,
3413
- fullWidth: !0,
3414
- freeSolo: !1
3415
- }
3416
- )
3417
- }
3418
- ) })
3419
- ] })
3420
- ] })
3421
- ]
3422
- }
3423
- )
3424
- ]
3425
- }
3426
- )
3427
- ] }) }),
3428
- ((on = q[L]) == null ? void 0 : on.key) === "formLinking" && P && /* @__PURE__ */ t(c, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ s(c, { width: "80%", children: [
3429
- /* @__PURE__ */ t(
3430
- f,
3431
- {
3432
- variant: "h5",
3433
- sx: {
3434
- fontWeight: "bold",
3435
- textAlign: "center",
3436
- marginBottom: 1,
3437
- marginTop: 2
3438
- },
3439
- children: m("Form Linking")
3440
- }
3441
- ),
3442
- /* @__PURE__ */ t(
3443
- f,
3444
- {
3445
- sx: { textAlign: "center", mb: 4, color: "grey" },
3446
- children: "Link this feature to an existing form, or create a new form to be associated with it."
3447
- }
3448
- ),
3449
- /* @__PURE__ */ s(H, { container: !0, mt: 3, className: "flex flex-col w-[98%]", children: [
3450
- /* @__PURE__ */ t(
3451
- f,
3452
- {
3453
- variant: "subtitle1",
3454
- sx: {
3455
- marginLeft: 1,
3456
- marginBottom: "0.5rem",
3457
- fontWeight: 600
3458
- },
3459
- children: "Use Existing Form"
3460
- }
3461
- ),
3462
- /* @__PURE__ */ t(H, { container: !0, sx: { alignItems: "center" }, children: /* @__PURE__ */ s(
3463
- te,
3464
- {
3465
- variant: "outlined",
3466
- className: "m-3 flex flex-row items-center w-[80%] justify-between",
3467
- children: [
3468
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
3469
- m("Select"),
3470
- " ",
3471
- m("Form"),
3472
- ":"
3473
- ] }),
3474
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
3475
- Ve,
3476
- {
3477
- control: a.control,
3478
- name: "formCode",
3479
- options: he || [],
3480
- getOptionDisabled: (e) => e.menu_config_id && e.menu_config_id !== parseInt(b.get("featureId")),
3481
- displayName: "form_name",
3482
- optionValue: "form_code",
3483
- errors: a.formState.errors,
3484
- size: "small",
3485
- disableClearable: !1,
3486
- onChange: (e) => {
3487
- e.target.value ? (a.setValue(
3488
- "navigationState",
3489
- `medplat.form.${e.target.value}`
3490
- ), ye(e.target.value)) : (a.setValue("version", null), a.setValue(
3491
- "navigationState",
3492
- "medplat.form."
3493
- ));
3494
- }
3495
- }
3496
- ) })
3497
- ]
3498
- }
3499
- ) }),
3500
- /* @__PURE__ */ s(
3501
- te,
3502
- {
3503
- variant: "outlined",
3504
- className: "m-3 flex flex-row items-center w-[80%] justify-between",
3505
- children: [
3506
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
3507
- m("Select"),
3508
- " ",
3509
- m("Version"),
3510
- ":"
3511
- ] }),
3512
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
3513
- Ve,
3514
- {
3515
- control: a.control,
3516
- name: "version",
3517
- options: Array.isArray(J == null ? void 0 : J[De]) ? J[De].map(
3518
- (e) => e.version
3519
- ) : [],
3520
- errors: a.formState.errors,
3521
- disableClearable: !1,
3522
- size: "small"
3523
- }
3524
- ) })
3525
- ]
3526
- }
3527
- ),
3528
- /* @__PURE__ */ t(
3529
- Ye,
3530
- {
3531
- sx: {
3532
- width: "80%",
3533
- margin: "1rem auto",
3534
- position: "relative"
3535
- },
3536
- children: /* @__PURE__ */ t(
3537
- f,
3538
- {
3539
- variant: "caption",
3540
- sx: {
3541
- position: "absolute",
3542
- top: "-0.6rem",
3543
- left: "50%",
3544
- transform: "translateX(-50%)",
3545
- backgroundColor: "background.paper",
3546
- padding: "0 0.5rem"
3547
- },
3548
- children: "OR"
3549
- }
3550
- )
3551
- }
3552
- ),
3553
- /* @__PURE__ */ s(c, { className: "flex justify-center", children: [
3554
- /* @__PURE__ */ t(
3555
- U,
3556
- {
3557
- variant: "outlined",
3558
- size: "small",
3559
- onClick: () => {
3560
- a.setValue("formCode", null), S(!0);
3561
- },
3562
- children: "Add New Form"
3563
- }
3564
- ),
3565
- N && /* @__PURE__ */ t(
3566
- An,
3567
- {
3568
- mainFormCtrl: a,
3569
- openAddFormModal: N,
3570
- setModal: (e) => {
3571
- S(e);
3572
- },
3573
- reloadForms: Fi
3574
- }
3575
- )
3576
- ] })
3577
- ] })
3578
- ] }) }),
3579
- ((ln = q[L]) == null ? void 0 : ln.key) === "additionalPermissions" && /* @__PURE__ */ t(H, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(c, { mt: 3, className: "flex flex-col w-full", children: [
3580
- /* @__PURE__ */ t(
3581
- f,
3582
- {
3583
- variant: "h5",
3584
- sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
3585
- children: "Additional Permissions"
3586
- }
3587
- ),
3588
- /* @__PURE__ */ t(
3589
- f,
3590
- {
3591
- sx: { textAlign: "center", mb: 4, color: "grey" },
3592
- children: "Define custom permissions for this feature. These will be used to control fine-grained permissions beyond default roles."
3593
- }
3594
- ),
3595
- !P && (l == null ? void 0 : l.val) === !1 ? /* @__PURE__ */ s(fe, { children: [
3596
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
3597
- te,
3598
- {
3599
- variant: "outlined",
3600
- className: "flex flex-row items-center ml-3 ",
3601
- children: [
3602
- /* @__PURE__ */ t(f, { variant: "body2", children: m("Add feature JSON access rights") }),
3603
- /* @__PURE__ */ t(
3604
- gn,
3605
- {
3606
- disabled: Qn,
3607
- checked: Te,
3608
- onChange: Mi,
3609
- "data-testid": "managefeature-checkbox-access-rights"
3610
- }
3611
- )
3612
- ]
3613
- }
3614
- ) }),
3615
- /* @__PURE__ */ t(H, { children: K.value && Te && /* @__PURE__ */ t(H, { children: /* @__PURE__ */ t(Ki, { className: "ml-2", children: (dn = a.getValues("updatedFields")) == null ? void 0 : dn.map((e, n) => {
3616
- var i;
3617
- return /* @__PURE__ */ s(
3618
- H,
3619
- {
3620
- className: " mb-2.5 flex flex-row items-center ",
3621
- children: [
3622
- /* @__PURE__ */ t(te, { children: /* @__PURE__ */ t(
3623
- $,
3624
- {
3625
- name: `updatedFields[${n}].value`,
3626
- control: a.control,
3627
- render: ({ field: r }) => /* @__PURE__ */ t(
3628
- Vn,
3629
- {
3630
- ...r,
3631
- label: `${m("Right")} ${n + 1}`,
3632
- value: r.value || "",
3633
- sx: {
3634
- "& .MuiInputLabel-root": {
3635
- fontSize: "14px"
3636
- },
3637
- "& .MuiInputBase-input": {
3638
- fontSize: "14px"
3639
- }
3640
- }
3641
- }
3642
- )
3643
- }
3644
- ) }),
3645
- /* @__PURE__ */ t(
3646
- gn,
3647
- {
3648
- disabled: e.updated,
3649
- checked: e.checkbox,
3650
- onChange: () => Bi(e.id),
3651
- className: " mr-2.5",
3652
- "data-testid": `managefeature-checkbox-updated-right-${n + 1}`
3653
- }
3654
- ),
3655
- n + 1 === ((i = a.getValues("updatedFields")) == null ? void 0 : i.length) && /* @__PURE__ */ t(
3656
- U,
3657
- {
3658
- variant: "contained",
3659
- color: "primary",
3660
- onClick: Oi,
3661
- size: "small",
3662
- className: " mr-2.5",
3663
- disabled: !ri.updatedFields.some(
3664
- (r) => r.id === (e == null ? void 0 : e.id) && r.value
3665
- ),
3666
- "data-testid": "managefeature-button-add-updated",
3667
- children: m("Add")
3668
- }
3669
- ),
3670
- !e.updated && /* @__PURE__ */ t(
3671
- U,
3672
- {
3673
- variant: "contained",
3674
- size: "small",
3675
- color: "secondary",
3676
- onClick: () => Ui(e.id),
3677
- "data-testid": `managefeature-button-delete-updated-${n + 1}`,
3678
- children: m("Delete")
3679
- }
3680
- )
3681
- ]
3682
- },
3683
- e.id
3684
- );
3685
- }) }) }) })
3686
- ] }) : /* @__PURE__ */ s(fe, { children: [
3687
- (ce == null ? void 0 : ce.length) === 0 ? /* @__PURE__ */ t(
3688
- f,
3689
- {
3690
- variant: "subtitle1",
3691
- color: "text.secondary",
3692
- align: "center",
3693
- sx: { py: 2 },
3694
- children: "No permissions added yet."
3695
- }
3696
- ) : /* @__PURE__ */ t(
3697
- Wn,
3698
- {
3699
- permissions: ce,
3700
- onEdit: (e) => Ii(e),
3701
- onRemove: (e) => vi(e),
3702
- handleAddChildClick: (e) => ki(e),
3703
- isDynamicFeature: P
3704
- }
3705
- ),
3706
- /* @__PURE__ */ t(
3707
- c,
3708
- {
3709
- sx: {
3710
- display: "flex",
3711
- justifyContent: "flex-end",
3712
- mt: 2
3713
- },
3714
- children: /* @__PURE__ */ t(
3715
- U,
3716
- {
3717
- variant: "outlined",
3718
- size: "small",
3719
- startIcon: /* @__PURE__ */ t(le, { iconName: "faPlus" }),
3720
- onClick: Ni,
3721
- sx: {
3722
- textTransform: "none",
3723
- fontWeight: 500,
3724
- borderRadius: 2,
3725
- px: 2,
3726
- py: 0.75,
3727
- minWidth: 120
3728
- },
3729
- children: "Add Parent Permission"
3730
- }
3731
- )
3732
- }
3733
- ),
3734
- /* @__PURE__ */ t(
3735
- qn,
3736
- {
3737
- open: Bn,
3738
- onClose: () => Qe(!1),
3739
- onSave: wi,
3740
- formCtrl: a,
3741
- editData: On,
3742
- parentPermissionId: Je === "add-child" ? pt : null,
3743
- mode: Je,
3744
- permissionTypes: jn,
3745
- setPermissionTypes: Gn,
3746
- existingPermissionIds: new Set(
3747
- st(ce).map(
3748
- (e) => e.permissionId
3749
- )
3750
- ),
3751
- isDynamicFeature: P
3752
- }
3753
- )
3754
- ] })
3755
- ] }) }),
3756
- ((cn = q[L]) == null ? void 0 : cn.key) === "assignFeatures" && /* @__PURE__ */ s(c, { mt: 3, className: "flex flex-col w-full", children: [
3757
- /* @__PURE__ */ t(
3758
- f,
3759
- {
3760
- variant: "h5",
3761
- sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
3762
- children: m("Assign Features")
3763
- }
3764
- ),
3765
- /* @__PURE__ */ t(f, { sx: { textAlign: "center", mb: 4, color: "grey" }, children: "Assign this feature to specific users or roles. You can toggle individual permissions below after assigning." }),
3766
- /* @__PURE__ */ s(c, { display: "flex", gap: 2, flexWrap: "wrap", mb: 3, children: [
3767
- /* @__PURE__ */ s(c, { flex: "1 1 300px", minWidth: 300, children: [
3768
- /* @__PURE__ */ t(f, { variant: "subtitle1", sx: { mb: 1 }, children: m("User") }),
3769
- /* @__PURE__ */ t(
3770
- Ee,
3771
- {
3772
- id: "roles",
3773
- name: "roles",
3774
- control: a.control,
3775
- options: !P && (l == null ? void 0 : l.val) === !1 ? Be.filter(
3776
- (e) => !Ne.some(
3777
- (n) => n.entityType === "user" && n.user_id === e.id
3778
- )
3779
- ) : Be,
3780
- value: _,
3781
- singleSelect: !0,
3782
- onChange: fi,
3783
- onInputChange: qi,
3784
- getOptionLabel: bi,
3785
- "data-testid": "accessrights-autocomplete-user",
3786
- fullWidth: !0
3787
- }
3788
- )
3789
- ] }),
3790
- /* @__PURE__ */ s(c, { flex: "1 1 300px", minWidth: 300, children: [
3791
- /* @__PURE__ */ t(f, { variant: "subtitle1", sx: { mb: 1 }, children: m("Role") }),
3792
- /* @__PURE__ */ t(
3793
- Ee,
3794
- {
3795
- id: "selectedRoles",
3796
- name: "selectedRoles",
3797
- control: a.control,
3798
- options: !P && (l == null ? void 0 : l.val) === !1 ? $t().filter(
3799
- (e) => !Ne.some(
3800
- (n) => n.entityType === "role" && n.role_id === e.id
3801
- )
3802
- ) : $t(),
3803
- onChange: (e, n) => ui(n),
3804
- getOptionLabel: (e) => e == null ? void 0 : e.name,
3805
- dataTestId: "accessrights-select-role",
3806
- value: g,
3807
- fullWidth: !0
3808
- }
3809
- )
3810
- ] }),
3811
- /* @__PURE__ */ t(
3812
- c,
3813
- {
3814
- display: "flex",
3815
- alignItems: "flex-end",
3816
- flexShrink: 0,
3817
- sx: { minWidth: 120 },
3818
- children: /* @__PURE__ */ t(
3819
- U,
3820
- {
3821
- variant: "contained",
3822
- size: "medium",
3823
- fullWidth: !0,
3824
- disabled: !(g.length > 0 || _ != null && _.id),
3825
- "data-testid": "accessrights-add-button",
3826
- onClick: Ti,
3827
- sx: { minWidth: 120, marginBottom: "10px" },
3828
- children: m("Add")
3829
- }
3830
- )
3831
- }
3832
- )
3833
- ] }),
3834
- !P && (l == null ? void 0 : l.val) === !1 ? /* @__PURE__ */ t(yn, { sx: { maxHeight: 360, overflowY: "auto" }, children: /* @__PURE__ */ s(bn, { size: "small", children: [
3835
- /* @__PURE__ */ t(xn, { children: /* @__PURE__ */ s(ct, { children: [
3836
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Type") }),
3837
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Name") }),
3838
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Access Right") }),
3839
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Actions") })
3840
- ] }) }),
3841
- /* @__PURE__ */ t(Sn, { children: Ue.map((e, n) => /* @__PURE__ */ s(ct, { children: [
3842
- /* @__PURE__ */ t(ee, { children: e.designationId ? "Role" : "User" }),
3843
- /* @__PURE__ */ t(ee, { children: e.roleName || e.fullName }),
3844
- /* @__PURE__ */ t(ee, { children: /* @__PURE__ */ t(
3845
- c,
3846
- {
3847
- display: "flex",
3848
- flexDirection: "column",
3849
- gap: 1,
3850
- children: (() => {
3851
- const i = K.value ? a.getValues("updatedFields") : a.getValues("fields"), r = i == null ? void 0 : i.reduce((h, y) => (h[y.value] = y.checkbox, h), {}), o = e.featureJson ? JSON.parse(e.featureJson) : {}, u = Object.fromEntries(
3852
- Object.entries(o).map(
3853
- ([h, y]) => [
3854
- h,
3855
- y === !0 || y === "true"
3856
- ]
3857
- )
3858
- ), d = {
3859
- ...u,
3860
- ...Object.fromEntries(
3861
- Object.entries(
3862
- r || {}
3863
- ).filter(
3864
- ([h]) => !(h in u)
3865
- )
3866
- )
3867
- };
3868
- return Object.entries(d).map(
3869
- ([h, y]) => /* @__PURE__ */ s(
3870
- c,
3871
- {
3872
- display: "flex",
3873
- alignItems: "center",
3874
- gap: 1,
3875
- children: [
3876
- /* @__PURE__ */ t(
3877
- Ie,
3878
- {
3879
- sx: {
3880
- transform: "scale(0.75)",
3881
- transformOrigin: "left center"
3882
- },
3883
- checked: !!y,
3884
- onChange: () => {
3885
- const F = [
3886
- ...Ue
3887
- ];
3888
- let k = {};
3889
- try {
3890
- k = e.featureJson ? JSON.parse(
3891
- e.featureJson
3892
- ) : {};
3893
- } catch (se) {
3894
- console.warn(
3895
- "Invalid JSON in featureJson:",
3896
- se
3897
- );
3898
- }
3899
- const X = (K.value ? a.getValues(
3900
- "updatedFields"
3901
- ) : a.getValues(
3902
- "fields"
3903
- ) || []).reduce(
3904
- (se, oe) => (se[oe.value] = oe.value in k ? k[oe.value] : oe.checkbox, se),
3905
- {}
3906
- );
3907
- X[h] = !y, F[n] = {
3908
- ...e,
3909
- featureJson: JSON.stringify(
3910
- X
3911
- )
3912
- }, ze(F);
3913
- }
3914
- }
3915
- ),
3916
- /* @__PURE__ */ t(f, { variant: "subtitle1", children: h })
3917
- ]
3918
- },
3919
- h
3920
- )
3921
- );
3922
- })()
3923
- }
3924
- ) }),
3925
- /* @__PURE__ */ t(ee, { children: /* @__PURE__ */ t(
3926
- qe,
3927
- {
3928
- size: "small",
3929
- color: "error",
3930
- onClick: () => {
3931
- const i = Ue.filter(
3932
- (r, o) => o !== n
3933
- );
3934
- ze(i);
3935
- },
3936
- children: /* @__PURE__ */ t(
3937
- le,
3938
- {
3939
- iconName: "faTrashAlt",
3940
- size: "sm"
3941
- }
3942
- )
3943
- }
3944
- ) })
3945
- ] }, n)) })
3946
- ] }) }) : /* @__PURE__ */ t(fe, { children: Ne.length > 0 && /* @__PURE__ */ t(
3947
- yn,
3948
- {
3949
- sx: { maxHeight: 360, overflowY: "auto" },
3950
- children: /* @__PURE__ */ s(bn, { size: "small", children: [
3951
- /* @__PURE__ */ t(xn, { children: /* @__PURE__ */ s(ct, { children: [
3952
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Type") }),
3953
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Name") }),
3954
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Permissions") }),
3955
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Actions") })
3956
- ] }) }),
3957
- /* @__PURE__ */ t(Sn, { children: Ne.map((e, n) => /* @__PURE__ */ s(ct, { children: [
3958
- /* @__PURE__ */ t(ee, { children: e.entityType === "role" ? "Role" : "User" }),
3959
- /* @__PURE__ */ t(ee, { children: e.name }),
3960
- /* @__PURE__ */ t(ee, { children: /* @__PURE__ */ t(
3961
- _t,
3962
- {
3963
- permissions: e.permissions,
3964
- onToggle: (i) => _i(n, i)
3965
- }
3966
- ) }),
3967
- /* @__PURE__ */ t(ee, { children: /* @__PURE__ */ t(
3968
- qe,
3969
- {
3970
- size: "small",
3971
- color: "error",
3972
- onClick: () => {
3973
- const i = Ne.filter(
3974
- (r, o) => o !== n
3975
- );
3976
- We(i);
3977
- },
3978
- children: /* @__PURE__ */ t(
3979
- le,
3980
- {
3981
- iconName: "faTrashAlt",
3982
- size: "sm"
3983
- }
3984
- )
3985
- }
3986
- ) })
3987
- ] }, n)) })
3988
- ] })
3989
- }
3990
- ) }),
3991
- /* @__PURE__ */ t(
3992
- Rn,
3993
- {
3994
- open: zn,
3995
- onClose: () => gt(!1),
3996
- permissions: ce,
3997
- entityData: Ln,
3998
- onSave: (e) => {
3999
- We((n) => [...n, e]), gt(!1);
4000
- }
4001
- }
4002
- )
4003
- ] }),
4004
- ((un = q[L]) == null ? void 0 : un.key) === "submit" && Ae && /* @__PURE__ */ s(
4005
- c,
4006
- {
4007
- sx: {
4008
- mt: 4,
4009
- display: "flex",
4010
- flexDirection: "column",
4011
- alignItems: "center",
4012
- justifyContent: "center",
4013
- textAlign: "center",
4014
- minHeight: "300px",
4015
- px: 3,
4016
- mx: "auto",
4017
- maxWidth: 500,
4018
- backgroundColor: "background.default",
4019
- borderRadius: 1.5,
4020
- boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
4021
- border: `1px solid ${C.palette.divider}`,
4022
- p: 6
4023
- },
4024
- children: [
4025
- /* @__PURE__ */ t(c, { sx: { color: "success.main", fontSize: 40, mb: 2 }, children: /* @__PURE__ */ t(le, { iconName: "faCheckCircle" }) }),
4026
- /* @__PURE__ */ s(
4027
- f,
4028
- {
4029
- variant: "h6",
4030
- gutterBottom: !0,
4031
- sx: { fontWeight: "bold" },
4032
- children: [
4033
- "Feature was successfully",
4034
- b.get("featureId") ? "updated" : "created",
4035
- "!"
4036
- ]
4037
- }
4038
- ),
4039
- /* @__PURE__ */ t(Ye, { sx: { my: 2, width: "100%" } }),
4040
- /* @__PURE__ */ s(f, { variant: "subtitle1", gutterBottom: !0, children: [
4041
- /* @__PURE__ */ t("strong", { children: "Feature Name:" }),
4042
- " ",
4043
- a.getValues("menuName")
4044
- ] }),
4045
- P && /* @__PURE__ */ s(f, { variant: "subtitle1", gutterBottom: !0, children: [
4046
- /* @__PURE__ */ t("strong", { children: "Feature Constant:" }),
4047
- " ",
4048
- a.getValues("featureConstant")
4049
- ] }),
4050
- /* @__PURE__ */ t(c, { mt: 5, width: "100%", display: "flex", justifyContent: "center", children: a.getValues("formCode") && a.getValues("version") ? /* @__PURE__ */ t(
4051
- U,
4052
- {
4053
- variant: "contained",
4054
- color: "primary",
4055
- onClick: () => {
4056
- var r;
4057
- const e = a.getValues("formCode"), n = a.getValues("version"), i = (r = J == null ? void 0 : J[e]) == null ? void 0 : r.find(
4058
- (o) => o.version === n
4059
- );
4060
- i != null && i.uuid ? E(
4061
- `/ui/medplat/admin/medplatForms/form/${i.uuid}`
4062
- ) : console.warn("Could not find matching version UUID");
4063
- },
4064
- children: "Configure Form"
4065
- }
4066
- ) : /* @__PURE__ */ t(
4067
- U,
4068
- {
4069
- variant: "outlined",
4070
- color: "primary",
4071
- onClick: () => E("/ui/medplat/manage/menu"),
4072
- children: "Go Back to Menu"
4073
- }
4074
- ) })
4075
- ]
4076
- }
4077
- ),
4078
- !Ae && /* @__PURE__ */ s(
4079
- c,
4080
- {
4081
- mt: "auto",
4082
- display: "flex",
4083
- justifyContent: "flex-end",
4084
- gap: 2,
4085
- sx: { paddingTop: 4 },
4086
- children: [
4087
- /* @__PURE__ */ t(
4088
- U,
4089
- {
4090
- variant: "outlined",
4091
- sx: { color: "text.secondary" },
4092
- onClick: si,
4093
- children: "Back"
4094
- }
4095
- ),
4096
- ((mn = q[L]) == null ? void 0 : mn.key) !== "submit" && (() => {
4097
- var h;
4098
- const e = (h = q[L]) == null ? void 0 : h.key, n = ["formLinking"].includes(e), i = et.includes(e), [r, o] = a.getValues(Bt(e)), u = e === "formLinking" ? !!(r != null && r.trim()) || !!(o != null && o.trim()) : e === "additionalPermissions" ? Array.isArray(r) && r.length > 0 : !1, d = a.handleSubmit(
4099
- (y) => {
4100
- Xt(y);
4101
- const F = q.findIndex(
4102
- (k) => k.key === "submit"
4103
- );
4104
- At((k) => new Set(k).add(e)), Ce(F);
4105
- }
4106
- );
4107
- return e === "assignFeatures" || e === "accessRights" ? /* @__PURE__ */ t(
4108
- U,
4109
- {
4110
- variant: "contained",
4111
- onClick: d,
4112
- children: "Save"
4113
- }
4114
- ) : n ? Rt ? /* @__PURE__ */ t(U, { variant: "contained", onClick: xt, children: "Next" }) : u ? /* @__PURE__ */ t(U, { variant: "contained", disabled: !0, children: "Next" }) : /* @__PURE__ */ t(
4115
- U,
4116
- {
4117
- variant: "outlined",
4118
- color: "secondary",
4119
- onClick: () => {
4120
- i || Me((y) => [...y, e]), xt();
4121
- },
4122
- children: "Skip for now"
4123
- }
4124
- ) : /* @__PURE__ */ t(
4125
- U,
4126
- {
4127
- variant: "contained",
4128
- onClick: xt,
4129
- disabled: !Rt,
4130
- children: "Next"
4131
- }
4132
- );
4133
- })()
4134
- ]
4135
- }
4136
- )
4137
- ]
4138
- }
4139
- )
4140
- ] }) })
4141
- }
4142
- );
4143
- }
4144
- Wn.propTypes = {
4145
- permissions: I.any,
4146
- onEdit: I.any,
4147
- onRemove: I.any,
4148
- handleAddChildClick: I.any,
4149
- isDynamicFeature: I.any
4150
- };
4151
- qn.propTypes = {
4152
- open: I.any,
4153
- onClose: I.any,
4154
- onSave: I.any,
4155
- formCtrl: I.any,
4156
- editData: I.any,
4157
- parentPermissionId: I.any,
4158
- mode: I.any,
4159
- permissionTypes: I.any,
4160
- setPermissionTypes: I.any,
4161
- isDynamicFeature: I.any,
4162
- existingPermissionIds: I.any
4163
- };
4164
- Tt.propTypes = {
4165
- permission: I.any,
4166
- index: I.any,
4167
- depth: I.any,
4168
- onEdit: I.any,
4169
- onRemove: I.any,
4170
- handleAddChildClick: I.any,
4171
- isLastChild: I.any,
4172
- isDynamicFeature: I.any
4173
- };
4174
- _t.propTypes = {
4175
- permissions: I.any,
4176
- onToggle: I.any,
4177
- isChild: I.any
4178
- };
4179
- Rn.propTypes = {
4180
- open: I.any,
4181
- onClose: I.any,
4182
- onSave: I.any,
4183
- entityData: I.any,
4184
- permissions: I.any
4185
- };
4186
- export {
4187
- Qr as default
4188
- };
4189
- //# sourceMappingURL=ManageDynamicFeature-dt096fyj.js.map