aq-fe-framework 0.1.18 → 0.1.20
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/dist/index.d.mts +62 -4
- package/dist/index.mjs +56 -54
- package/package.json +1 -1
- package/dist/utils/index.d.mts +0 -57
- package/dist/utils/index.mjs +0 -252
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
|
|
1
|
+
import ExcelJS from 'exceljs';
|
|
2
|
+
import { DefaultMantineColor } from '@mantine/core';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
|
|
5
|
+
declare const utils_converter_enumToOptions: (enumObj: object) => {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
9
|
+
declare const utils_converter_getLabelByValue: (data: Record<number, string>, value?: number | string) => string;
|
|
10
|
+
declare const utils_converter_getKeyByValue: <K extends string | number, V>(obj: Record<K, V>, value: V) => K | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Chuyển đổi enum thành mảng các đối tượng {value, label}
|
|
13
|
+
* @param enumObject - Đối tượng enum cần chuyển đổi
|
|
14
|
+
* @returns Mảng các đối tượng có dạng {value: string, label: string}
|
|
15
|
+
*/
|
|
16
|
+
declare function utils_converter_enumToSelectOptions<T extends Record<string, string | number>>(enumObject: T): Array<{
|
|
17
|
+
value: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}>;
|
|
20
|
+
|
|
21
|
+
declare function U0DateToDDMMYYYString(date: Date): string;
|
|
22
|
+
declare function utils_date_dateToDDMMYYYString(date: Date): string;
|
|
23
|
+
|
|
24
|
+
interface IUtils_Excel_ColumnConfig<T> {
|
|
25
|
+
fieldKey: keyof T;
|
|
26
|
+
fieldName: string;
|
|
27
|
+
isRequired?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare function utils_excel_exportExcel<T extends Record<string, any>>({ workbook, sheetName, data, config, }: {
|
|
30
|
+
workbook: ExcelJS.Workbook;
|
|
31
|
+
sheetName: string;
|
|
32
|
+
data: T[];
|
|
33
|
+
config: IUtils_Excel_ColumnConfig<T>[];
|
|
34
|
+
}): Promise<ExcelJS.Workbook>;
|
|
35
|
+
declare function utils_excel_download({ workbook, name }: {
|
|
36
|
+
workbook: ExcelJS.Workbook;
|
|
37
|
+
name: string;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
|
|
40
|
+
declare function utils_file_fileToAQDocumentType(file: File): Promise<any>;
|
|
41
|
+
declare function utils_file_docxtemplaterDownload({ data, filePath, fileName }: {
|
|
42
|
+
data: any;
|
|
43
|
+
filePath: string;
|
|
44
|
+
fileName?: string;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
|
|
47
|
+
interface I {
|
|
48
|
+
crudType?: "delete" | "update" | "create" | "error" | "importSucess";
|
|
49
|
+
message?: string;
|
|
50
|
+
color?: DefaultMantineColor | undefined;
|
|
51
|
+
}
|
|
52
|
+
declare function utils_notification_show({ crudType, message, color }: I): void;
|
|
53
|
+
|
|
54
|
+
declare function utils_pdf_download(url: string): Promise<void>;
|
|
55
|
+
|
|
56
|
+
declare const utils_time_convertTimeStringToSeconds: (time: string) => number;
|
|
57
|
+
declare const utils_time_getCurrentTimeString: () => string;
|
|
58
|
+
|
|
59
|
+
declare function U0MyValidateEmpty(message?: string): (value: unknown) => string | number | bigint | true | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | null;
|
|
60
|
+
declare function U0MyValidateEmail(value?: string): "Email không đúng định dạng" | null;
|
|
61
|
+
|
|
62
|
+
export { type IUtils_Excel_ColumnConfig, U0DateToDDMMYYYString, U0MyValidateEmail, U0MyValidateEmpty, utils_converter_enumToOptions, utils_converter_enumToSelectOptions, utils_converter_getKeyByValue, utils_converter_getLabelByValue, utils_date_dateToDDMMYYYString, utils_excel_download, utils_excel_exportExcel, utils_file_docxtemplaterDownload, utils_file_fileToAQDocumentType, utils_notification_show, utils_pdf_download, utils_time_convertTimeStringToSeconds, utils_time_getCurrentTimeString };
|
package/dist/index.mjs
CHANGED
|
@@ -1,57 +1,3 @@
|
|
|
1
|
-
// src/components/Layouts/FlexColumn/MyFlexColumn.tsx
|
|
2
|
-
import { Flex } from "@mantine/core";
|
|
3
|
-
|
|
4
|
-
// src/utils/notification.ts
|
|
5
|
-
import { notifications } from "@mantine/notifications";
|
|
6
|
-
function utils_notification_show({ crudType = "create", message, color }) {
|
|
7
|
-
if (crudType == "create") {
|
|
8
|
-
notifications.show({
|
|
9
|
-
message: message ? message : "Th\xEAm th\xE0nh c\xF4ng!",
|
|
10
|
-
color: color ? color : "green"
|
|
11
|
-
});
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (crudType == "update") {
|
|
15
|
-
notifications.show({
|
|
16
|
-
message: message ? message : "C\u1EADp nh\u1EADt th\xE0nh c\xF4ng!",
|
|
17
|
-
color: color ? color : "green"
|
|
18
|
-
});
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (crudType == "delete") {
|
|
22
|
-
notifications.show({
|
|
23
|
-
message: message ? message : "X\xF3a th\xE0nh c\xF4ng!",
|
|
24
|
-
color: color ? color : "green"
|
|
25
|
-
});
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (crudType == "error") {
|
|
29
|
-
notifications.show({
|
|
30
|
-
message: message ? message : "L\u1ED7i!",
|
|
31
|
-
color: color ? color : "red"
|
|
32
|
-
});
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (crudType == "importSucess") {
|
|
36
|
-
notifications.show({
|
|
37
|
-
message: message ? message : "Import th\xE0nh c\xF4ng!"
|
|
38
|
-
});
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// src/components/Buttons/ButtonCRUD/MyButtonCreate.tsx
|
|
44
|
-
import { useDisclosure } from "@mantine/hooks";
|
|
45
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
46
|
-
|
|
47
|
-
// src/components/Buttons/Button/MyButton.tsx
|
|
48
|
-
import { Button } from "@mantine/core";
|
|
49
|
-
import { IconDeviceFloppy, IconEdit, IconFileExport, IconFileImport, IconPlus, IconPrinter, IconTrash, IconX } from "@tabler/icons-react";
|
|
50
|
-
|
|
51
|
-
// src/components/Buttons/ButtonModal/MyButtonModal.tsx
|
|
52
|
-
import { Button as Button2, Modal } from "@mantine/core";
|
|
53
|
-
import { IconEdit as IconEdit2, IconPlus as IconPlus2, IconTrash as IconTrash2 } from "@tabler/icons-react";
|
|
54
|
-
|
|
55
1
|
// src/utils/converter.ts
|
|
56
2
|
var utils_converter_enumToOptions = (enumObj) => {
|
|
57
3
|
return Object.entries(enumObj).filter(([key]) => isNaN(Number(key))).map(([label, value]) => ({ value: String(value), label }));
|
|
@@ -186,6 +132,9 @@ async function utils_excel_download({
|
|
|
186
132
|
}
|
|
187
133
|
|
|
188
134
|
// src/utils/file.ts
|
|
135
|
+
import Docxtemplater from "docxtemplater";
|
|
136
|
+
import { saveAs as saveAs2 } from "file-saver";
|
|
137
|
+
import PizZip from "pizzip";
|
|
189
138
|
function utils_file_fileToAQDocumentType(file) {
|
|
190
139
|
return new Promise((resolve, reject) => {
|
|
191
140
|
const fileReader = new FileReader();
|
|
@@ -204,6 +153,58 @@ function utils_file_fileToAQDocumentType(file) {
|
|
|
204
153
|
fileReader.readAsDataURL(file);
|
|
205
154
|
});
|
|
206
155
|
}
|
|
156
|
+
async function utils_file_docxtemplaterDownload({
|
|
157
|
+
data,
|
|
158
|
+
filePath,
|
|
159
|
+
fileName
|
|
160
|
+
}) {
|
|
161
|
+
const response = await fetch(filePath);
|
|
162
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
163
|
+
const zip = new PizZip(arrayBuffer);
|
|
164
|
+
const doc = new Docxtemplater(zip);
|
|
165
|
+
doc.render(data);
|
|
166
|
+
const buffer = doc.getZip().generate({ type: "base64" });
|
|
167
|
+
saveAs2(buffer, fileName || "output.docx");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// src/utils/notification.ts
|
|
171
|
+
import { notifications } from "@mantine/notifications";
|
|
172
|
+
function utils_notification_show({ crudType = "create", message, color }) {
|
|
173
|
+
if (crudType == "create") {
|
|
174
|
+
notifications.show({
|
|
175
|
+
message: message ? message : "Th\xEAm th\xE0nh c\xF4ng!",
|
|
176
|
+
color: color ? color : "green"
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (crudType == "update") {
|
|
181
|
+
notifications.show({
|
|
182
|
+
message: message ? message : "C\u1EADp nh\u1EADt th\xE0nh c\xF4ng!",
|
|
183
|
+
color: color ? color : "green"
|
|
184
|
+
});
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (crudType == "delete") {
|
|
188
|
+
notifications.show({
|
|
189
|
+
message: message ? message : "X\xF3a th\xE0nh c\xF4ng!",
|
|
190
|
+
color: color ? color : "green"
|
|
191
|
+
});
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (crudType == "error") {
|
|
195
|
+
notifications.show({
|
|
196
|
+
message: message ? message : "L\u1ED7i!",
|
|
197
|
+
color: color ? color : "red"
|
|
198
|
+
});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (crudType == "importSucess") {
|
|
202
|
+
notifications.show({
|
|
203
|
+
message: message ? message : "Import th\xE0nh c\xF4ng!"
|
|
204
|
+
});
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
207
208
|
|
|
208
209
|
// src/utils/pdf.ts
|
|
209
210
|
import axios from "axios";
|
|
@@ -259,6 +260,7 @@ export {
|
|
|
259
260
|
utils_date_dateToDDMMYYYString,
|
|
260
261
|
utils_excel_download,
|
|
261
262
|
utils_excel_exportExcel,
|
|
263
|
+
utils_file_docxtemplaterDownload,
|
|
262
264
|
utils_file_fileToAQDocumentType,
|
|
263
265
|
utils_notification_show,
|
|
264
266
|
utils_pdf_download,
|
package/package.json
CHANGED
package/dist/utils/index.d.mts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import ExcelJS from 'exceljs';
|
|
2
|
-
import { DefaultMantineColor } from '@mantine/core';
|
|
3
|
-
import * as react from 'react';
|
|
4
|
-
|
|
5
|
-
declare const utils_converter_enumToOptions: (enumObj: object) => {
|
|
6
|
-
value: string;
|
|
7
|
-
label: string;
|
|
8
|
-
}[];
|
|
9
|
-
declare const utils_converter_getLabelByValue: (data: Record<number, string>, value?: number | string) => string;
|
|
10
|
-
declare const utils_converter_getKeyByValue: <K extends string | number, V>(obj: Record<K, V>, value: V) => K | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Chuyển đổi enum thành mảng các đối tượng {value, label}
|
|
13
|
-
* @param enumObject - Đối tượng enum cần chuyển đổi
|
|
14
|
-
* @returns Mảng các đối tượng có dạng {value: string, label: string}
|
|
15
|
-
*/
|
|
16
|
-
declare function utils_converter_enumToSelectOptions<T extends Record<string, string | number>>(enumObject: T): Array<{
|
|
17
|
-
value: string;
|
|
18
|
-
label: string;
|
|
19
|
-
}>;
|
|
20
|
-
|
|
21
|
-
declare function U0DateToDDMMYYYString(date: Date): string;
|
|
22
|
-
declare function utils_date_dateToDDMMYYYString(date: Date): string;
|
|
23
|
-
|
|
24
|
-
interface IUtils_Excel_ColumnConfig<T> {
|
|
25
|
-
fieldKey: keyof T;
|
|
26
|
-
fieldName: string;
|
|
27
|
-
isRequired?: boolean;
|
|
28
|
-
}
|
|
29
|
-
declare function utils_excel_exportExcel<T extends Record<string, any>>({ workbook, sheetName, data, config, }: {
|
|
30
|
-
workbook: ExcelJS.Workbook;
|
|
31
|
-
sheetName: string;
|
|
32
|
-
data: T[];
|
|
33
|
-
config: IUtils_Excel_ColumnConfig<T>[];
|
|
34
|
-
}): Promise<ExcelJS.Workbook>;
|
|
35
|
-
declare function utils_excel_download({ workbook, name }: {
|
|
36
|
-
workbook: ExcelJS.Workbook;
|
|
37
|
-
name: string;
|
|
38
|
-
}): Promise<void>;
|
|
39
|
-
|
|
40
|
-
declare function utils_file_fileToAQDocumentType(file: File): Promise<any>;
|
|
41
|
-
|
|
42
|
-
interface I {
|
|
43
|
-
crudType?: "delete" | "update" | "create" | "error" | "importSucess";
|
|
44
|
-
message?: string;
|
|
45
|
-
color?: DefaultMantineColor | undefined;
|
|
46
|
-
}
|
|
47
|
-
declare function utils_notification_show({ crudType, message, color }: I): void;
|
|
48
|
-
|
|
49
|
-
declare function utils_pdf_download(url: string): Promise<void>;
|
|
50
|
-
|
|
51
|
-
declare const utils_time_convertTimeStringToSeconds: (time: string) => number;
|
|
52
|
-
declare const utils_time_getCurrentTimeString: () => string;
|
|
53
|
-
|
|
54
|
-
declare function U0MyValidateEmpty(message?: string): (value: unknown) => string | number | bigint | true | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | null;
|
|
55
|
-
declare function U0MyValidateEmail(value?: string): "Email không đúng định dạng" | null;
|
|
56
|
-
|
|
57
|
-
export { type IUtils_Excel_ColumnConfig, U0DateToDDMMYYYString, U0MyValidateEmail, U0MyValidateEmpty, utils_converter_enumToOptions, utils_converter_enumToSelectOptions, utils_converter_getKeyByValue, utils_converter_getLabelByValue, utils_date_dateToDDMMYYYString, utils_excel_download, utils_excel_exportExcel, utils_file_fileToAQDocumentType, utils_notification_show, utils_pdf_download, utils_time_convertTimeStringToSeconds, utils_time_getCurrentTimeString };
|
package/dist/utils/index.mjs
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
// src/utils/converter.ts
|
|
2
|
-
var utils_converter_enumToOptions = (enumObj) => {
|
|
3
|
-
return Object.entries(enumObj).filter(([key]) => isNaN(Number(key))).map(([label, value]) => ({ value: String(value), label }));
|
|
4
|
-
};
|
|
5
|
-
var utils_converter_getLabelByValue = (data, value) => {
|
|
6
|
-
const numericValue = Number(value);
|
|
7
|
-
return data[numericValue] || "Kh\xF4ng x\xE1c \u0111\u1ECBnh";
|
|
8
|
-
};
|
|
9
|
-
var utils_converter_getKeyByValue = (obj, value) => {
|
|
10
|
-
var _a;
|
|
11
|
-
return (_a = Object.entries(obj).find(([_, v]) => v === value)) == null ? void 0 : _a[0];
|
|
12
|
-
};
|
|
13
|
-
function utils_converter_enumToSelectOptions(enumObject) {
|
|
14
|
-
const result = [];
|
|
15
|
-
const numericEnumKeys = Object.keys(enumObject).filter((key) => isNaN(Number(key)));
|
|
16
|
-
for (const key of numericEnumKeys) {
|
|
17
|
-
const enumValue = enumObject[key];
|
|
18
|
-
if (typeof enumValue === "number") {
|
|
19
|
-
result.push({
|
|
20
|
-
value: String(enumValue),
|
|
21
|
-
label: key
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/utils/date.ts
|
|
29
|
-
function U0DateToDDMMYYYString(date) {
|
|
30
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
31
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
32
|
-
const year = date.getFullYear();
|
|
33
|
-
return `${day}/${month}/${year}`;
|
|
34
|
-
}
|
|
35
|
-
function utils_date_dateToDDMMYYYString(date) {
|
|
36
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
37
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
38
|
-
const year = date.getFullYear();
|
|
39
|
-
return `${day}/${month}/${year}`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/utils/excel.ts
|
|
43
|
-
import saveAs from "file-saver";
|
|
44
|
-
async function utils_excel_exportExcel({
|
|
45
|
-
workbook,
|
|
46
|
-
sheetName,
|
|
47
|
-
data,
|
|
48
|
-
config
|
|
49
|
-
}) {
|
|
50
|
-
const sheet = workbook.addWorksheet(sheetName);
|
|
51
|
-
const fieldNames = config.map((item) => String(item.fieldKey));
|
|
52
|
-
const headerMappings = {};
|
|
53
|
-
const markedColumns = [];
|
|
54
|
-
config.forEach((item) => {
|
|
55
|
-
const fieldKeyStr = String(item.fieldKey);
|
|
56
|
-
headerMappings[fieldKeyStr] = item.fieldName;
|
|
57
|
-
if (item.isRequired) {
|
|
58
|
-
markedColumns.push(fieldKeyStr);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
const columns = fieldNames.map((fieldName) => {
|
|
62
|
-
return {
|
|
63
|
-
key: fieldName,
|
|
64
|
-
width: 20
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
sheet.columns = columns;
|
|
68
|
-
const displayRow = sheet.addRow(
|
|
69
|
-
fieldNames.map((fieldName) => {
|
|
70
|
-
const displayName = headerMappings[fieldName] || fieldName;
|
|
71
|
-
return markedColumns.includes(fieldName) ? `${displayName} *` : displayName;
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
const keyRow = sheet.addRow(fieldNames);
|
|
75
|
-
data.forEach((item) => {
|
|
76
|
-
const rowData = {};
|
|
77
|
-
fieldNames.forEach((field) => {
|
|
78
|
-
rowData[field] = item[field];
|
|
79
|
-
});
|
|
80
|
-
sheet.addRow(rowData);
|
|
81
|
-
});
|
|
82
|
-
for (let i = 1; i <= fieldNames.length; i++) {
|
|
83
|
-
const cell = displayRow.getCell(i);
|
|
84
|
-
cell.font = { bold: true };
|
|
85
|
-
cell.fill = {
|
|
86
|
-
type: "pattern",
|
|
87
|
-
pattern: "solid",
|
|
88
|
-
fgColor: { argb: "FFE0E0E0" }
|
|
89
|
-
// Light gray background
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
for (let i = 1; i <= fieldNames.length; i++) {
|
|
93
|
-
const cell = keyRow.getCell(i);
|
|
94
|
-
cell.font = { italic: true };
|
|
95
|
-
cell.fill = {
|
|
96
|
-
type: "pattern",
|
|
97
|
-
pattern: "solid",
|
|
98
|
-
fgColor: { argb: "FFF0F0F0" }
|
|
99
|
-
// Lighter gray background
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
if (markedColumns.length > 0) {
|
|
103
|
-
for (let i = 1; i <= fieldNames.length; i++) {
|
|
104
|
-
const cell = displayRow.getCell(i);
|
|
105
|
-
const text = cell.value;
|
|
106
|
-
if (typeof text === "string" && text.endsWith(" *")) {
|
|
107
|
-
cell.value = {
|
|
108
|
-
richText: [
|
|
109
|
-
{
|
|
110
|
-
text: text.substring(0, text.length - 2),
|
|
111
|
-
font: { bold: true }
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
text: " *",
|
|
115
|
-
font: { bold: true, color: { argb: "FFFF0000" } }
|
|
116
|
-
// Red color
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return workbook;
|
|
124
|
-
}
|
|
125
|
-
async function utils_excel_download({
|
|
126
|
-
workbook,
|
|
127
|
-
name
|
|
128
|
-
}) {
|
|
129
|
-
const buffer = await workbook.xlsx.writeBuffer();
|
|
130
|
-
const blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
|
|
131
|
-
saveAs(blob, name);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// src/utils/file.ts
|
|
135
|
-
function utils_file_fileToAQDocumentType(file) {
|
|
136
|
-
return new Promise((resolve, reject) => {
|
|
137
|
-
const fileReader = new FileReader();
|
|
138
|
-
fileReader.onloadend = () => {
|
|
139
|
-
const fileName = file.name;
|
|
140
|
-
const fileExtension = file.name.split(".").pop();
|
|
141
|
-
const fileBase64String = fileReader.result;
|
|
142
|
-
resolve({
|
|
143
|
-
fileName,
|
|
144
|
-
fileExtension,
|
|
145
|
-
fileBase64String: fileBase64String.split(",")[1]
|
|
146
|
-
// Chỉ lấy phần base64 sau dấu phẩy
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
fileReader.onerror = reject;
|
|
150
|
-
fileReader.readAsDataURL(file);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// src/utils/notification.ts
|
|
155
|
-
import { notifications } from "@mantine/notifications";
|
|
156
|
-
function utils_notification_show({ crudType = "create", message, color }) {
|
|
157
|
-
if (crudType == "create") {
|
|
158
|
-
notifications.show({
|
|
159
|
-
message: message ? message : "Th\xEAm th\xE0nh c\xF4ng!",
|
|
160
|
-
color: color ? color : "green"
|
|
161
|
-
});
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (crudType == "update") {
|
|
165
|
-
notifications.show({
|
|
166
|
-
message: message ? message : "C\u1EADp nh\u1EADt th\xE0nh c\xF4ng!",
|
|
167
|
-
color: color ? color : "green"
|
|
168
|
-
});
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
if (crudType == "delete") {
|
|
172
|
-
notifications.show({
|
|
173
|
-
message: message ? message : "X\xF3a th\xE0nh c\xF4ng!",
|
|
174
|
-
color: color ? color : "green"
|
|
175
|
-
});
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (crudType == "error") {
|
|
179
|
-
notifications.show({
|
|
180
|
-
message: message ? message : "L\u1ED7i!",
|
|
181
|
-
color: color ? color : "red"
|
|
182
|
-
});
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (crudType == "importSucess") {
|
|
186
|
-
notifications.show({
|
|
187
|
-
message: message ? message : "Import th\xE0nh c\xF4ng!"
|
|
188
|
-
});
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// src/utils/pdf.ts
|
|
194
|
-
import axios from "axios";
|
|
195
|
-
async function utils_pdf_download(url) {
|
|
196
|
-
try {
|
|
197
|
-
const response = await axios.get(url, {
|
|
198
|
-
responseType: "blob"
|
|
199
|
-
// Đảm bảo nhận dữ liệu dạng blob để tải file
|
|
200
|
-
});
|
|
201
|
-
const blob = new Blob([response.data], { type: "application/pdf" });
|
|
202
|
-
const link = document.createElement("a");
|
|
203
|
-
link.href = window.URL.createObjectURL(blob);
|
|
204
|
-
link.download = "file.pdf";
|
|
205
|
-
link.click();
|
|
206
|
-
window.URL.revokeObjectURL(link.href);
|
|
207
|
-
} catch (error) {
|
|
208
|
-
console.error("Error downloading PDF:", error);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// src/utils/time.ts
|
|
213
|
-
var utils_time_convertTimeStringToSeconds = (time) => {
|
|
214
|
-
const [hours, minutes, seconds] = time.split(":").map(Number);
|
|
215
|
-
return hours * 3600 + minutes * 60 + seconds;
|
|
216
|
-
};
|
|
217
|
-
var utils_time_getCurrentTimeString = () => {
|
|
218
|
-
const formatTime = (number) => {
|
|
219
|
-
return number < 10 ? "0" + number : number;
|
|
220
|
-
};
|
|
221
|
-
const now = /* @__PURE__ */ new Date();
|
|
222
|
-
const hours = formatTime(now.getHours());
|
|
223
|
-
const minutes = formatTime(now.getMinutes());
|
|
224
|
-
const seconds = formatTime(now.getSeconds());
|
|
225
|
-
return `${hours}:${minutes}:${seconds}`;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// src/utils/validateForm.ts
|
|
229
|
-
import { isNotEmpty } from "@mantine/form";
|
|
230
|
-
function U0MyValidateEmpty(message) {
|
|
231
|
-
return isNotEmpty(message ? message : "Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng");
|
|
232
|
-
}
|
|
233
|
-
function U0MyValidateEmail(value) {
|
|
234
|
-
return /^\S+@\S+$/.test(value) ? null : "Email kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng";
|
|
235
|
-
}
|
|
236
|
-
export {
|
|
237
|
-
U0DateToDDMMYYYString,
|
|
238
|
-
U0MyValidateEmail,
|
|
239
|
-
U0MyValidateEmpty,
|
|
240
|
-
utils_converter_enumToOptions,
|
|
241
|
-
utils_converter_enumToSelectOptions,
|
|
242
|
-
utils_converter_getKeyByValue,
|
|
243
|
-
utils_converter_getLabelByValue,
|
|
244
|
-
utils_date_dateToDDMMYYYString,
|
|
245
|
-
utils_excel_download,
|
|
246
|
-
utils_excel_exportExcel,
|
|
247
|
-
utils_file_fileToAQDocumentType,
|
|
248
|
-
utils_notification_show,
|
|
249
|
-
utils_pdf_download,
|
|
250
|
-
utils_time_convertTimeStringToSeconds,
|
|
251
|
-
utils_time_getCurrentTimeString
|
|
252
|
-
};
|