authscape 1.0.121 → 1.0.122

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.
@@ -0,0 +1,121 @@
1
+ import React, { Component } from 'react';
2
+ //import {apiService} from 'authscape';
3
+ import DataTable, {createTheme} from "react-data-table-component";
4
+
5
+ export class Datatable extends Component {
6
+
7
+ static defaultProps = {
8
+ options: {}
9
+ }
10
+
11
+ constructor(props) {
12
+ super(props);
13
+
14
+ this.state = {
15
+ pageNumber : 1,
16
+ pageLength : props.pageLength ? props.pageLength : 10,
17
+ data: [],
18
+ loading: false,
19
+ totalRows: 0
20
+ };
21
+ }
22
+
23
+ componentDidMount = async () => {
24
+ await this.GetDataFromUrl(this.state.pageNumber, this.state.pageLength, this.props.params);
25
+ createTheme('dataTable', {
26
+ text:{
27
+
28
+ }
29
+ })
30
+ }
31
+
32
+ reload = async (reset = false) => {
33
+
34
+ if (reset === true)
35
+ {
36
+ this.setState({pageNumber: 1}, async () => {
37
+ await this.GetDataFromUrl(this.state.pageNumber, this.state.pageLength, this.props.params);
38
+ })
39
+ }
40
+ else
41
+ {
42
+ await this.GetDataFromUrl(this.state.pageNumber, this.state.pageLength, this.props.params);
43
+ }
44
+
45
+
46
+ }
47
+
48
+ GetDataFromUrl = (page, length, postData = {}) => {
49
+
50
+ this.setState({
51
+ loading: true
52
+ }, async function () {
53
+
54
+ let data = postData;
55
+
56
+ data.offset = page;
57
+ data.length = length;
58
+
59
+ let response = null;
60
+ if (this.props.methodType == "get")
61
+ {
62
+ response = await apiService().get(this.props.url);
63
+ }
64
+ else
65
+ {
66
+ response = await apiService().post(this.props.url, postData);
67
+ }
68
+
69
+ if (response != null && response.status === 200)
70
+ {
71
+ if (this.props.returnResult != null)
72
+ {
73
+ this.props.returnResult(response.data.data);
74
+ }
75
+
76
+ this.setState({
77
+ totalRows: response.data.recordsTotal,
78
+ data: response.data.data,
79
+ loading: false
80
+ });
81
+ }
82
+ else
83
+ {
84
+ //console.error(response.status + " - " + response.data);
85
+ }
86
+
87
+ });
88
+
89
+ }
90
+
91
+ handlePageChange = async page => {
92
+ const { pageLength } = this.state;
93
+ this.setState({pageNumber: page});
94
+ await this.GetDataFromUrl(page, pageLength, this.props.params);
95
+ };
96
+
97
+ render() {
98
+
99
+ return (
100
+ <div>
101
+ <DataTable
102
+ title={this.props.title}
103
+ columns={this.props.columns}
104
+ data={this.state.data}
105
+ paginationRowsPerPageOptions={this.props.pageLength ? [this.props.pageLength] : [10]}
106
+ progressPending={this.state.loading}
107
+ //customStyles={this.props.customStyles}
108
+ paginationPerPage={this.props.pageLength ? this.props.pageLength : 10}
109
+ paginationServer
110
+ pagination
111
+ {...this.props.options}
112
+ //expandableRows={this.props.expandableRows}
113
+ //expandableRowsComponent={this.props.expandableRowsComponent}
114
+ paginationTotalRows={this.state.totalRows}
115
+ // onChangeRowsPerPage={this.handlePerRowsChange}
116
+ onChangePage={this.handlePageChange}
117
+ noDataComponent={this.props.noDataComponent}
118
+ />
119
+ </div>);
120
+ }
121
+ }
@@ -0,0 +1,346 @@
1
+ import React, { useState, useRef, useEffect } from "react";
2
+ import { apiService } from "../services/authService";
3
+ import LinearProgress from "@mui/material/LinearProgress";
4
+ import { Box } from "@mui/system";
5
+ import { Grid } from "@mui/material";
6
+ import FileCopyRoundedIcon from "@mui/icons-material/FileCopyRounded";
7
+ import UploadRoundedIcon from "@mui/icons-material/UploadRounded";
8
+ import Typography from "@mui/material/Typography";
9
+ import Stack from "@mui/material/Stack";
10
+ import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
11
+ import IconButton from "@mui/material/IconButton";
12
+ import DeleteIcon from "@mui/icons-material/Delete";
13
+ import Button from "@mui/material/Button";
14
+ import Dialog from "@mui/material/Dialog";
15
+ import DialogActions from "@mui/material/DialogActions";
16
+ import DialogContent from "@mui/material/DialogContent";
17
+ import DialogContentText from "@mui/material/DialogContentText";
18
+ import DialogTitle from "@mui/material/DialogTitle";
19
+ import Tooltip from '@mui/material/Tooltip';
20
+ import Backdrop from '@mui/material/Backdrop';
21
+ import CircularProgress from '@mui/material/CircularProgress';
22
+
23
+ export default function FileUploader({
24
+ url,
25
+ params,
26
+ multiple = false,
27
+ fileLoaderUri = null,
28
+ children,
29
+ isHidden = false,
30
+ refOveride = null,
31
+ primaryColor = "#000",
32
+ deleteUri = "/Storage/RemoveFile?orderFileId="
33
+ }) {
34
+ // Declare a new state variable, which we'll call "count"
35
+ const [message, setMessage] = useState("");
36
+ const [loaded, setLoaded] = useState(0);
37
+ // const [selectedFile, setSelectedFile] = useState(null);
38
+ const [uploading, setUploading] = useState(false);
39
+
40
+ const [viewDeleteDialog, setViewDeleteDialog] = useState(false);
41
+
42
+ const [filesUploaded, setFilesUploaded] = useState([]);
43
+
44
+ const [orderFileId, setOrderFileId] = useState(null);
45
+
46
+ const [filesDownloadable, setFilesDownloadable] = useState(null);
47
+
48
+ const [parameters, setParameters] = useState([]);
49
+
50
+ const fileUploader = useRef();
51
+
52
+ const handleUpload = async (event) => {
53
+ let selectedFiles = event.target.files;
54
+
55
+ setLoaded(0);
56
+ setMessage(event.target.files[0] ? event.target.files[0].name : "");
57
+
58
+ if (uploading) return;
59
+ if (!selectedFiles) {
60
+ setMessage("Select a file first");
61
+ return;
62
+ }
63
+
64
+ setUploading(true);
65
+
66
+ let fileCount = selectedFiles.length;
67
+ let fileIndex = 1;
68
+
69
+ for (
70
+ let selectedIndex = 0;
71
+ selectedIndex < selectedFiles.length;
72
+ selectedIndex++
73
+ ) {
74
+ const selectedFile = selectedFiles[selectedIndex];
75
+
76
+ const data = new FormData();
77
+ data.append("file", selectedFile, selectedFile.name);
78
+
79
+ for (let index = 0; index < parameters.length; index++) {
80
+ const element = parameters[index];
81
+ data.append(element.key, element.value);
82
+ }
83
+
84
+ try {
85
+ await apiService().post(url, data, {
86
+ onUploadProgress: (ProgressEvent) => {
87
+ let loadedTotal = Math.round(
88
+ (ProgressEvent.loaded / ProgressEvent.total) * 100
89
+ );
90
+ let percent = (fileIndex / fileCount) * 100;
91
+ setLoaded(percent);
92
+
93
+ if (percent == 100) {
94
+ setTimeout(() => {
95
+ setLoaded(0);
96
+ setMessage("");
97
+ reloadFiles();
98
+ }, 2000);
99
+ }
100
+ },
101
+ });
102
+ } catch (err) {
103
+ setUploading(false);
104
+ setMessage("Failed to upload");
105
+ }
106
+
107
+ fileIndex++;
108
+ }
109
+
110
+ setUploading(false);
111
+ setMessage("Uploaded successfully");
112
+ };
113
+
114
+ const handleUploadFileInput = () => {
115
+ fileUploader.current.click();
116
+ };
117
+
118
+ useEffect(() => {
119
+ if (params != null) {
120
+ const propertyNames = Object.keys(params);
121
+ const propertyValues = Object.values(params);
122
+
123
+ let array = [];
124
+
125
+ for (let index = 0; index < propertyNames.length; index++) {
126
+ array.push({
127
+ key: propertyNames[0],
128
+ value: propertyValues[0],
129
+ });
130
+ }
131
+
132
+ setParameters(array);
133
+ }
134
+ }, [params]);
135
+
136
+ const reloadFiles = async () => {
137
+ let response = await apiService().get(fileLoaderUri);
138
+ if (response != null && response.status == 200) {
139
+ setFilesDownloadable(response.data);
140
+ }
141
+ };
142
+
143
+ useEffect(() => {
144
+ if (fileLoaderUri != null) {
145
+ const fetchAsync = async () => {
146
+ await reloadFiles();
147
+ };
148
+ fetchAsync();
149
+ }
150
+ }, [fileLoaderUri]);
151
+
152
+ return (
153
+ <Box sx={{ marginTop: 1, display: isHidden ? "none" : "block" }}>
154
+
155
+ <input
156
+ className="inputfile"
157
+ id="file"
158
+ type="file"
159
+ name="file"
160
+ multiple={multiple}
161
+ ref={fileUploader}
162
+ onChange={handleUpload}
163
+ style={{ display: "none" }}
164
+ />
165
+
166
+ <Grid container spacing={2}>
167
+ <Grid ref={refOveride} item xs={4} onClick={handleUploadFileInput}>
168
+ <Grid
169
+ container
170
+ sx={{
171
+ padding: 2,
172
+ backgroundColor: "#ECEDED",
173
+ fontSize: "14px",
174
+ cursor: "pointer",
175
+ borderRadius: "8px",
176
+ border: "1px dashed #C8D4D5",
177
+ }}
178
+ >
179
+ <Grid item xs={2}>
180
+ <Box>
181
+ <FileCopyRoundedIcon
182
+ sx={{ fill: "#C8D4D5", width: 50, height: 50 }}
183
+ />
184
+ </Box>
185
+ </Grid>
186
+ <Grid item xs={10}>
187
+ <Box>Drag and drop files here or</Box>
188
+ <Box sx={{ marginTop: 1 }}>
189
+ <Stack direction="row" spacing={2}>
190
+ <UploadRoundedIcon
191
+ sx={{ fill: primaryColor, width: 30, height: 30 }}
192
+ />
193
+ <Typography
194
+ variant="h3"
195
+ component={"span"}
196
+ sx={{ color: primaryColor, paddingTop: 0.6 }}
197
+ >
198
+ Upload
199
+ </Typography>
200
+ </Stack>
201
+ </Box>
202
+ </Grid>
203
+ <Grid item xs={12}>
204
+ {loaded > 0 && (
205
+ <LinearProgress
206
+ variant="buffer"
207
+ value={loaded}
208
+ sx={{ marginTop: 2 }}
209
+ />
210
+ )}
211
+
212
+ {loaded == 100 && (
213
+ <Typography
214
+ variant="h3"
215
+ component={"span"}
216
+ sx={{ color: primaryColor, paddingTop: 0.6 }}>
217
+ Completed
218
+ </Typography>
219
+ )}
220
+ </Grid>
221
+ </Grid>
222
+ </Grid>
223
+
224
+ {children}
225
+
226
+ <Grid container sx={{ paddingTop: 1 }}>
227
+ {filesDownloadable != null &&
228
+ filesDownloadable.map((fileUpload, idx) => {
229
+ return (
230
+ <Grid
231
+ key={"fileDownloadable-" + idx}
232
+ item
233
+ xs={8}
234
+ sm={8}
235
+ md={5}
236
+ lg={3}
237
+ sx={{
238
+ marginLeft: 2,
239
+ padding: 1,
240
+ marginTop: 1,
241
+ backgroundColor: "#ECEDED",
242
+ position: "relative",
243
+ fontSize: "14px",
244
+ cursor: "pointer",
245
+ borderRadius: "8px",
246
+ border: "1px solid #54C7DD",
247
+ }}
248
+ onClick={async () => {
249
+ window.open(fileUpload.uri);
250
+ }}
251
+ >
252
+ <Tooltip placement="left" arrow title={fileUpload.name}>
253
+ <Stack
254
+ direction="row"
255
+ spacing={1}
256
+ display="flex"
257
+ justifyContent={"space-between"}
258
+ >
259
+ <Box display={"flex"} alignItems="center">
260
+ <FileDownloadOutlinedIcon sx={{ fill: "#92D6E3" }} />
261
+ <Box
262
+ sx={{
263
+ paddingTop: 0.6,
264
+ marginLeft: "5px",
265
+ }}
266
+ >
267
+ <Typography
268
+ sx={{
269
+ overflow: "hidden",
270
+ whiteSpace: "nowrap",
271
+ textOverflow: "ellipsis",
272
+ width:"350px"
273
+ }}
274
+ >
275
+ {fileUpload.name}
276
+ </Typography>
277
+ </Box>
278
+
279
+ <IconButton
280
+ aria-label="delete"
281
+ sx={{ position: "absolute", right: "0" }}
282
+ onClick={(evt) => {
283
+ evt.stopPropagation();
284
+ setOrderFileId(fileUpload.id);
285
+ setViewDeleteDialog(true);
286
+ }}
287
+ >
288
+ <DeleteIcon />
289
+ </IconButton>
290
+ </Box>
291
+ </Stack>
292
+ </Tooltip>
293
+ </Grid>
294
+ );
295
+ })}
296
+ </Grid>
297
+ </Grid>
298
+
299
+ <Dialog
300
+ open={viewDeleteDialog}
301
+ fullWidth={true}
302
+ maxWidth={"xs"}
303
+ onClose={() => {
304
+ setViewDeleteDialog(false);
305
+ }}
306
+ aria-labelledby="alert-dialog-title"
307
+ aria-describedby="alert-dialog-description">
308
+ <DialogTitle id="alert-dialog-title">Remove File</DialogTitle>
309
+ <DialogContent>
310
+ <DialogContentText id="alert-dialog-description">
311
+ Are you sure you want to remove this file?
312
+ </DialogContentText>
313
+ </DialogContent>
314
+ <DialogActions>
315
+ <Button
316
+ onClick={() => {
317
+ setViewDeleteDialog(false);
318
+ }}
319
+ >
320
+ No
321
+ </Button>
322
+ <Button
323
+ onClick={async () => {
324
+
325
+ let response = await apiService().delete(
326
+ deleteUri + orderFileId
327
+ );
328
+ if (response != null && response.status == 200) {
329
+ setViewDeleteDialog(false);
330
+ await reloadFiles();
331
+ }
332
+
333
+ }}
334
+ autoFocus
335
+ >
336
+ Yes
337
+ </Button>
338
+ </DialogActions>
339
+ </Dialog>
340
+
341
+ <Backdrop sx={{ color: '#fff', zIndex: 99999 }} open={uploading}>
342
+ <CircularProgress color="inherit" />
343
+ </Backdrop>
344
+ </Box>
345
+ );
346
+ }
package/jsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "paths": {
4
- "@/*": ["./*"]
4
+ "@/*": ["./src/*"]
5
5
  }
6
6
  }
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.121",
3
+ "version": "1.0.122",
4
4
  "scripts": {
5
5
  "dev": "next dev",
6
6
  "build": "next build",
@@ -8,8 +8,15 @@
8
8
  "lint": "next lint"
9
9
  },
10
10
  "dependencies": {
11
+ "@stripe/react-stripe-js": "^2.1.0",
12
+ "@stripe/stripe-js": "^1.53.0",
13
+ "axios": "^1.4.0",
14
+ "js-file-download": "^0.4.12",
11
15
  "next": "13.4.4",
16
+ "nookies": "^2.5.2",
17
+ "query-string": "^8.1.0",
12
18
  "react": "18.2.0",
19
+ "react-data-table-component": "^7.5.3",
13
20
  "react-dom": "18.2.0"
14
21
  }
15
22
  }
package/pages/Test.js DELETED
@@ -1,8 +0,0 @@
1
-
2
- export default function Test() {
3
- return (
4
- <div>
5
- This is a test
6
- </div>
7
- )
8
- }
package/public/next.svg DELETED
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-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black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>