@erpsquad/common 1.10.17 → 1.10.19

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 (59) hide show
  1. package/dist/chunks/{android-12-switch-Nw977vtV.esm.js → android-12-switch-BJGIDwYR.esm.js} +131 -80
  2. package/dist/chunks/android-12-switch-BJGIDwYR.esm.js.map +1 -0
  3. package/dist/chunks/{android-12-switch-DQG8As1Y.js → android-12-switch-PEYCUiaq.js} +131 -80
  4. package/dist/chunks/android-12-switch-PEYCUiaq.js.map +1 -0
  5. package/dist/chunks/{appbar-CGe_OPDv.js → appbar-rUKxg-G7.js} +3 -2
  6. package/dist/chunks/{appbar-CGe_OPDv.js.map → appbar-rUKxg-G7.js.map} +1 -1
  7. package/dist/chunks/{appbar-KrkQiVAV.esm.js → appbar-zELMJiqH.esm.js} +3 -2
  8. package/dist/chunks/{appbar-KrkQiVAV.esm.js.map → appbar-zELMJiqH.esm.js.map} +1 -1
  9. package/dist/chunks/{default-data-pmy2guR7.js → default-data-COIp_txP.js} +4 -4
  10. package/dist/chunks/{default-data-pmy2guR7.js.map → default-data-COIp_txP.js.map} +1 -1
  11. package/dist/chunks/{default-data-Dt8HLhhG.esm.js → default-data-Ceg98EuN.esm.js} +4 -4
  12. package/dist/chunks/{default-data-Dt8HLhhG.esm.js.map → default-data-Ceg98EuN.esm.js.map} +1 -1
  13. package/dist/chunks/{form-builder-deconversion-DLGJdpXM.esm.js → form-builder-deconversion-B4OuGvBB.esm.js} +6 -2
  14. package/dist/chunks/form-builder-deconversion-B4OuGvBB.esm.js.map +1 -0
  15. package/dist/chunks/{form-builder-deconversion-D5-FPTEJ.js → form-builder-deconversion-BcmOEnG9.js} +6 -2
  16. package/dist/chunks/form-builder-deconversion-BcmOEnG9.js.map +1 -0
  17. package/dist/chunks/{fullScreen-8kPj1_fu.esm.js → fullScreen-BZgvFEKI.esm.js} +2 -2
  18. package/dist/chunks/{fullScreen-8kPj1_fu.esm.js.map → fullScreen-BZgvFEKI.esm.js.map} +1 -1
  19. package/dist/chunks/{fullScreen-DZWgEHUi.js → fullScreen-CSJaBvxv.js} +2 -2
  20. package/dist/chunks/{fullScreen-DZWgEHUi.js.map → fullScreen-CSJaBvxv.js.map} +1 -1
  21. package/dist/chunks/{sidebar-BeSjxulx.esm.js → sidebar-BXrUlb1O.esm.js} +2 -2
  22. package/dist/chunks/{sidebar-BeSjxulx.esm.js.map → sidebar-BXrUlb1O.esm.js.map} +1 -1
  23. package/dist/chunks/{sidebar-DKHIqaS0.js → sidebar-BbJUAEIV.js} +2 -2
  24. package/dist/chunks/{sidebar-DKHIqaS0.js.map → sidebar-BbJUAEIV.js.map} +1 -1
  25. package/dist/chunks/{sidebarScreen-Ca2YjEI4.js → sidebarScreen-DnI42_mr.js} +3 -3
  26. package/dist/chunks/{sidebarScreen-Ca2YjEI4.js.map → sidebarScreen-DnI42_mr.js.map} +1 -1
  27. package/dist/chunks/{sidebarScreen-DQWQqmvK.esm.js → sidebarScreen-NlMW1w_l.esm.js} +3 -3
  28. package/dist/chunks/{sidebarScreen-DQWQqmvK.esm.js.map → sidebarScreen-NlMW1w_l.esm.js.map} +1 -1
  29. package/dist/chunks/{uom-field-wrapper-DjrmGUaV.js → uom-field-wrapper-BsTblyVT.js} +91 -15
  30. package/dist/chunks/uom-field-wrapper-BsTblyVT.js.map +1 -0
  31. package/dist/chunks/{uom-field-wrapper-Db0m4mhG.esm.js → uom-field-wrapper-D0YgJsP5.esm.js} +91 -15
  32. package/dist/chunks/uom-field-wrapper-D0YgJsP5.esm.js.map +1 -0
  33. package/dist/components/department-add-modal.d.ts +8 -1
  34. package/dist/components/designation-add-modal.d.ts +9 -1
  35. package/dist/components/form-control/form-builder/form-builder-element/dynamic-select.d.ts +1 -0
  36. package/dist/components/index.esm.js +5 -5
  37. package/dist/components/index.js +5 -5
  38. package/dist/components/team-add-modal.d.ts +7 -1
  39. package/dist/hooks/useSetDefaultConfig.d.ts +2 -1
  40. package/dist/index.esm.js +8 -8
  41. package/dist/index.js +8 -8
  42. package/dist/layout/index.esm.js +2 -2
  43. package/dist/layout/index.js +2 -2
  44. package/dist/src/components/department-add-modal.d.ts +8 -1
  45. package/dist/src/components/designation-add-modal.d.ts +9 -1
  46. package/dist/src/components/form-control/form-builder/form-builder-element/dynamic-select.d.ts +1 -0
  47. package/dist/src/components/team-add-modal.d.ts +7 -1
  48. package/dist/src/hooks/useSetDefaultConfig.d.ts +2 -1
  49. package/dist/utils/index.esm.js +1 -1
  50. package/dist/utils/index.js +1 -1
  51. package/dist/views/index.esm.js +5 -5
  52. package/dist/views/index.js +4 -4
  53. package/package.json +1 -1
  54. package/dist/chunks/android-12-switch-DQG8As1Y.js.map +0 -1
  55. package/dist/chunks/android-12-switch-Nw977vtV.esm.js.map +0 -1
  56. package/dist/chunks/form-builder-deconversion-D5-FPTEJ.js.map +0 -1
  57. package/dist/chunks/form-builder-deconversion-DLGJdpXM.esm.js.map +0 -1
  58. package/dist/chunks/uom-field-wrapper-Db0m4mhG.esm.js.map +0 -1
  59. package/dist/chunks/uom-field-wrapper-DjrmGUaV.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { j as jsxRuntimeExports } from "./jsx-runtime-ClFauRgV.esm.js";
