admin_lsac 1.3.2 → 1.4.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.
Files changed (79) hide show
  1. package/.eslintrc.cjs +18 -0
  2. package/README.md +162 -162
  3. package/dist/src/App.d.ts +7 -0
  4. package/dist/src/App.js +10 -0
  5. package/dist/src/components/AdminPage.d.ts +8 -0
  6. package/dist/{esm/components/Page.js → src/components/AdminPage.js} +35 -43
  7. package/dist/src/components/GenericForm.d.ts +8 -0
  8. package/dist/src/components/GenericForm.js +151 -0
  9. package/dist/src/main.d.ts +1 -0
  10. package/dist/src/main.js +7 -0
  11. package/dist/{App.d.ts → src/schema.d.ts} +53 -76
  12. package/dist/src/testSchemas/event.d.ts +2 -0
  13. package/dist/src/testSchemas/event.js +86 -0
  14. package/dist/src/utils/websockets.d.ts +1 -0
  15. package/dist/{esm → src}/utils/websockets.js +5 -5
  16. package/index.html +13 -0
  17. package/package.json +42 -73
  18. package/tsconfig.app.json +27 -0
  19. package/tsconfig.json +11 -31
  20. package/tsconfig.node.json +13 -0
  21. package/vite.config.ts +7 -0
  22. package/dist/App.js +0 -12
  23. package/dist/cjs/App.js +0 -12
  24. package/dist/cjs/components/GenericForm.js +0 -305
  25. package/dist/cjs/components/Page.js +0 -119
  26. package/dist/cjs/index.js +0 -18
  27. package/dist/cjs/pages/event.js +0 -134
  28. package/dist/cjs/pages/page.js +0 -375
  29. package/dist/cjs/reportWebVitals.js +0 -38
  30. package/dist/cjs/schema/schema.config.js +0 -9
  31. package/dist/cjs/schema/schema.js +0 -2
  32. package/dist/cjs/setupTests.js +0 -7
  33. package/dist/cjs/utils/websockets.js +0 -22
  34. package/dist/components/GenericForm.js +0 -305
  35. package/dist/components/Page.js +0 -119
  36. package/dist/esm/App.js +0 -10
  37. package/dist/esm/components/GenericForm.js +0 -275
  38. package/dist/esm/index.js +0 -13
  39. package/dist/esm/pages/event.js +0 -128
  40. package/dist/esm/pages/page.js +0 -349
  41. package/dist/esm/reportWebVitals.js +0 -13
  42. package/dist/esm/schema/schema.config.js +0 -6
  43. package/dist/esm/setupTests.js +0 -5
  44. package/dist/index.js +0 -18
  45. package/dist/pages/event.js +0 -134
  46. package/dist/pages/page.js +0 -375
  47. package/dist/reportWebVitals.js +0 -38
  48. package/dist/schema/schema.config.js +0 -9
  49. package/dist/schema/schema.js +0 -2
  50. package/dist/setupTests.js +0 -7
  51. package/dist/utils/websockets.js +0 -22
  52. package/public/favicon.ico +0 -0
  53. package/public/index.html +0 -43
  54. package/public/logo192.png +0 -0
  55. package/public/logo512.png +0 -0
  56. package/public/manifest.json +0 -25
  57. package/public/robots.txt +0 -3
  58. package/server/.env.example +0 -3
  59. package/server/deploy.js +0 -29
  60. package/server/package-lock.json +0 -712
  61. package/server/package.json +0 -18
  62. package/src/App.css +0 -38
  63. package/src/App.tsx +0 -50
  64. package/src/components/GenericForm.tsx +0 -308
  65. package/src/components/Page.tsx +0 -243
  66. package/src/index.css +0 -13
  67. package/src/index.tsx +0 -20
  68. package/src/logo.svg +0 -1
  69. package/src/pages/event.ts +0 -93
  70. package/src/pages/page.ts +0 -336
  71. package/src/react-app-env.d.ts +0 -1
  72. package/src/reportWebVitals.ts +0 -15
  73. package/src/schema/schema.config.ts +0 -8
  74. package/src/schema/schema.ts +0 -63
  75. package/src/setupTests.ts +0 -5
  76. package/src/utils/websockets.tsx +0 -17
  77. package/tsconfig.esm.json +0 -7
  78. package/webpack.config.js +0 -22
  79. /package/dist/{esm/schema → src}/schema.js +0 -0
