aq-fe-framework 0.1.29 → 0.1.32

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,67 @@
1
+ // src/utils/date.ts
2
+ function U0DateToDDMMYYYString(date) {
3
+ const day = String(date.getDate()).padStart(2, "0");
4
+ const month = String(date.getMonth() + 1).padStart(2, "0");
5
+ const year = date.getFullYear();
6
+ return `${day}/${month}/${year}`;
7
+ }
8
+ function utils_date_dateToDDMMYYYString(date) {
9
+ const day = String(date.getDate()).padStart(2, "0");
10
+ const month = String(date.getMonth() + 1).padStart(2, "0");
11
+ const year = date.getFullYear();
12
+ return `${day}/${month}/${year}`;
13
+ }
14
+
15
+ // src/utils/file.ts
16
+ import Docxtemplater from "docxtemplater";
17
+ import { saveAs } from "file-saver";
18
+ import PizZip from "pizzip";
19
+ function utils_file_fileToAQDocumentType(file) {
20
+ return new Promise((resolve, reject) => {
21
+ const fileReader = new FileReader();
22
+ fileReader.onloadend = () => {
23
+ const fileName = file.name;
24
+ const fileExtension = file.name.split(".").pop();
25
+ const fileBase64String = fileReader.result;
26
+ resolve({
27
+ fileName,
28
+ fileExtension,
29
+ fileBase64String: fileBase64String.split(",")[1]
30
+ // Chỉ lấy phần base64 sau dấu phẩy
31
+ });
32
+ };
33
+ fileReader.onerror = reject;
34
+ fileReader.readAsDataURL(file);
35
+ });
36
+ }
37
+ async function utils_file_docxtemplaterDownload({
38
+ data,
39
+ filePath,
40
+ fileName
41
+ }) {
42
+ const response = await fetch(filePath);
43
+ const arrayBuffer = await response.arrayBuffer();
44
+ const zip = new PizZip(arrayBuffer);
45
+ const doc = new Docxtemplater(zip);
46
+ doc.render(data);
47
+ const buffer = doc.getZip().generate({ type: "blob" });
48
+ saveAs(buffer, fileName || "output.docx");
49
+ }
50
+
51
+ // src/utils/validateForm.ts
52
+ import { isNotEmpty } from "@mantine/form";
53
+ function U0MyValidateEmpty(message) {
54
+ return isNotEmpty(message ? message : "Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng");
55
+ }
56
+ function U0MyValidateEmail(value) {
57
+ return /^\S+@\S+$/.test(value) ? null : "Email kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng";
58
+ }
59
+
60
+ export {
61
+ U0DateToDDMMYYYString,
62
+ utils_date_dateToDDMMYYYString,
63
+ utils_file_fileToAQDocumentType,
64
+ utils_file_docxtemplaterDownload,
65
+ U0MyValidateEmpty,
66
+ U0MyValidateEmail
67
+ };