2
2
  import { y as internal_processStyles, e as _objectWithoutPropertiesLoose, v as styled$1, _ as _extends, j as capitalize, b as createTheme, m as isPlainObject, i as internal_serializeStyles, q as styleFunctionSx, z as resolveProps, A as formatMuiErrorMessage, B as clamp, P as PropTypes, D as handleBreakpoints, E as resolveBreakpointValues, F as createUnarySpacing, l as deepmerge, H as mergeBreakpointsInOrder, g as generateUtilityClass, I as getValue, d as defaultTheme$1, T as THEME_ID, k as interopRequireDefaultExports, u as useDefaultProps, f as alpha_1, w as lighten_1, x as darken_1 } from "./identifier-u4E_J1of.esm.js";
3
- import { z as default_1$9, B as Button$1, M as Modal, d as Select$1, S as SearchBar, F as Typography$1, _ as _inheritsLoose, X as forceReflow, j as Transition, Y as classNamesShape, u as useTheme$4, Z as useSlotProps, U as IconButton$1, P as Paper, $ as Fade, t as Modal$1, a0 as Backdrop, a1 as Portal, W as refType, q as HTMLElementType, p as chainPropTypes, a2 as Grow, a3 as FocusTrap, i as ButtonBase, E as List, w as ListItem, a4 as TransitionGroup, a5 as isHostComponent, m as elementTypeAcceptingRef, O as Menu$1, n as getReactElementRef, J as resolveComponentProps, I as o, s as useRtl, Q as MenuItem$1, a6 as MenuList, a7 as Divider$1, T as TextField$1, f as Tooltip$1, G as default_1$b, y as default_1$c, c as ConfirmPopUp, D as DynamicInput, e as Toast, o as elementAcceptingRef, a8 as exactProp, g as Box$1, b as Avatar } from "./appbar-KrkQiVAV.esm.js";
3
+ import { z as default_1$9, B as Button$1, M as Modal, d as Select$1, S as SearchBar, F as Typography$1, _ as _inheritsLoose, X as forceReflow, j as Transition, Y as classNamesShape, u as useTheme$4, Z as useSlotProps, U as IconButton$1, P as Paper, $ as Fade, t as Modal$1, a0 as Backdrop, a1 as Portal, W as refType, q as HTMLElementType, p as chainPropTypes, a2 as Grow, a3 as FocusTrap, i as ButtonBase, E as List, w as ListItem, a4 as TransitionGroup, a5 as isHostComponent, m as elementTypeAcceptingRef, O as Menu$1, n as getReactElementRef, J as resolveComponentProps, I as o, s as useRtl, Q as MenuItem$1, a6 as MenuList, a7 as Divider$1, T as TextField$1, f as Tooltip$1, G as default_1$b, y as default_1$c, c as ConfirmPopUp, D as DynamicInput, e as Toast, o as elementAcceptingRef, a8 as exactProp, g as Box$1, b as Avatar } from "./appbar-zELMJiqH.esm.js";
4
4
  import { d as useEnhancedEffect, r as requireCreateSvgIcon, T as Typography, i as default_1$a, t as useId, l as ownerDocument, e as useForkRef, k as useEventCallback, q as useControlled, v as unsupportedProp, o as ownerWindow, h as debounce$1, p as isMuiElement, u as useAuth } from "./useAuth-Dp6w9OBc.esm.js";
