@mixd-id/web-scaffold 0.1.2301231332 → 0.1.2301231334
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mixd-id/web-scaffold",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2301231334",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite serve",
|
|
7
7
|
"build": "vite build",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"@tailwindcss/line-clamp": "^0.4.0",
|
|
23
23
|
"@vueuse/core": "^9.0.2",
|
|
24
24
|
"adm-zip": "^0.5.10",
|
|
25
|
-
"axios": "^0.27.2",
|
|
26
25
|
"compression": "^1.7.4",
|
|
27
26
|
"cookie-parser": "^1.4.6",
|
|
28
27
|
"cors": "^2.8.5",
|
|
@@ -17,15 +17,16 @@
|
|
|
17
17
|
</div>
|
|
18
18
|
</template>
|
|
19
19
|
<template v-slot:foot>
|
|
20
|
-
<div class="p-5" v-if="step === 2">
|
|
21
|
-
<Button
|
|
20
|
+
<div class="p-5 flex flex-row gap-3" v-if="step === 2">
|
|
21
|
+
<Button class="w-[120px]" :disabled="!canImport" :state="isLoading ? 2 : 1" @click="proceedImport">Import</Button>
|
|
22
|
+
<Button variant="secondary" class="w-[80px]" @click="step = 1">Back</Button>
|
|
22
23
|
</div>
|
|
23
24
|
</template>
|
|
24
25
|
|
|
25
26
|
<div class="flex-1 p-5 flex flex-col items-center justify-center" v-if="step === 1">
|
|
26
27
|
<button type="button" @click="$refs.uploader.click()" class="rounded-3xl w-[200px] bg-base-300 px-6 aspect-square flex items-center justify-center text-center border-dashed border-[3px] border-text-100">
|
|
27
28
|
<div class="text-xl" v-if="!isLoading">
|
|
28
|
-
|
|
29
|
+
Click to <br />
|
|
29
30
|
<span class="text-primary text-lg">Upload</span>
|
|
30
31
|
file
|
|
31
32
|
</div>
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
<br />
|
|
41
42
|
<div v-if="templateFiles.length > 0" class="flex flex-col gap-2">
|
|
42
43
|
<a v-for="(file, index) in templateFiles" :href="file" class="text-primary">
|
|
43
|
-
Download
|
|
44
|
+
Download Sample {{ templateFiles.length > 1 ? index + 1 : '' }}
|
|
44
45
|
</a>
|
|
45
46
|
</div>
|
|
46
47
|
</div>
|
package/src/utils/importer.js
CHANGED
|
@@ -23,9 +23,9 @@ const analyseRequest = async(req) => {
|
|
|
23
23
|
const res = glob.sync(process.env.ROOT_PATH + '/storage/files/temp/' + folderName + '/**/*(*.xlsx|*.csv)')
|
|
24
24
|
|
|
25
25
|
if(res.length < 1)
|
|
26
|
-
throw new
|
|
26
|
+
throw new Error('Invalid file')
|
|
27
27
|
else if(res.length > 1)
|
|
28
|
-
throw new
|
|
28
|
+
throw new Error('Invalid file')
|
|
29
29
|
else{
|
|
30
30
|
xlsxFile = res[0]
|
|
31
31
|
xlsxFileType = xlsxFile.split('.').slice(-1).pop()
|
|
@@ -38,6 +38,7 @@ const analyseRequest = async(req) => {
|
|
|
38
38
|
xlsxFile = process.env.ROOT_PATH + '/storage/files/temp/' + folderName + '/' + filename
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
|
|
41
42
|
const workbook = new Exceljs.Workbook();
|
|
42
43
|
switch(xlsxFileType){
|
|
43
44
|
|
|
@@ -54,14 +55,17 @@ const analyseRequest = async(req) => {
|
|
|
54
55
|
break
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
if(workbook.worksheets.length > 1)
|
|
59
|
+
throw new Error('Number of sheet allowed within file is 1')
|
|
60
|
+
else if(workbook.worksheets.length < 1)
|
|
61
|
+
throw new Error('Unable to read worksheet')
|
|
62
|
+
|
|
63
|
+
const worksheet = workbook.worksheets[0]
|
|
60
64
|
|
|
61
65
|
const columns = []
|
|
62
66
|
const header = worksheet.getRow(1)
|
|
63
67
|
if(!header)
|
|
64
|
-
throw new
|
|
68
|
+
throw new Error('Invalid file')
|
|
65
69
|
header.eachCell((cell) => {
|
|
66
70
|
columns.push(cell.value)
|
|
67
71
|
})
|
|
@@ -80,7 +84,7 @@ const importRequest = async(req) => {
|
|
|
80
84
|
|
|
81
85
|
keys.forEach((key) => {
|
|
82
86
|
if (key.required && !key.value)
|
|
83
|
-
throw new
|
|
87
|
+
throw new Error({name: ['Kolom ' + key.text + ' harus diisi']})
|
|
84
88
|
})
|
|
85
89
|
|
|
86
90
|
const rows = []
|
|
@@ -101,7 +105,7 @@ const importRequest = async(req) => {
|
|
|
101
105
|
break
|
|
102
106
|
}
|
|
103
107
|
|
|
104
|
-
const worksheet = workbook.
|
|
108
|
+
const worksheet = workbook.worksheets[0]
|
|
105
109
|
worksheet.eachRow((row, index) => {
|
|
106
110
|
if(index === 1){
|
|
107
111
|
row.eachCell((cell, index) => {
|