admin_lsac 2.0.0 → 2.0.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/README.md CHANGED
@@ -193,7 +193,7 @@ const companies: PageSchema = {
193
193
  name: "name",
194
194
  label: "Quiz Name",
195
195
  type: "string", // for every FormField, type must be specified
196
- validationSchema: Yup.string().required(),
196
+ validationSchema: Yup.string().required(), // you can also require 'boolean' values with Yup
197
197
  },
198
198
  {
199
199
  name: "questions",
@@ -36,7 +36,23 @@ function exportToCSV(data, filename) {
36
36
  }
37
37
  return formattedObj;
38
38
  };
39
- const formattedData = data.map(formatImageData);
39
+ const removeTimestamps = (obj) => {
40
+ const { createdAt, updatedAt, ...rest } = obj;
41
+ return rest;
42
+ };
43
+ const allKeys = new Set();
44
+ data.forEach((item) => {
45
+ Object.keys(formatImageData(removeTimestamps(item))).forEach((key) => allKeys.add(key));
46
+ });
47
+ const formattedData = data.map((item) => {
48
+ const newItem = formatImageData(removeTimestamps(item));
49
+ allKeys.forEach((key) => {
50
+ if (!(key in newItem)) {
51
+ newItem[key] = '';
52
+ }
53
+ });
54
+ return newItem;
55
+ });
40
56
  const csvConfig = mkConfig({
41
57
  useKeysAsHeaders: true,
42
58
  filename: filename,
@@ -37,7 +37,7 @@ function generateSingleField(formfield, fieldName, key) {
37
37
  if (event.currentTarget.files != null) {
38
38
  form.setFieldValue(fieldName, event.currentTarget.files[0]);
39
39
  }
40
- } })) : (_jsxs(Select, { ...field, defaultValue: "", 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));
40
+ } })) : formfield.type === 'date' ? (_jsx(Input, { ...field, type: "date", placeholder: "" })) : (_jsxs(Select, { ...field, defaultValue: "", 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));
41
41
  }
42
42
  function parseFields(fields, previous) {
43
43
  if (!fields) {
@@ -135,7 +135,7 @@ export function GenericForm({ action, onClose, rowId }) {
135
135
  await action.onSubmit(values);
136
136
  if (onClose)
137
137
  onClose();
138
- Swal.fire('Ok');
138
+ Swal.fire('Action/RowAction executed successfully');
139
139
  }
140
140
  catch (e) {
141
141
  if (onClose)
@@ -145,5 +145,5 @@ export function GenericForm({ action, onClose, rowId }) {
145
145
  text: 'Error: ' + err,
146
146
  });
147
147
  }
148
- }, children: ({ isSubmitting }) => (_jsxs(Form, { children: [formFields, _jsx(Button, { mt: 4, colorScheme: "teal", isLoading: isSubmitting, type: "submit", children: "Submit" }), _jsx(Button, { mt: 4, colorScheme: "teal", type: "reset", children: "Initialise Form" })] })) }) }));
148
+ }, children: ({ isSubmitting }) => (_jsxs(Form, { children: [formFields, _jsx(Button, { mt: 4, mb: 2, colorScheme: "teal", isLoading: isSubmitting, type: "submit", children: "Submit" }), action.initialise && (_jsx(Button, { mt: 4, mb: 2, ml: 4, colorScheme: "teal", type: "reset", children: "Initialise Form" }))] })) }) }));
149
149
  }
@@ -6,7 +6,7 @@ export interface TableField {
6
6
  export interface SimpleField {
7
7
  name: string;
8
8
  label: string;
9
- type: 'string' | 'number' | 'file';
9
+ type: 'string' | 'number' | 'file' | 'date';
10
10
  validationSchema: any;
11
11
  }
12
12
  export interface Option {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "admin_lsac",
3
3
  "private": false,
4
- "version": "2.0.0",
4
+ "version": "2.0.1",
5
5
  "description": "Generic Admin Panel created for storing events' data",
6
6
  "scripts": {
7
7
  "dev": "vite",