5
5
  import { AccordionSummary, AccordionDetails, styled as styled$2, Accordion as Accordion$1, useTheme as useTheme$3, useMediaQuery as useMediaQuery$1, DialogTitle, IconButton, Tabs as Tabs$1, Tab as Tab$1, MenuItem, DialogActions as DialogActions$1, Box, Checkbox as Checkbox$1, Radio as Radio$1, RadioGroup, FormControlLabel, Tooltip, Divider, CircularProgress, OutlinedInput as OutlinedInput$1, InputAdornment as InputAdornment$1, ListItemIcon, ListItemText, Grid, DialogContent as DialogContent$1, Stack as Stack$1, Select as Select$2, Autocomplete, Menu as Menu$3, Alert as Alert$1, FormControl as FormControl$1, FormHelperText as FormHelperText$1, Chip as Chip$2, Dialog as Dialog$1, Grow as Grow$1, Breadcrumbs, TextField as TextField$2, List as List$1, ListItem as ListItem$1, ListItemAvatar, Switch as Switch$1 } from "@mui/material";
6
6
  import { useDrag, useDrop } from "react-dnd";
@@ -12,7 +12,7 @@ import { Controller, useWatch, useFormContext, useForm, FormProvider } from "rea
12
12
  /* empty css */
13
13
  import { useTranslation } from "react-i18next";
14
14
  import { h as getDisplayName, e as extendSxProp, a as clsx, b as composeClasses, s as styled$3, g as generateUtilityClasses, c as createSvgIcon, i as require$$1, r as rootShouldForwardProp, f as reactIsExports, j as slotShouldForwardProp } from "./notification-Dr_nE2Dc.esm.js";
15
- import { C as Chip$1, M as Menu$2, t as transformTableColumns, f as formBuilderDeConversion } from "./form-builder-deconversion-DLGJdpXM.esm.js";
15
+ import { C as Chip$1, M as Menu$2, t as transformTableColumns, f as formBuilderDeConversion } from "./form-builder-deconversion-B4OuGvBB.esm.js";
16
16
  import * as Yup from "yup";
17
17
  import dayjs from "dayjs";
18
18
  import { aU as formatText, A as fetchApi, a8 as getErrorMessage, aO as toFixedWithNumbers, ac as getFileName, M as formatAmount, Q as formatDate, W as formatLabel, S as SECTION_TYPES, aL as skuGenerator, aT as fetchOptions, ar as getToken, aZ as postV1Designation, a_ as postV1DepartmentsTeams, a$ as postV1Departments, a1 as generateFields, a2 as generateQueryString, aE as postImportSheet, ai as getOperatorLabel, a9 as getExcelExportTemplate, am as getPdfExportTemplate, aa as getExcelTemplateGenerateTemplate, a3 as generateRandomId } from "./common-Cv12BqWf.esm.js";
@@ -19245,14 +19245,7 @@ const addressColumns = [
19245
19245
  editProperties: {
19246
19246
  placeholder: "Enter City",
19247
19247
  field_name: "city",
19248
- validations: [
19249
- {
19250
- type: "required",
19251
- value: true,
19252
- msg_en: "City is required",
19253
- msg_ar: "City is required"
19254
- }
19255
- ]
19248
+ validations: []
19256
19249
  }
19257
19250
  },