@@ -1,93 +0,0 @@
1
- import axios from "axios";
2
- import React from "react";
3
- import { PageSchema } from "../schema/schema";
4
-
5
- const domain = "http://localhost:3001";
6
-
7
- export const event: PageSchema = {
8
- name: "Events",
9
- actions: [],
10
- rowActions: [
11
- // {
12
- // name: "Delete Event",
13
- // fields: [
14
- // {
15
- // name: "input",
16
- // label: "Mock Field",
17
- // type: "string",
18
- // validationSchema: "",
19
- // },
20
- // ],
21
- // initialise: async (eventId: number) => {
22
- // const res = await axios.get(domain + "/events/" + eventId);
23
- // let obj: any = {};
24
- // obj.input = res.data.name;
25
- // return obj;
26
- // },
27
- // onSubmit: async (formValues: any, eventId: number) => {
28
- // const res = await axios.delete(
29
- // domain + "/events/" + eventId
30
- // );
31
- // return res.data;
32
- // },
33
- // }
34
- ],
35
- getRequest: async () => {
36
- // const res = await axios.get(domain + "/events");
37
- // return res.data;
38
- return [];
39
- },
40
- tableFields: [
41
- {
42
- name: "Id",
43
- access: (obj: any) => obj.id,
44
- },
45
- {
46
- name: "Event Name",
47
- access: (obj: any) => obj.name,
48
- },
49
- {
50
- name: "Description",
51
- access: (obj: any) => obj.description,
52
- },
53
- {
54
- name: "Category",
55
- access: (obj: any) => obj.category,
56
- },
57
- {
58
- name: "Ticket Type",
59
- access: (obj: any) => obj.ticketType,
60
- },
61
- {
62
- name: "Date",
63
- access: (obj: any) => obj.date,
64
- },
65
- {
66
- name: "Release",
67
- access: (obj: any) => obj.release,
68
- },
69
- {
70
- name: "Is Released",
71
- access: (obj: any) => (obj.isReleased ? "Is Released" : "Not Released"),
72
- },
73
- {
74
- name: "Available Tickets",
75
- access: (obj: any) => obj.availableTickets,
76
- },
77
- {
78
- name: "Max Tickets",
79
- access: (obj: any) => obj.maxTickets,
80
- },
81
- {
82
- name: "Image",
83
- access: (obj: any) =>
84
- obj.imgUrl
85
- ? React.createElement("img", {
86
- src: obj.imgUrl,
87
- alt: "ERROR",
88
- style: { width: "100px" },
89
- })
90
- : "No Image Available",
91
- },
92
- ],
93
- };
package/src/pages/page.ts DELETED
@@ -1,336 +0,0 @@
1
- import { ArrayField, PageSchema } from "../schema/schema";
2
- import * as Yup from "yup";
3
-
4
- const typeAdding = (objectField: any): any => {
5
- objectField.type = "object";
6
- objectField.fields = [
7
- ...objectField.simpleFields,
8
- ...objectField.dropdownFields,
9
- ...objectField.objectFields,
10
- ...objectField.arrayFields,
11
- ];
12
-
13
- if (objectField.objectFields) {
14
- objectField.objectFields.map((objectField: any) => {
15
- objectField = typeAdding(objectField);
16
- return objectField;
17
- });
18
- }
19
-
20
- if (objectField.arrayFields) {
21
- objectField.arrayFields.map((arrayField: any) => {
22
- arrayField.element = typeAdding(arrayField.element);
23
- return arrayField;
24
- });
25
- }
26
-
27
- return objectField;
28
- };
29
-
30
- const arrayObjs = (x: number): ArrayField[] => {
31
- if (x > 0)
32
- return [
33
- {
34
- name: "simpleFields",
35
- label: "Type SimpleField",
36
- type: "array",
37
- element: {
38
- name: "",
39
- label: "",
40
- type: "object",
41
- fields: [
42
- {
43
- name: "name",
44
- label: "Name",
45
- type: "string",
46
- validationSchema: Yup.string().required(),
47
- },
48
- {
49
- name: "label",
50
- label: "Label",
51
- type: "string",
52
- validationSchema: Yup.string().required(),
53
- },
54
- {
55
- name: "type",
56
- label: "Type",
57
- type: "string",
58
- validationSchema: Yup.string().required(),
59
- },
60
- {
61
- name: "validationSchema",
62
- label: "Validation Schema",
63
- type: "string",
64
- validationSchema: Yup.string().required(),
65
- },
66
- ],
67
- },
68
- },
69
- {
70
- name: "dropdownFields",
71
- label: "Type DropdownField",
72
- type: "array",
73
- element: {
74
- name: "",
75
- label: "",
76
- type: "object",
77
- fields: [
78
- {
79
- name: "name",
80
- label: "Name",
81
- type: "string",
82
- validationSchema: Yup.string().required(),
83
- },
84
- {
85
- name: "label",
86
- label: "Label",
87
- type: "string",
88
- validationSchema: Yup.string().required(),
89
- },
90
- {
91
- name: "options",
92
- label: "Options",
93
- type: "array",
94
- element: {
95
- name: "",
96
- label: "",
97
- type: "object",
98
- fields: [
99
- {
100
- name: "value",
101
- label: "Value",
102
- type: "string",
103
- validationSchema: Yup.string().required(),
104
- },
105
- {
106
- name: "display",
107
- label: "Display",
108
- type: "string",
109
- validationSchema: Yup.string().required(),
110
- },
111
- ],
112
- },
113
- },
114
- {
115
- name: "getOptions",
116
- label: "GetOptions Function",
117
- type: "string",
118
- validationSchema: Yup.string().required(),
119
- },
120
- ],
121
- },
122
- },
123
- {
124
- name: "objectFields",
125
- label: "Type ObjectField",
126
- type: "array",
127
- element: {
128
- name: "",
129
- label: "",
130
- type: "object",
131
- fields: [
132
- {
133
- name: "name",
134
- label: "Name",
135
- type: "string",
136
- validationSchema: Yup.string().required(),
137
- },
138
- {
139
- name: "label",
140
- label: "Label",
141
- type: "string",
142
- validationSchema: Yup.string().required(),
143
- },
144
- ...arrayObjs(x - 1),
145
- ],
146
- },
147
- },
148
- {
149
- name: "arrayFields",
150
- label: "Type ArrayField",
151
- type: "array",
152
- element: {
153
- name: "",
154
- label: "",
155
- type: "object",
156
- fields: [
157
- {
158
- name: "name",
159
- label: "Name",
160
- type: "string",
161
- validationSchema: Yup.string().required(),
162
- },
163
- {
164
- name: "label",
165
- label: "Label",
166
- type: "string",
167
- validationSchema: Yup.string().required(),
168
- },
169
- ...arrayObjs(x - 1),
170
- ],
171
- },
172
- },
173
- ];
174
- else return [];
175
- };
176
-
177
- export const page: PageSchema = {
178
- name: "Pages",
179
- getRequest: async () => [],
180
- tableFields: [],
181
- actions: [
182
- {
183
- name: "Create New Page",
184
- fields: [
185
- {
186
- name: "name",
187
- label: "Page Name",
188
- type: "string",
189
- validationSchema: Yup.string().required(),
190
- },
191
- {
192
- name: "getRequest",
193
- label: "GetRequest",
194
- type: "string",
195
- validationSchema: Yup.string().required(),
196
- },
197
- {
198
- name: "tableFields",
199
- label: "TableFields",
200
- type: "array",
201
- element: {
202
- name: "",
203
- label: "",
204
- type: "object",
205
- fields: [
206
- {
207
- name: "name",
208
- label: "TableField Name",
209
- type: "string",
210
- validationSchema: Yup.string().required(),
211
- },
212
- {
213
- name: "access",
214
- label: "TableField Access Function",
215
- type: "string",
216
- validationSchema: Yup.string().required(),
217
- },
218
- ],
219
- },
220
- },
221
- {
222
- name: "actions",
223
- label: "Actions",
224
- type: "array",
225
- element: {
226
- name: "",
227
- label: "",
228
- type: "object",
229
- fields: [
230
- {
231
- name: "name",
232
- label: "Action Name",
233
- type: "string",
234
- validationSchema: Yup.string().required(),
235
- },
236
- ...arrayObjs(4),
237
- {
238
- name: "onSubmit",
239
- label: "Action OnSubmit Function",
240
- type: "string",
241
- validationSchema: Yup.string().required(),
242
- },
243
- ],
244
- },
245
- },
246
- {
247
- name: "rowActions",
248
- label: "Row Actions",
249
- type: "array",
250
- element: {
251
- name: "",
252
- label: "",
253
- type: "object",
254
- fields: [
255
- {
256
- name: "name",
257
- label: "Row Action Name",
258
- type: "string",
259
- validationSchema: Yup.string().required(),
260
- },
261
- ...arrayObjs(4),
262
- {
263
- name: "initialise",
264
- label: "Row Action Initialise Function",
265
- type: "string",
266
- validationSchema: "",
267
- },
268
- {
269
- name: "onSubmit",
270
- label: "Row Action OnSubmit Function",
271
- type: "string",
272
- validationSchema: Yup.string().required(),
273
- },
274
- ],
275
- },
276
- },
277
- ],
278
- onSubmit: async (formValues: any) => {
279
- if (Array.isArray(formValues.actions))
280
- formValues.actions.map((action: any) => {
281
- action.dropdownFields?.map(
282
- (actionField: any) => (actionField.type = "dropdown")
283
- );
284
-
285
- action.objectFields?.map(
286
- (actionField: any) => (actionField = typeAdding(actionField))
287
- );
288
-
289
- action.arrayFields?.map((actionField: any) => {
290
- actionField.type = "array";
291
- actionField.element = typeAdding(actionField.element);
292
- return actionField;
293
- });
294
-
295
- action.fields = [
296
- ...action.simpleFields,
297
- ...action.dropdownFields,
298
- ...action.objectFields,
299
- ...action.arrayFields,
300
- ];
301
- return action;
302
- });
303
-
304
- if (Array.isArray(formValues.rowActions))
305
- formValues.actions.map((rowAction: any) => {
306
- rowAction.dropdownFields?.map(
307
- (rowActionField: any) => (rowActionField.type = "dropdown")
308
- );
309
-
310
- rowAction.objectFields?.map(
311
- (rowActionField: any) =>
312
- (rowActionField = typeAdding(rowActionField))
313
- );
314
-
315
- rowAction.arrayFields?.map((rowActionField: any) => {
316
- rowActionField.type = "array";
317
- rowActionField.element = typeAdding(rowActionField.element);
318
- return rowActionField;
319
- });
320
-
321
- rowAction.fields = [
322
- ...rowAction.simpleFields,
323
- ...rowAction.dropdownFields,
324
- ...rowAction.objectFields,
325
- ...rowAction.arrayFields,
326
- ];
327
- return rowAction;
328
- });
329
-
330
- console.log(formValues);
331
- return [];
332
- },
333
- },
334
- ],
335
- rowActions: [],
336
- };
@@ -1 +0,0 @@
1
- /// <reference types="react-scripts" />
@@ -1,15 +0,0 @@
1
- import { ReportHandler } from "web-vitals";
2
-
3
- const reportWebVitals = (onPerfEntry?: ReportHandler) => {
4
- if (onPerfEntry && onPerfEntry instanceof Function) {
5
- import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
6
- getCLS(onPerfEntry);
7
- getFID(onPerfEntry);
8
- getFCP(onPerfEntry);
9
- getLCP(onPerfEntry);
10
- getTTFB(onPerfEntry);
11
- });
12
- }
13
- };
14
-
15
- export default reportWebVitals;
@@ -1,8 +0,0 @@
1
- import { PageSchema } from "./schema";
2
- import { event } from "../pages/event";
3
- import { page } from "../pages/page";
4
-
5
- export const pages: PageSchema[] = [
6
- event, // example schema
7
- page,
8
- ];
@@ -1,63 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface TableField {
4
- name: string;
5
- access: (obj: any) => string | number | React.ReactElement;
6
- }
7
-
8
- export interface SimpleField {
9
- name: string;
10
- label: string;
11
- type: "string" | "number" | "file";
12
- validationSchema: any;
13
- }
14
-
15
- export interface Option {
16
- value: string | number | boolean;
17
- display: string;
18
- }
19
-
20
- export interface DropdownField {
21
- name: string;
22
- label: string;
23
- type: "dropdown";
24
- options?: Option[] | undefined;
25
- getOptions: () => Promise<Option[]>;
26
- }
27
-
28
- export interface ObjectField {
29
- name: string;
30
- label: string;
31
- type: "object";
32
- fields: FormField[];
33
- }
34
-
35
- export interface ArrayField {
36
- name: string;
37
- label: string;
38
- type: "array";
39
- element: Exclude<FormField, ArrayField>;
40
- }
41
-
42
- export type FormField = SimpleField | DropdownField | ObjectField | ArrayField;
43
-
44
- export interface Action {
45
- name: string;
46
- fields?: FormField[];
47
- onSubmit: (obj1: any, obj2?: any) => Promise<any>;
48
- }
49
-
50
- export interface RowAction {
51
- name: string;
52
- fields?: FormField[];
53
- initialise?: (obj: any) => any;
54
- onSubmit: (obj1: any, obj2?: any) => Promise<any>;
55
- }
56
-
57
- export interface PageSchema {
58
- name: string;
59
- actions: Action[];
60
- rowActions: RowAction[];
61
- getRequest: () => Promise<any[]>;
62
- tableFields: TableField[];
63
- }
package/src/setupTests.ts DELETED
@@ -1,5 +0,0 @@
1
- // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
- // allows you to do things like:
3
- // expect(element).toHaveTextContent(/react/i)
4
- // learn more: https://github.com/testing-library/jest-dom
5
- import "@testing-library/jest-dom";
@@ -1,17 +0,0 @@
1
- import io from "socket.io-client";
2
- import { useEffect } from "react";
3
-
4
- const Socket = (setSocket: any, apiURL: string) => {
5
- useEffect(() => {
6
- const socketRef = io(apiURL, {
7
- transports: ["websocket"],
8
- });
9
- setSocket(socketRef);
10
- return () => {
11
- socketRef.removeAllListeners();
12
- socketRef.disconnect();
13
- };
14
- }, []);
15
- };
16
-
17
- export const newSocket = (setSocket: any, apiURL: string) => Socket(setSocket, apiURL);
package/tsconfig.esm.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "esnext",
5
- "outDir": "./dist/esm"
6
- }
7
- }
package/webpack.config.js DELETED
@@ -1,22 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = {
4
- mode: 'production',
5
- entry: './src/App.tsx',
6
- output: {
7
- filename: 'bundle.js',
8
- path: path.resolve(__dirname, 'dist'),
9
- },
10
- resolve: {
11
- extensions: ['.tsx', '.ts', '.js'],
12
- },
13
- module: {
14
- rules: [
15
- {
16
- test: /\.(ts|tsx)$/,
17
- exclude: /node_modules/,
18
- use: 'ts-loader',
19
- },
20
- ],
21
- },
22
- };
File without changes