admin_lsac 2.0.10 → 2.0.12

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.
@@ -91,7 +91,7 @@ export function AdminPage({ pages, selectedPage, basePath, apiURL = '', }) {
91
91
  rowActionsMenu.remove();
92
92
  }
93
93
  }, children: rowAction.name }, index)));
94
- } }) }), _jsxs(Modal, { size: '6xl', isOpen: isOpen, onClose: onClose, children: [_jsx(ModalOverlay, {}), _jsxs(ModalContent, { children: [_jsx(ModalHeader, { children: selectedAction.name }), _jsx(ModalCloseButton, {}), _jsxs(ModalBody, { children: [selectedAction.fields && selectedAction.fields?.length > 0 ? (_jsx(GenericForm, { action: selectedAction, onClose: onClose, rowId: rowId, rowObject: rowObject })) : (_jsx(Button, { colorScheme: "blue", mr: 3, onClick: () => {
94
+ } }) }), _jsxs(Modal, { size: '6xl', isOpen: isOpen, onClose: onClose, children: [_jsx(ModalOverlay, {}), _jsxs(ModalContent, { children: [_jsx(ModalHeader, { children: selectedAction.name }), _jsx(ModalCloseButton, {}), _jsxs(ModalBody, { children: [selectedAction.fields ? (_jsx(GenericForm, { action: selectedAction, onClose: onClose, rowId: rowId, rowObject: rowObject })) : (_jsx(Button, { colorScheme: "blue", mr: 3, onClick: () => {
95
95
  selectedAction.onSubmit(rowId);
96
96
  onClose();
97
97
  }, children: "Confirm Action" })), _jsx(Button, { colorScheme: "red", mr: 3, onClick: onClose, children: "Close" })] })] })] })] }));
@@ -34,14 +34,14 @@ function parseValidation(fields) {
34
34
  function generateSingleField(formfield, fieldName, key) {
35
35
  return (_jsx(Field, { name: fieldName, children: ({ field, form }) => (_jsxs(FormControl, { isInvalid: getIn(form.touched, fieldName) && getIn(form.errors, fieldName), children: [_jsx(FormLabel, { marginTop: 2, children: formfield.label }), formfield.type === 'string' ||
36
36
  formfield.type === 'number' ||
37
- formfield.type === 'date' ? (_jsx(Input, { ...field, value: field.value || '', type: formfield.type === 'number' || formfield.type === 'date' ? formfield.type : 'text' })) : formfield.type === 'file' ? (_jsx(Input, { type: "file", name: fieldName, onChange: (event) => {
37
+ formfield.type === 'date' ? (_jsx(Input, { ...field, value: '' + field.value || '', type: formfield.type === 'number' || formfield.type === 'date' ? formfield.type : 'text' })) : formfield.type === 'file' ? (_jsx(Input, { type: "file", name: fieldName, onChange: (event) => {
38
38
  if (event.currentTarget.files != null) {
39
39
  form.setFieldValue(fieldName, event.currentTarget.files[0]);
40
40
  }
41
41
  } })) : (_jsxs(Select, { ...field, value: field.value || '', onChange: (e) => {
42
- const selectedOption = formfield.options?.find((option) => option.value.toString() === e.target.value);
42
+ const selectedOption = formfield.options?.[parseInt(e.target.value)];
43
43
  form.setFieldValue(fieldName, selectedOption?.value);
44
- }, children: [_jsx("option", { disabled: true, value: "", children: "Select an option!" }), formfield.options?.map((option, key) => (_jsx("option", { value: `${option.value}`, children: option.display }, key)))] })), _jsx(FormErrorMessage, { children: getIn(form.errors, fieldName) })] })) }, key));
44
+ }, children: [_jsx("option", { disabled: true, value: "", children: "Select an option!" }), formfield.options?.map((option, key) => (_jsx("option", { value: key, children: option.display }, key)))] })), _jsx(FormErrorMessage, { children: getIn(form.errors, fieldName) })] })) }, key));
45
45
  }
46
46
  function parseFields(fields, previous) {
47
47
  if (!fields) {
@@ -80,16 +80,10 @@ function getCustomInitialValues(fields) {
80
80
  return obj;
81
81
  }
82
82
  fields.forEach((field) => {
83
- if (field.type === 'array')
84
- obj[field.name] = [];
85
- else if (field.type === 'object')
83
+ if (field.type === 'object')
86
84
  obj[field.name] = getCustomInitialValues(field.fields);
87
- else if (field.type === 'string')
88
- obj[field.name] = '';
89
- else if (field.type === 'number')
90
- obj[field.name] = 0;
91
85
  else
92
- obj[field.name] = null;
86
+ obj[field.name] = undefined;
93
87
  });
94
88
  return obj;
95
89
  }
@@ -128,8 +122,6 @@ export function GenericForm({ action, onClose, rowId, rowObject }) {
128
122
  const newInitialValues = await getInitialValues(action, rowId);
129
123
  setInitialValues(newInitialValues);
130
124
  };
131
- if (!action.fields)
132
- return _jsx(_Fragment, {});
133
125
  return (_jsx(_Fragment, { children: _jsx(Formik, { enableReinitialize: true, initialValues: initialValues, validationSchema: Yup.object(validationSchema), onReset: handleFormReset, onSubmit: async (values) => {
134
126
  try {
135
127
  if (rowObject !== undefined)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "admin_lsac",
3
3
  "private": false,
4
- "version": "2.0.10",
4
+ "version": "2.0.12",
5
5
  "description": "Generic Admin Panel created for storing events' data",
6
6
  "scripts": {
7
7
  "dev": "vite",