19258
19251
  {
@@ -19371,8 +19364,8 @@ const generateValidationSchema1 = () => {
19371
19364
  then: () => Yup.string().required("Company is required"),
19372
19365
  otherwise: () => Yup.string().optional().nullable()
19373
19366
  }),
19374
- [PARTIES_FIELDS.VAT_NUMBER]: Yup.string().optional().nullable(),
19375
- [PARTIES_FIELDS.CRN]: Yup.string().optional().nullable(),
19367
+ [PARTIES_FIELDS.VAT_NUMBER]: Yup.string().optional().nullable().max(15, "VAT number should not exceed 15 digits").matches(/^\d{15}$/, { excludeEmptyString: true, message: "VAT number should have exactly 15 digits" }),
19368
+ [PARTIES_FIELDS.CRN]: Yup.string().optional().nullable().max(10, "CRN should not exceed 10 digits").matches(/^\d{10}$/, { excludeEmptyString: true, message: "CRN should have exactly 10 digits" }),
19376
19369
  [PARTIES_FIELDS.COMPANY]: Yup.mixed().required("Company is required"),
19377
19370
  [PARTIES_FIELDS.CURRENCY]: Yup.array().required("Currency is required"),
19378
19371
  [PARTIES_FIELDS.RESPONSIBLE_PERSON]: Yup.string().required("Responsible Person is required"),
