@asaleh37/ui-base 25.8.23 → 25.8.26-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asaleh37/ui-base",
3
- "version": "25.8.23",
3
+ "version": "25.8.26-1",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Ahmed Saleh Mohamed",
@@ -116,6 +116,7 @@ const EntityParameterGrid: React.FC = () => {
116
116
  required: true,
117
117
  fieldType: "combobox",
118
118
  options: SystemParameterTypes,
119
+ comboboxValueDataType: "string",
119
120
  optionDisplayField: "value",
120
121
  optionValueField: "value",
121
122
  formProps: {
@@ -113,6 +113,7 @@ const MailRecipientGrid: React.FC<MailRecipientGridProps> = (props) => {
113
113
  options: [{ value: "To" }, { value: "CC" }],
114
114
  optionDisplayField: "value",
115
115
  optionValueField: "value",
116
+ comboboxValueDataType: "string",
116
117
  },
117
118
  },
118
119
  {
@@ -142,7 +143,7 @@ const MailRecipientGrid: React.FC<MailRecipientGridProps> = (props) => {
142
143
  apiActions={apiActions}
143
144
  data={data}
144
145
  hideInfoBar={true}
145
- gridLoadParametersValues={{mailTemplateId:props.selectedRecord.id}}
146
+ gridLoadParametersValues={{ mailTemplateId: props.selectedRecord.id }}
146
147
  setData={setData}
147
148
  editMode={{ editMode: "row" }}
148
149
  formElements={formElements}
@@ -210,6 +210,7 @@ const MailSenderConfigGrid: React.FC = () => {
210
210
  fieldName: "mailEngine",
211
211
  required: true,
212
212
  fieldType: "combobox",
213
+ comboboxValueDataType: "string",
213
214
  options: [{ value: "Gmail" }, { value: "Azure" }],
214
215
  optionDisplayField: "value",
215
216
  optionValueField: "value",
@@ -61,7 +61,7 @@ const adjustFormAccordingToReportType = (
61
61
  value: any,
62
62
  formActions: FormActionProps,
63
63
  formManager: UseFormReturn
64
- ) => {
64
+ ) => {
65
65
  if (value && validationObject[value]) {
66
66
  const validationObjects: ReportValidationOptions = validationObject[value];
67
67
  const fields = Object.keys(validationObjects);
@@ -208,6 +208,7 @@ const ReportGrid: React.FC = () => {
208
208
  optionValueField: "value",
209
209
  required: true,
210
210
  fieldType: "combobox",
211
+ comboboxValueDataType: "string",
211
212
  formProps: {
212
213
  onValueChangeCallBack(
213
214
  value,
@@ -247,6 +248,7 @@ const ReportGrid: React.FC = () => {
247
248
  fieldLabel: "ATTACHMENT_CONFIG_STORAGE_TYPE",
248
249
  fieldName: "storageType",
249
250
  required: true,
251
+ comboboxValueDataType: "string",
250
252
  fieldType: "combobox",
251
253
  options: storageTypes,
252
254
  optionDisplayField: "value",
@@ -354,10 +356,10 @@ const ReportGrid: React.FC = () => {
354
356
  props: {
355
357
  fieldLabel: "REPORT_REPORT_EXCEL_DATA_QUERY_ID",
356
358
  fieldName: "reportExcelDataQueryId",
357
- hidden: true,
358
- gridProps: {
359
- hidden: true,
360
- },
359
+ // hidden: true,
360
+ // gridProps: {
361
+ // hidden: true,
362
+ // },
361
363
  required: false,
362
364
  fieldType: "combobox",
363
365
  options: SystemDataQueries,
@@ -53,6 +53,9 @@ const Login: React.FC = () => {
53
53
  ...response.data,
54
54
  isAuthenticated: true,
55
55
  };
56
+ if (response?.data?.token) {
57
+ localStorage.setItem("TOKEN", response.data.token);
58
+ }
56
59
  dispatch(UserSessionActions.setAuthenticated(UserSession));
57
60
  }
58
61
  } catch (e: any) {
@@ -101,11 +104,13 @@ const Login: React.FC = () => {
101
104
  const checkUserSession = async () => {
102
105
  if (appInfo?.apiBaseUrl) {
103
106
  if (userSession.isAuthenticated == null) {
107
+ const token = localStorage.getItem("TOKEN");
104
108
  try {
105
109
  let response = await axios.get(
106
110
  `${appInfo.apiBaseUrl}/api/auth/userInfo`,
107
111
  {
108
112
  withCredentials: true,
113
+ headers: { Authorization: `Bearer ${token}` },
109
114
  }
110
115
  );
111
116
  if (response != null && response.data != null) {
@@ -1,3 +1,4 @@
1
+ import { DataGridPremium } from "@mui/x-data-grid-premium";
1
2
  export * from "./BaseApp";
2
3
  export * from "@mui/material";
3
4
  export * from "@mui/lab";
@@ -6,3 +7,4 @@ export { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
7
  export type { FontAwesomeIconProps } from "@fortawesome/react-fontawesome";
7
8
  export * from "./templates";
8
9
  export * from "@mui/x-tree-view/models";
10
+ export { DataGridPremium } ;
@@ -189,6 +189,7 @@ export type RecordFieldProps = {
189
189
  | "lookup"
190
190
  | "custom";
191
191
  lookupType?: string;
192
+ comboboxValueDataType?: "number" | "string";
192
193
  required?: boolean;
193
194
  disabled?: boolean;
194
195
  hidden?: boolean;
@@ -197,6 +197,36 @@ export const constructValidationSchema = (fields: Array<RecordFieldProps>) => {
197
197
  } else {
198
198
  validationSchemaObj[fieldName] = z.boolean().optional().nullable();
199
199
  }
200
+ } else if (field.fieldType === "combobox") {
201
+ if (field?.comboboxValueDataType) {
202
+ if (field?.comboboxValueDataType === "number") {
203
+ if (field?.required === true) {
204
+ validationSchemaObj[fieldName] = z.number({
205
+ required_error: "This field is required",
206
+ invalid_type_error: "This field must be a number",
207
+ });
208
+ } else {
209
+ validationSchemaObj[fieldName] = z.number().optional().nullable();
210
+ }
211
+ } else if (field?.comboboxValueDataType === "string") {
212
+ if (field?.required === true) {
213
+ validationSchemaObj[fieldName] = z
214
+ .string({ message: "This field is required" })
215
+ .min(1, "This field is required");
216
+ } else {
217
+ validationSchemaObj[fieldName] = z.string().optional().nullable();
218
+ }
219
+ }
220
+ } else {
221
+ if (field?.required === true) {
222
+ validationSchemaObj[fieldName] = z.number({
223
+ required_error: "This field is required",
224
+ invalid_type_error: "This field must be a number",
225
+ });
226
+ } else {
227
+ validationSchemaObj[fieldName] = z.number().optional().nullable();
228
+ }
229
+ }
200
230
  } else {
201
231
  if (field?.required === true) {
202
232
  validationSchemaObj[fieldName] = z
@@ -229,7 +229,7 @@ const FormElementField: React.FC<FormElementFieldProps> = (
229
229
  onChangeCallBack={(v: any, selectedRecord: any) => {
230
230
  let newValue = null;
231
231
  if (v) {
232
- newValue = v ;
232
+ newValue = v;
233
233
  }
234
234
  formManager.setValue(fieldName, newValue);
235
235
  if (props?.formProps?.onValueChangeCallBack) {
@@ -22,7 +22,7 @@ const ComboBox: React.FC<ComboBoxProps> = (props) => {
22
22
  const getValue = (v: string) => {
23
23
  for (let option of props.options) {
24
24
  if (option[props.valueField] == v) {
25
- return option + "";
25
+ return option;
26
26
  }
27
27
  }
28
28
  return null;
@@ -41,7 +41,7 @@ const ComboBox: React.FC<ComboBoxProps> = (props) => {
41
41
  ) {
42
42
  if (newValue != null) {
43
43
  let v = newValue[props.valueField];
44
- props.onChangeCallBack(v + "", newValue);
44
+ props.onChangeCallBack(v, newValue);
45
45
  } else {
46
46
  props.onChangeCallBack(null, null);
47
47
  }
@@ -100,10 +100,20 @@ const TemplateForm: React.FC<TemplateFormProps> = (
100
100
  field?.fieldType === "combobox" &&
101
101
  retrievedRecord[field.fieldName]
102
102
  ) {
103
- formManager.setValue(
104
- field.fieldName,
105
- retrievedRecord[field.fieldName] + ""
106
- );
103
+ if (
104
+ field?.comboboxValueDataType &&
105
+ field?.comboboxValueDataType === "string"
106
+ ) {
107
+ formManager.setValue(
108
+ field.fieldName,
109
+ retrievedRecord[field.fieldName] + ""
110
+ );
111
+ } else {
112
+ formManager.setValue(
113
+ field.fieldName,
114
+ retrievedRecord[field.fieldName]
115
+ );
116
+ }
107
117
  }
108
118
  }
109
119
  }
@@ -89,7 +89,7 @@ export const generateComboColumn: (
89
89
  type: "custom",
90
90
  valueGetter: (value) => {
91
91
  if (value) {
92
- return value + "";
92
+ return value;
93
93
  }
94
94
  return value;
95
95
  },
@@ -128,7 +128,7 @@ export const generateComboColumn: (
128
128
  params.api.setEditCellValue({
129
129
  id: params.id,
130
130
  field: params.field,
131
- value: v + "",
131
+ value: v,
132
132
  });
133
133
  }}
134
134
  />
@@ -744,23 +744,24 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
744
744
  }
745
745
  };
746
746
 
747
- const handleColumnWidthChange: GridEventListener<"columnWidthChange"> = (
748
- params: GridColumnResizeParams
749
- ) => {
750
- const updatedWidths = {
751
- ...columnWidths,
752
- [params.colDef.field]: params.width,
753
- };
754
- setColumnWidths(updatedWidths);
755
- if (props?.gridStateKey) {
756
- saveGridState(props.gridStateKey, { columnWidths: updatedWidths });
757
- }
758
- };
747
+ // const handleColumnWidthChange: GridEventListener<"columnWidthChange"> = (
748
+ // params: GridColumnResizeParams
749
+ // ) => {
750
+ // const updatedWidths = {
751
+ // ...columnWidths,
752
+ // [params.colDef.field]: params.width,
753
+ // };
754
+ // setColumnWidths(updatedWidths);
755
+ // if (props?.gridStateKey) {
756
+ // saveGridState(props.gridStateKey, { columnWidths: updatedWidths });
757
+ // }
758
+ // };
759
759
 
760
760
  const adjustedColumns: Array<TemplateGridColDef> = React.useMemo(() => {
761
761
  const baseCols = structuredColumns.map((col) => ({
762
762
  ...col,
763
- width: columnWidths[col.field] || col.width,
763
+ minWidth: col?.width || 200,
764
+ flex: 1,
764
765
  }));
765
766
 
766
767
  // Reorder based on saved columnOrder
@@ -768,9 +769,9 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
768
769
  const fieldToCol = new Map(baseCols.map((col) => [col.field, col]));
769
770
  return columnOrder.map((field) => fieldToCol.get(field)!).filter(Boolean);
770
771
  }
771
-
772
772
  return baseCols;
773
773
  }, [columnOrder, columnWidths, structuredColumns]);
774
+
774
775
  return (
775
776
  <>
776
777
  <ConfirmationWindow />
@@ -984,7 +985,7 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
984
985
  columnVisibilityModel={columnVisibilityModel}
985
986
  onColumnVisibilityModelChange={handleColumnVisibilityChange}
986
987
  onColumnOrderChange={handleColumnOrderChange}
987
- onColumnWidthChange={handleColumnWidthChange}
988
+ // onColumnWidthChange={handleColumnWidthChange}
988
989
  rowGroupingModel={gridRowGroupingModel}
989
990
  onRowGroupingModelChange={(model: GridRowGroupingModel) => {
990
991
  handleRowGroupChange(model);
@@ -27,7 +27,8 @@ const getGridColumnsFromRecord = (data: Array<any>) => {
27
27
  },
28
28
  };
29
29
  formElements.push(formElement);
30
- }
30
+ }
31
+ debugger;
31
32
  return formElements;
32
33
  };
33
34
 
@@ -10,6 +10,7 @@ import {
10
10
  } from "@mui/material";
11
11
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
12
12
  import { IconProp } from "@fortawesome/fontawesome-svg-core";
13
+ import { useSelector } from "react-redux";
13
14
 
14
15
  export interface TemplateWindowProp {
15
16
  height?: any;
@@ -27,7 +28,9 @@ interface WindowProps {
27
28
 
28
29
  export const useWindow = (props: TemplateWindowProp) => {
29
30
  const [windowState, setWindowState] = useState(false);
30
-
31
+ const appDirection = useSelector(
32
+ (state: any) => state.AppLayout.appDirection
33
+ );
31
34
  const Window: React.FC<WindowProps> = (windowProps: WindowProps) => {
32
35
  return (
33
36
  <Modal
@@ -40,6 +43,7 @@ export const useWindow = (props: TemplateWindowProp) => {
40
43
  }}
41
44
  >
42
45
  <Box
46
+ dir={appDirection}
43
47
  sx={{
44
48
  position: "absolute",
45
49
  top: "50%",
@@ -39,6 +39,16 @@ const useAxios = () => {
39
39
  });
40
40
 
41
41
  axiosInstance.defaults.withCredentials = true;
42
+ axiosInstance.interceptors.request.use(
43
+ (config) => {
44
+ const token = localStorage.getItem("TOKEN");
45
+ if (token) {
46
+ config.headers.Authorization = `Bearer ${token}`;
47
+ }
48
+ return config;
49
+ },
50
+ (error) => Promise.reject(error)
51
+ );
42
52
  axiosInstance.interceptors.response.use(
43
53
  (response: any) => {
44
54
  return response;
@@ -36,7 +36,7 @@ const MainContent: React.FC = () => {
36
36
  stores[storeKey]?.url != "" &&
37
37
  stores[storeKey].autoLoad === true
38
38
  ) {
39
- await handleGetRequest({
39
+ handleGetRequest({
40
40
  endPointURI: stores[storeKey].url,
41
41
  showMask: false,
42
42
  successCallBkFn: (response) => {
@@ -61,55 +61,57 @@ const MainContent: React.FC = () => {
61
61
  <CacheProvider
62
62
  value={AppLayoutState.appDirection === "ltr" ? cacheLtr : cacheRtl}
63
63
  >
64
- {isAutoLoadLoaded ? (
65
- <Box
66
- sx={{
67
- display: "flex",
68
- flexDirection: "column",
69
- // alignItems: "center",
70
- justifyContent: "flex-start",
71
- flex: 1,
72
- overflow: "hidden",
73
- padding: 3,
74
- }}
75
- >
76
- <Routes>
77
- {AppInfo.enableAdministrationModule
78
- ? SYSTEM_ROUTES.map((route: SystemRoute, index) => {
79
- return (
80
- <Route
81
- key={"adm" + index}
82
- path={route.path}
83
- element={
84
- <RouteWrapper
85
- authority={route.authority}
86
- applicationModule={route.applicationModule}
87
- >
88
- <route.component />
89
- </RouteWrapper>
90
- }
91
- />
92
- );
93
- })
94
- : null}
95
- {businessRoutes.map((route: SystemRoute, index) => {
96
- return (
97
- <Route
98
- key={"bs" + index}
99
- path={route.path}
100
- element={
101
- <RouteWrapper authority={route.authority}>
102
- <route.component />
103
- </RouteWrapper>
104
- }
105
- />
106
- );
107
- })}
108
- </Routes>
109
- </Box>
110
- ) : (
64
+ {/* {isAutoLoadLoaded ? ( */}
65
+ <Box
66
+ sx={{
67
+ display: "flex",
68
+ flexDirection: "column",
69
+ // alignItems: "center",
70
+ justifyContent: "flex-start",
71
+ flex: 1,
72
+ overflow: "hidden",
73
+ padding: 3,
74
+ }}
75
+ >
76
+ <Routes>
77
+ {AppInfo.enableAdministrationModule
78
+ ? SYSTEM_ROUTES.map((route: SystemRoute, index) => {
79
+ return (
80
+ <Route
81
+ key={"adm" + index}
82
+ path={route.path}
83
+ element={
84
+ <RouteWrapper
85
+ authority={route.authority}
86
+ applicationModule={route.applicationModule}
87
+ >
88
+ <route.component />
89
+ </RouteWrapper>
90
+ }
91
+ />
92
+ );
93
+ })
94
+ : null}
95
+ {businessRoutes.map((route: SystemRoute, index) => {
96
+ return (
97
+ <Route
98
+ key={"bs" + index}
99
+ path={route.path}
100
+ element={
101
+ <RouteWrapper authority={route.authority}>
102
+ <route.component />
103
+ </RouteWrapper>
104
+ }
105
+ />
106
+ );
107
+ })}
108
+ </Routes>
109
+ </Box>
110
+ )
111
+ {/* : (
111
112
  <></>
112
- )}
113
+ )
114
+ } */}
113
115
  </CacheProvider>
114
116
  );
115
117
  };