@@ -19427,7 +19420,8 @@ const getDefaultConfig = (props, user) => {
19427
19420
  const useDefaultConfig = ({
19428
19421
  props,
19429
19422
  setValue,
19430
- isInternalOptions
19423
+ isInternalOptions,
19424
+ watchedValue
19431
19425
  }) => {
19432
19426
  const { user: authUser } = useAuth();
19433
19427
  const contextUser = getEffectiveUser(authUser);
@@ -19435,15 +19429,19 @@ const useDefaultConfig = ({
19435
19429
  useEffect(() => {
19436
19430
  const user = getEffectiveUser(contextUser);
19437
19431
  const { value, options } = getDefaultConfig(props, user);
19432
+ if (!isInternalOptions) {
19433
+ setDefaultOptions(options);
19434
+ }
19435
+ const hasValue2 = watchedValue !== null && watchedValue !== void 0 && watchedValue !== "" && (!Array.isArray(watchedValue) || watchedValue.length > 0);
19436
+ if (hasValue2) {
19437
+ return;
19438
+ }
19438
19439
  if (value === null || value === void 0) {
19439
19440
  return;
19440
19441
  }
19441
19442
  if (typeof setValue === "function") {
19442
19443
  setValue(`${props.fieldArrayName}.${props.name}`, (props == null ? void 0 : props.is_multiselect) ? [value] : value);
19443
19444
  }
19444
- if (!isInternalOptions) {
19445
- setDefaultOptions(options);
19446
- }
19447
19445
  }, [props == null ? void 0 : props.name, props == null ? void 0 : props.apiType, contextUser, setValue, isInternalOptions]);
19448
19446
  return {
19449
19447
  defaultOptions
@@ -19668,7 +19666,8 @@ const DynamicSearchSelect = React__default.memo((props) => {
19668
19666
  const { defaultOptions = [] } = useDefaultConfig({
19669
19667
  props,
19670
19668
  setValue,
19671
- isInternalOptions
19669
+ isInternalOptions,
19670
+ watchedValue
19672
19671
  });
19673
19672
  const searchOptionsLocally = useCallback((searchTerm, value) => {
19674
19673
  const currentOptions = props.options && props.options.length > 0 ? props.options : defaultOptions || [];
@@ -27229,7 +27228,8 @@ const InlineEditFields = ({
27229
27228
  isInternal: (fieldProperties == null ? void 0 : fieldProperties.isInternal) || !(fieldProperties == null ? void 0 : fieldProperties.apiType),
27230
27229
  multiple: fieldProperties == null ? void 0 : fieldProperties.is_multiple,
27231
27230
  value: (fieldProperties == null ? void 0 : fieldProperties.is_multiple) ? Array.isArray(inputValue == null ? void 0 : inputValue[column.id]) ? inputValue == null ? void 0 : inputValue[column.id] : [] : inputValue == null ? void 0 : inputValue[column.id],
27232
- getSelectedData: (row2) => getSelectedData(fieldProperties == null ? void 0 : fieldProperties.field_name, row2)
27231
+ getSelectedData: (row2) => getSelectedData(fieldProperties == null ? void 0 : fieldProperties.field_name, row2),
27232
+ disabled: fieldDisbled
27233
27233
  }
27234
27234
  ),
27235
27235
  (errors == null ? void 0 : errors[column.id]) && /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { color: "theme.error.600", type: "s5", children: errors == null ? void 0 : errors[column.id] })
@@ -27497,6 +27497,18 @@ const MaterialTable = React__default.memo(({
27497
27497
  /^(https?:\/\/)?((([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,})|localhost)(:\d{2,5})?(\/[a-zA-Z0-9#_-]+\/?)*(\?[a-zA-Z0-9&=_-]+)?(#\S+)?$/,
27498
27498
  { excludeEmptyString: true, message: "Please enter valid URL." }
27499
27499
  );
27500
+ case "date":
27501
+ case "date_time":
27502
+ case "time":
27503
+ return Yup.date().transform((value, originalValue) => {
27504
+ if (originalValue && typeof originalValue === "object" && "toDate" in originalValue) {
27505
+ return originalValue.toDate();
27506
+ }
27507
+ return value;
27508
+ }).typeError("Valid date is required");
27509
+ case "file":
27510
+ case "image":
27511
+ return Yup.mixed().nullable();
27500
27512
  default:
27501
27513
  return Yup.string();
27502
27514
  }
@@ -27538,6 +27550,17 @@ const MaterialTable = React__default.memo(({
27538
27550
  )) || validations;
27539
27551
  }
27540
27552
  });
27553
+ case "validate":
27554
+ if (typeof validation.callback === "function") {
27555
+ vld = vld.test(
27556
+ validation.name || "custom-validate",
27557
+ validation.msg_en || "Validation failed",
27558
+ function(value) {
27559
+ return validation.callback(value, this.parent);
27560
+ }
27561
+ );
27562
+ }
27563
+ break;
27541
27564
  default:
27542
27565
  vld = validations;
27543
27566
  break;
@@ -28857,7 +28880,8 @@ ${val}`;
28857
28880
  name: PARTIES_FIELDS.VAT_NUMBER,
28858
28881
  placeholder: t("common.party.fields.vat_number_placeholder"),
28859
28882
  fieldArrayName: PARTIES_FORM_ARRAY_NAME,
28860
- formControl: control
28883
+ formControl: control,
28884
+ max: 15
28861
28885
  }
28862
28886
  ) }),
28863
28887
  /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, xs: 12, sm: 6, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -28867,7 +28891,8 @@ ${val}`;
28867
28891
  name: PARTIES_FIELDS.CRN,
28868
28892
  placeholder: t("common.party.fields.crn_placeholder"),
28869
28893
  fieldArrayName: PARTIES_FORM_ARRAY_NAME,
28870
- formControl: control
28894
+ formControl: control,
28895
+ max: 10
28871
28896
  }
28872
28897
  ) })
28873
28898
  ] }),
@@ -34568,32 +34593,38 @@ const teamValidationSchema = Yup.object().shape({
34568
34593
  description: Yup.string()
34569
34594
  })
34570
34595
  });
34571
- const DEFAULT_VALUES = {
34596
+ const getDefaultValues$2 = (initialValues) => ({
34572
34597
  team: {
34573
34598
  name: "",
34574
- department_id: null,
34599
+ department_id: (initialValues == null ? void 0 : initialValues.department_id) ?? null,
34575
34600
  team_lead_id: null,
34576
34601
  member_ids: null,
34577
34602
  description: ""
34578
34603
  }
34579
- };
34604
+ });
34580
34605
  const TeamAddModal = ({
34581
34606
  isOpen,
34582
34607
  setIsOpen,
34583
34608
  onSave,
34584
34609
  isLoading,
34585
- modalProps
34610
+ modalProps,
34611
+ initialValues
34586
34612
  }) => {
34587
34613
  const { t } = useTranslation();
34588
34614
  const { control, handleSubmit, reset, watch } = useForm({
34589
34615
  mode: "all",
34590
34616
  resolver: o(teamValidationSchema),
34591
- defaultValues: DEFAULT_VALUES
34617
+ defaultValues: getDefaultValues$2(initialValues)
34592
34618
  });
34593
34619
  const selectedDepartmentId = watch("team.department_id");
34594
34620
  const selectedTeamLeadId = watch("team.team_lead_id");
34621
+ useEffect(() => {
34622
+ if (isOpen) {
34623
+ reset(getDefaultValues$2(initialValues));
34624
+ }
34625
+ }, [isOpen]);
34595
34626
  const handleModalClose = () => {
34596
- reset(DEFAULT_VALUES);
34627
+ reset(getDefaultValues$2(initialValues));
34597
34628
  setIsOpen();
34598
34629
  };
34599
34630
  const onSubmit = async (values) => {
@@ -34720,44 +34751,40 @@ const departmentValidationSchema = Yup.object().shape({
34720
34751
  description: Yup.string()
34721
34752
  })
34722
34753
  });
34754
+ const getDefaultValues$1 = (initialValues) => ({
34755
+ department: {
34756
+ company_id: (initialValues == null ? void 0 : initialValues.company_id) ?? null,
34757
+ department_code: "",
34758
+ name: "",
34759
+ parent_department_id: (initialValues == null ? void 0 : initialValues.parent_department_id) ?? null,
34760
+ department_head_id: null,
34761
+ cost_code: "",
34762
+ status: true,
34763
+ description: ""
34764
+ }
34765
+ });
34723
34766
  const DepartmentAddModal = ({
34724
34767
  isOpen,
34725
34768
  setIsOpen,
34726
34769
  onSave,
34727
34770
  isLoading,
34728
- modalProps
34771
+ modalProps,
34772
+ initialValues
34729
34773
  }) => {
34730
34774
  const { t } = useTranslation();
34731
34775
  const { control, handleSubmit, reset, trigger, watch } = useForm({
34732
34776
  mode: "all",
34733
34777
  resolver: o(departmentValidationSchema),
34734
- defaultValues: {
34735
- department: {
34736
- company_id: null,
34737
- department_code: "",
34738
- name: "",
34739
- parent_department_id: null,
34740
- department_head_id: null,
34741
- cost_code: "",
34742
- status: true,
34743
- description: ""
34744
- }
34745
- }
34778
+ defaultValues: getDefaultValues$1(initialValues)
34746
34779
  });
34747
34780
  const rootCompanyId = watch("department.company_id");
34781
+ useEffect(() => {
34782
+ if (isOpen) {
34783
+ reset(getDefaultValues$1(initialValues));
34784
+ }
34785
+ }, [isOpen]);
34748
34786
  const handleModalClose = () => {
34749
- reset({
34750
- department: {
34751
- company_id: null,
34752
- department_code: "",
34753
- name: "",
34754
- parent_department_id: null,
34755
- department_head_id: null,
34756
- cost_code: "",
34757
- status: true,
34758
- description: ""
34759
- }
34760
- });
34787
+ reset(getDefaultValues$1(initialValues));
34761
34788
  setIsOpen();
34762
34789
  };
34763
34790
  const onSubmit = async (values) => {
@@ -34847,7 +34874,8 @@ const DepartmentAddModal = ({
34847
34874
  required: false,
34848
34875
  options: [],
34849
34876
  customeFilter: {
34850
- "&company_id.eq": rootCompanyId || 0
34877
+ "&company_id.eq": rootCompanyId || 0,
34878
+ "&is_active.eq": 1
34851
34879
  }
34852
34880
  }
34853
34881
  ) }),
@@ -35025,51 +35053,51 @@ const LocationAddModal = ({
35025
35053
  };
35026
35054
  const designationValidationSchema = Yup.object().shape({
35027
35055
  designation: Yup.object().shape({
35028
- company_id: Yup.string().nullable().required("Company is required"),
35056
+ company_id: Yup.number().nullable().required("Company is required"),
35029
35057
  designation_code: Yup.string(),
35030
35058
  name: Yup.string().required("Designation Name is required"),
35059
+ department_id: Yup.number().nullable().required("Department is required"),
35031
35060
  reports_to: Yup.string().nullable(),
35032
35061
  level: Yup.number().nullable().typeError("Level must be a number"),
35033
35062
  status: Yup.boolean(),
35034
35063
  description: Yup.string()
35035
35064
  })
35036
35065
  });
35066
+ const getDefaultValues = (initialValues) => ({
35067
+ designation: {
35068
+ company_id: (initialValues == null ? void 0 : initialValues.company_id) ?? null,
35069
+ designation_code: "",
35070
+ name: "",
35071
+ department_id: (initialValues == null ? void 0 : initialValues.department_id) ?? null,
35072
+ reports_to: (initialValues == null ? void 0 : initialValues.parent_designation_id) ?? null,
35073
+ level: null,
35074
+ status: true,
35075
+ description: ""
35076
+ }
35077
+ });
35037
35078
  const DesignationAddModal = ({
35038
35079
  isOpen,
35039
35080
  setIsOpen,
35040
35081
  onSave,
35041
35082
  isLoading,
35042
- modalProps
35083
+ modalProps,
35084
+ initialValues
35043
35085
  }) => {
35044
35086
  const { t } = useTranslation();
35045
35087
  const { control, handleSubmit, reset, trigger, watch } = useForm({
35046
35088
  mode: "all",
35047
35089
  resolver: o(designationValidationSchema),
35048
- defaultValues: {
35049
- designation: {
35050
- company_id: null,
35051
- designation_code: "",
35052
- name: "",
35053
- reports_to: null,
35054
- level: null,
35055
- status: true,
35056
- description: ""
35057
- }
35058
- }
35090
+ defaultValues: getDefaultValues(initialValues)
35059
35091
  });
35060
- watch("designation.company_id");
35092
+ const rootCompanyId = watch("designation.company_id");
35093
+ const rootDepartmentId = watch("designation.department_id");
35094
+ useEffect(() => {
35095
+ if (isOpen) {
35096
+ reset(getDefaultValues(initialValues));
35097
+ }
35098
+ }, [isOpen]);
35061
35099
  const handleModalClose = () => {
35062
- reset({
35063
- designation: {
35064
- company_id: null,
35065
- designation_code: "",
35066
- name: "",
35067
- reports_to: null,
35068
- level: null,
35069
- status: true,
35070
- description: ""
35071
- }
35072
- });
35100
+ reset(getDefaultValues(initialValues));
35073
35101
  setIsOpen();
35074
35102
  };
35075
35103
  const onSubmit = async (values) => {
@@ -35106,6 +35134,23 @@ const DesignationAddModal = ({
35106
35134
  options: []
35107
35135
  }
35108
35136
  ) }),
35137
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, sm: 12, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35138
+ DynamicSearchSelect,
35139
+ {
35140
+ label: t("hrms.organization_structure.designationModal.department_label", "Department"),
35141
+ name: "department_id",
35142
+ placeholder: t("hrms.organization_structure.designationModal.department_placeholder", "Select Department"),
35143
+ fieldArrayName: "designation",
35144
+ formControl: control,
35145
+ apiType: "department",
35146
+ required: true,
35147
+ options: [],
35148
+ customeFilter: {
35149
+ "&company_id.eq": rootCompanyId || 0
35150
+ // '&is_active.eq': 1
35151
+ }
35152
+ }
35153
+ ) }),
35109
35154
  /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, sm: 6, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35110
35155
  DynamicInput,
35111
35156
  {
@@ -35137,8 +35182,13 @@ const DesignationAddModal = ({
35137
35182
  placeholder: t("hrms.organization_structure.designationModal.reports_to_placeholder", "Select Reports To"),
35138
35183
  fieldArrayName: "designation",
35139
35184
  formControl: control,
35140
- apiType: "roles",
35141
- required: false
35185
+ apiType: "designation",
35186
+ required: false,
35187
+ options: [],
35188
+ customeFilter: {
35189
+ "&company_id.eq": rootCompanyId || 0,
35190
+ "&department_id.eq": rootDepartmentId || 0
35191
+ }
35142
35192
  }
35143
35193
  ) }),
35144
35194
  /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, sm: 6, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -35149,6 +35199,7 @@ const DesignationAddModal = ({
35149
35199
  label: t("hrms.organization_structure.designationModal.level_label", "Level"),
35150
35200
  name: "level",
35151
35201
  fieldArrayName: "designation",
35202
+ disabled: true,
35152
35203
  placeholder: t("hrms.organization_structure.designationModal.level_placeholder", "Enter Level")
35153
35204
  }
35154
35205
  ) }),
@@ -40733,4 +40784,4 @@ export {
40733
40784
  DynamicTagsInput as y,
40734
40785
  DynamicTime as z
40735
40786
  };
40736
- //# sourceMappingURL=android-12-switch-Nw977vtV.esm.js.map
40787
+ //# sourceMappingURL=android-12-switch-BJGIDwYR.esm.js.map