diff --git a/apps/admin/package.json b/apps/admin/package.json index adbfe4c..20ff976 100644 --- a/apps/admin/package.json +++ b/apps/admin/package.json @@ -10,7 +10,13 @@ "@types/query-string": "^6.3.0", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", + "date-and-time": "^2.3.1", "dotenv": "^10.0.0", + "eslint": "^8.14.0", + "eslint-config-custom": "*", + "exchange-rates-api": "^1.1.0", + "interfaces": "*", + "lib": "*", "prop-types": "^15.7.2", "query-string": "^7.0.1", "ra-data-json-server": "^3.19.0", @@ -23,13 +29,8 @@ "react-dom": "^17.0.2", "react-dropzone": "^11.4.2", "react-scripts": "4.0.3", - "typescript": "^4.1.2", - "exchange-rates-api": "^1.1.0", - "eslint": "^8.14.0", - "eslint-config-custom": "*", - "interfaces": "*", - "lib": "*", "tsconfig": "*", + "typescript": "^4.1.2", "web-vitals": "^1.0.1" }, "scripts": { diff --git a/apps/admin/src/components/configurable_options/Create.tsx b/apps/admin/src/components/configurable_options/Create.tsx index a3bb238..4233f98 100644 --- a/apps/admin/src/components/configurable_options/Create.tsx +++ b/apps/admin/src/components/configurable_options/Create.tsx @@ -1,13 +1,14 @@ import - { - ArrayInput, - Create, FormTab, - NumberInput, - ReferenceArrayInput, SelectArrayInput, - SimpleFormIterator, - TabbedForm, - TextInput, - } from "react-admin"; +{ + ArrayInput, + AutocompleteArrayInput, + Create, FormTab, + NumberInput, + ReferenceArrayInput, + SimpleFormIterator, + TabbedForm, + TextInput, +} from "react-admin"; export const Create_configurable_options = (props: any) => ( @@ -15,8 +16,11 @@ export const Create_configurable_options = (props: any) => - - ({ + "name": searchText, + })} perPage={100} source="products_ids" reference="products"> + ( @@ -15,8 +16,11 @@ export const Edit_configurable_options = (props: any) => - - ({ + "name": searchText, + })} perPage={100} source="products_ids" reference="products"> + ( @@ -21,7 +21,7 @@ export const EditCustomer = (props: any) => - + { return { id: e, name: e }; })} /> diff --git a/apps/admin/src/components/invoices/Create.tsx b/apps/admin/src/components/invoices/Create.tsx index 6b77caf..f0ad71e 100644 --- a/apps/admin/src/components/invoices/Create.tsx +++ b/apps/admin/src/components/invoices/Create.tsx @@ -1,34 +1,37 @@ import { ArrayInput, + AutocompleteArrayInput, BooleanInput, Create, DateInput, FormTab, NumberInput, - ReferenceArrayInput, SelectArrayInput, SelectInput, + ReferenceArrayInput, AutocompleteInput, SimpleFormIterator, TabbedForm, } from "react-admin"; //@ts-ignore import MarkdownInput from 'ra-input-markdown'; import { currencyCodes } from "lib/Currencies"; +import RenderFullName from "../../lib/RenderFullName"; export const CreateInvoices = (props: any) => ( - - ({ + "personal.first_name": searchText, + })} perPage={100} source="customer_uid" reference="customers"> + - `${record.personal.first_name} ${record.personal.last_name}`} + optionText={RenderFullName} /> - { id: "active", name: "active" }, { id: "pending", name: "pending" }, ]} /> - { id: "swish", name: "swish" }, ]} /> - + { return { id: e, name: e }; })} /> @@ -66,8 +69,11 @@ export const CreateInvoices = (props: any) => - - ({ + "name": searchText, + })} perPage={100} source="product_id" reference="products"> + - - record.id.toString()} /> + ({ + "id": searchText, + })} perPage={100} source="transactions" reference="transactions"> + record?.id?.toString() ?? ""} /> diff --git a/apps/admin/src/components/invoices/Edit.tsx b/apps/admin/src/components/invoices/Edit.tsx index b62d3fc..4eaf046 100644 --- a/apps/admin/src/components/invoices/Edit.tsx +++ b/apps/admin/src/components/invoices/Edit.tsx @@ -1,16 +1,18 @@ import { ArrayInput, + AutocompleteArrayInput, BooleanInput, DateInput, Edit, FormTab, NumberInput, - ReferenceArrayInput, ReferenceInput, SelectArrayInput, SelectInput, + ReferenceArrayInput, ReferenceInput, AutocompleteInput, SimpleFormIterator, TabbedForm, } from "react-admin"; //@ts-ignore import MarkdownInput from 'ra-input-markdown'; import { currencyCodes } from "lib/Currencies"; +import RenderFullName from "../../lib/RenderFullName"; export const EditInvoices = (props: any) => ( @@ -18,19 +20,20 @@ export const EditInvoices = (props: any) => - - ({ + "personal.first_name": searchText, + })} perPage={100} source="customer_uid" reference="customers"> + - `${record.personal.first_name} ${record.personal.last_name}`} + optionText={RenderFullName} /> - { id: "cancelled", name: "cancelled" }, ]} /> - ]} /> - + { return { id: e, name: e }; })} /> @@ -76,8 +79,10 @@ export const EditInvoices = (props: any) => - - ({ + "name": searchText, + })} perPage={100} source="product_id" reference="products"> + - - ({ + "id": searchText, + })} perPage={100} source="transactions" reference="transactions"> + record.id.toString()} + optionText={(record) => record?.id?.toString() ?? ""} /> diff --git a/apps/admin/src/components/invoices/List.tsx b/apps/admin/src/components/invoices/List.tsx index ea65354..d4817ae 100644 --- a/apps/admin/src/components/invoices/List.tsx +++ b/apps/admin/src/components/invoices/List.tsx @@ -9,9 +9,10 @@ import Filter, SearchInput, ReferenceInput, - SelectInput, - ArrayField + AutocompleteInput, + ArrayField, } from 'react-admin'; +import RenderFullName from "../../lib/RenderFullName"; const PostPagination = (props: JSX.IntrinsicAttributes) => ; @@ -22,9 +23,7 @@ const TagFilter = (props: any) => {/* Search for specific customer */} - - `${record.personal.first_name} ${record.personal.last_name}`} /> + ) @@ -38,8 +37,7 @@ export const InvoicesList = (props: any) => ( - `${record.personal.first_name} ${record.personal.last_name}`} + render={RenderFullName} source="personal.first_name" /> diff --git a/apps/admin/src/components/orders/Create.tsx b/apps/admin/src/components/orders/Create.tsx index 6283288..50fcc12 100644 --- a/apps/admin/src/components/orders/Create.tsx +++ b/apps/admin/src/components/orders/Create.tsx @@ -3,31 +3,33 @@ import ArrayInput, Create, FormTab, NumberInput, - ReferenceArrayInput, SelectInput, + ReferenceArrayInput, AutocompleteInput, SimpleFormIterator, TabbedForm, } from "react-admin"; +import RenderFullName from "../../lib/RenderFullName"; export const CreateOrders = (props: any) => ( - - ({ + "personal.first_name": searchText, + })} perPage={100} source="customer_uid" reference="customers"> + - `${record.personal.first_name} ${record.personal.last_name}`} + optionText={RenderFullName} /> - - ]} /> - { id: "credit_card", name: "credit_card" }, { id: "swish", name: "swish" }, ]} /> - - ]} /> - - - record.id.toString()} /> + {/* @ts-ignore */} + ({ + "id": searchText, + })} perPage={100} source="invoices" reference="invoices"> + record?.id?.toString() ?? ""} /> diff --git a/apps/admin/src/components/orders/Edit.tsx b/apps/admin/src/components/orders/Edit.tsx index 5954822..52ba5b1 100644 --- a/apps/admin/src/components/orders/Edit.tsx +++ b/apps/admin/src/components/orders/Edit.tsx @@ -3,31 +3,32 @@ import ArrayInput, Edit, FormTab, NumberInput, - ReferenceArrayInput, ReferenceInput, SelectInput, + ReferenceArrayInput, ReferenceInput, AutocompleteInput, SimpleFormIterator, TabbedForm, } from "react-admin"; +import RenderFullName from "../../lib/RenderFullName"; export const EditOrders = (props: any) => ( - - ({ + "personal.first_name": searchText, + })} perPage={100} source="customer_uid" reference="customers"> + - `${record.personal.first_name} ${record.personal.last_name}`} + // allowEmpty={false} + optionText={RenderFullName} /> - - ]} /> - { id: "credit_card", name: "credit_card" }, { id: "swish", name: "swish" }, ]} /> - - - record.id.toString()} /> + record?.id?.toString() ?? ""} /> - + ); \ No newline at end of file diff --git a/apps/admin/src/components/orders/List.tsx b/apps/admin/src/components/orders/List.tsx index 06b991e..6e18167 100644 --- a/apps/admin/src/components/orders/List.tsx +++ b/apps/admin/src/components/orders/List.tsx @@ -1,4 +1,5 @@ -import { List, Datagrid, TextField, EditButton, ReferenceField, FunctionField, DateField, ReferenceArrayField, SingleFieldList, ChipField, Pagination, ArrayField } from 'react-admin'; +import { List, Datagrid, TextField, EditButton, ReferenceField, FunctionField, ReferenceArrayField, SingleFieldList, ChipField, Pagination, ArrayField } from 'react-admin'; +import RenderFullName from '../../lib/RenderFullName'; const PostPagination = (props: JSX.IntrinsicAttributes) => ; @@ -9,8 +10,7 @@ export const OrderList = (props: any) => ( - `${record.personal.first_name} ${record.personal.last_name}`} + render={RenderFullName} source="personal.first_name" /> @@ -31,8 +31,8 @@ export const OrderList = (props: any) => ( - - + + ( - - ({ + "name": searchText, + })} perPage={100} source="category_uid" reference="categories"> + - + { + return { id: e, name: e }; + })} /> + - ( - - ({ + "name": searchText, + })} perPage={100} source="category_uid" reference="categories"> + - + { + return { id: e, name: e }; + })} /> + - - + - - - - - - + + + + + + diff --git a/apps/admin/src/components/promotion_codes/Create.tsx b/apps/admin/src/components/promotion_codes/Create.tsx index 86c056f..b06dd98 100644 --- a/apps/admin/src/components/promotion_codes/Create.tsx +++ b/apps/admin/src/components/promotion_codes/Create.tsx @@ -6,7 +6,7 @@ percentage: boolean; products_ids: Array; */ -import { BooleanInput, Create, FormTab, NumberInput, ReferenceArrayInput, SelectArrayInput, TabbedForm, TextInput } from "react-admin"; +import { AutocompleteArrayInput, BooleanInput, Create, FormTab, NumberInput, ReferenceArrayInput, TabbedForm, TextInput } from "react-admin"; export default function CreatePromotionCode(props: any) { @@ -19,8 +19,10 @@ export default function CreatePromotionCode(props: any) - - ({ + "name": searchText, + })} perPage={100} source="products_ids" reference="products"> + ; */ -import { BooleanInput, Edit, FormTab, NumberInput, ReferenceArrayInput, SelectArrayInput, TabbedForm, TextInput } from "react-admin"; +import { AutocompleteArrayInput, BooleanInput, Edit, FormTab, NumberInput, ReferenceArrayInput, TabbedForm, TextInput } from "react-admin"; export default function EditPromotionCode(props: any) { @@ -19,8 +19,10 @@ export default function EditPromotionCode(props: any) - - ({ + "name": searchText, + })} perPage={100} source="products_ids" reference="products"> + - - ({ + "name": searchText, + })} perPage={100} source="promotion_codes" reference="promotion_codes"> + - + diff --git a/apps/admin/src/components/quotes/Edit.tsx b/apps/admin/src/components/quotes/Edit.tsx index 5df8e41..9231f68 100644 --- a/apps/admin/src/components/quotes/Edit.tsx +++ b/apps/admin/src/components/quotes/Edit.tsx @@ -20,30 +20,33 @@ } */ -import { ArrayInput, DateInput, Edit, FormTab, NumberInput, ReferenceArrayInput, ReferenceInput, SelectArrayInput, SelectInput, SimpleFormIterator, TabbedForm, TextInput } from "react-admin"; +import { ArrayInput, AutocompleteArrayInput, DateInput, Edit, FormTab, NumberInput, ReferenceArrayInput, ReferenceInput, AutocompleteInput, SimpleFormIterator, TabbedForm, TextInput } from "react-admin"; import CurrencyInput from "../../inputs/CurrencyInput"; import PaymentMethodInput from "../../inputs/PaymentMethodInput"; //@ts-ignore import MarkdownInput from 'ra-input-markdown'; +import RenderFullName from "../../lib/RenderFullName"; export default function EditQuote(props: any) { return ( - - ({ + "personal.first_name": searchText, + })} perPage={100} source="customer_uid" reference="customers"> + - `${record.personal.first_name} ${record.personal.last_name}`} + optionText={RenderFullName} /> - - ({ + "name": searchText, + })} perPage={100} source="promotion_codes" reference="promotion_codes"> + ( @@ -9,29 +11,66 @@ export const CreateTransactions = (props: any) => - - - `${record.personal.first_name} ${record.personal.last_name}`} - /> - - - record.id.toString()} /> - + ]} defaultValue="income" /> + + {({ formData }) => formData.statement === "income" && + <> + ({ + "personal.first_name": searchText, + })} perPage={100} source="customer_uid" reference="customers" allowEmpty> + + +
+ ({ + "id": searchText, + })} perPage={100} source="invoice_uid" + reference="invoices" allowEmpty> + record?.id?.toString() ?? ""} /> + +
+ + } +
+ + {({ formData }) => formData.statement === "expense" && + <> +
+ +
+
+ +
+
+ +
+
+ +
+ + } +
- + { return { id: e, name: e }; })} /> - - + ( - - - - `${record.personal.first_name} ${record.personal.last_name}`} - /> - - - record.id.toString()} /> - + + {({ formData }) => formData.statement === "income" && + <> + ({ + "personal.first_name": searchText, + })} perPage={100} source="customer_uid" reference="customers"> + + `${record.personal.first_name} ${record.personal.last_name}`} + /> + +
+ ({ + "id": searchText, + })} perPage={100} source="invoice_uid" + reference="invoices"> + record?.id?.toString() ?? ""} /> + +
+ + } +
+ + {({ formData }) => formData.statement === "expense" && + <> +
+ +
+
+ +
+
+ +
+
+ +
+ + } +
- + { return { id: e, name: e }; })} /> - ; @@ -8,42 +9,43 @@ const TagFilter = (props: any) => {/* Search for specific customer */} - - - `${record.personal.first_name} ${record.personal.last_name}`} /> + + ) } -export const ListTransactions = (props: any) => ( - } filters={}> - - - - - `${record.id}`} - source="id" - /> - - - - - `${record.personal.first_name} ${record.personal.last_name}`} - source="personal.first_name" - /> - - - - - - - - - -); \ No newline at end of file +export const ListTransactions = (props: any) => +{ + return ( + } filters={}> + + + + + `${record.id}`} + source="id" + /> + + + + + `${record.personal.first_name} ${record.personal.last_name}`} + source="personal.first_name" + /> + + + + + + + + + + ) +}; \ No newline at end of file diff --git a/apps/admin/src/inputs/CurrencyInput.tsx b/apps/admin/src/inputs/CurrencyInput.tsx index 07aa14d..8e1d24f 100644 --- a/apps/admin/src/inputs/CurrencyInput.tsx +++ b/apps/admin/src/inputs/CurrencyInput.tsx @@ -1,10 +1,10 @@ import { currencyCodes } from "lib/Currencies"; -import { SelectInput } from "react-admin"; +import { AutocompleteInput } from "react-admin"; export default function CurrencyInput() { return ( - + { return { id: e, name: e }; })} /> diff --git a/apps/admin/src/inputs/CustomerInput.tsx b/apps/admin/src/inputs/CustomerInput.tsx index ed2b518..0922494 100644 --- a/apps/admin/src/inputs/CustomerInput.tsx +++ b/apps/admin/src/inputs/CustomerInput.tsx @@ -1,4 +1,5 @@ -import { ReferenceArrayInput, ReferenceInput, SelectInput } from "react-admin"; +import { ReferenceArrayInput, ReferenceInput, AutocompleteInput } from "react-admin"; +import RenderFullName from "../lib/RenderFullName"; export default function CustomerInput({ source = "customer_uid", @@ -14,14 +15,12 @@ export default function CustomerInput({ label: label, children: ( - - `${record.personal.first_name} ${record.personal.last_name}`} + optionText={RenderFullName} /> ) }); diff --git a/apps/admin/src/inputs/PaymentMethodInput.tsx b/apps/admin/src/inputs/PaymentMethodInput.tsx index 231e10c..848d24d 100644 --- a/apps/admin/src/inputs/PaymentMethodInput.tsx +++ b/apps/admin/src/inputs/PaymentMethodInput.tsx @@ -1,9 +1,9 @@ -import { SelectInput } from "react-admin"; +import { AutocompleteInput } from "react-admin"; export default function PaymentMethodInput() { return ( - (choice: T) +{ + if (!choice) + return ``; + return `${choice?.personal?.first_name ?? ``} ${choice?.personal?.last_name ?? ``}`; +} \ No newline at end of file diff --git a/apps/admin/src/lib/date.js b/apps/admin/src/lib/date.js new file mode 100644 index 0000000..8ea0693 --- /dev/null +++ b/apps/admin/src/lib/date.js @@ -0,0 +1,38 @@ +/* eslint-disable no-const-assign */ +/* eslint-disable no-useless-escape */ +/* eslint-disable no-cond-assign */ +/* + date-and-time (c) KNOWLEDGECODE | MIT +*/ +const e = {}, f = {}, m = "en", n = { MMMM: "January February March April May June July August September October November December".split(" "), MMM: "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "), dddd: "Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "), ddd: "Sun Mon Tue Wed Thu Fri Sat".split(" "), dd: "Su Mo Tu We Th Fr Sa".split(" "), A: ["AM", "PM"] }, q = { + YYYY: function (a) { return ("000" + a.getFullYear()).slice(-4) }, YY: function (a) { return ("0" + a.getFullYear()).slice(-2) }, Y: function (a) + { + return "" + + a.getFullYear() + }, MMMM: function (a) { return this.res.MMMM[a.getMonth()] }, MMM: function (a) { return this.res.MMM[a.getMonth()] }, MM: function (a) { return ("0" + (a.getMonth() + 1)).slice(-2) }, M: function (a) { return "" + (a.getMonth() + 1) }, DD: function (a) { return ("0" + a.getDate()).slice(-2) }, D: function (a) { return "" + a.getDate() }, HH: function (a) { return ("0" + a.getHours()).slice(-2) }, H: function (a) { return "" + a.getHours() }, A: function (a) { return this.res.A[11 < a.getHours() | 0] }, hh: function (a) { return ("0" + (a.getHours() % 12 || 12)).slice(-2) }, + h: function (a) { return "" + (a.getHours() % 12 || 12) }, mm: function (a) { return ("0" + a.getMinutes()).slice(-2) }, m: function (a) { return "" + a.getMinutes() }, ss: function (a) { return ("0" + a.getSeconds()).slice(-2) }, s: function (a) { return "" + a.getSeconds() }, SSS: function (a) { return ("00" + a.getMilliseconds()).slice(-3) }, SS: function (a) { return ("0" + (a.getMilliseconds() / 10 | 0)).slice(-2) }, S: function (a) { return "" + (a.getMilliseconds() / 100 | 0) }, dddd: function (a) { return this.res.dddd[a.getDay()] }, ddd: function (a) { return this.res.ddd[a.getDay()] }, + dd: function (a) { return this.res.dd[a.getDay()] }, Z: function (a) { a = a.getTimezoneOffset() / .6 | 0; return (0 < a ? "-" : "+") + ("000" + Math.abs(a - (a % 100 * .4 | 0))).slice(-4) }, ZZ: function (a) { a = a.getTimezoneOffset(); var b = Math.abs(a); return (0 < a ? "-" : "+") + ("0" + (b / 60 | 0)).slice(-2) + ":" + ("0" + b % 60).slice(-2) }, post: function (a) { return a }, res: n +}, r = { + YYYY: function (a) { return this.exec(/^\d{4}/, a) }, Y: function (a) { return this.exec(/^\d{1,4}/, a) }, MMMM: function (a) { a = this.find(this.res.MMMM, a); a.value++; return a }, MMM: function (a) + { + a = this.find(this.res.MMM, + a); a.value++; return a + }, MM: function (a) { return this.exec(/^\d\d/, a) }, M: function (a) { return this.exec(/^\d\d?/, a) }, DD: function (a) { return this.exec(/^\d\d/, a) }, D: function (a) { return this.exec(/^\d\d?/, a) }, HH: function (a) { return this.exec(/^\d\d/, a) }, H: function (a) { return this.exec(/^\d\d?/, a) }, A: function (a) { return this.find(this.res.A, a) }, hh: function (a) { return this.exec(/^\d\d/, a) }, h: function (a) { return this.exec(/^\d\d?/, a) }, mm: function (a) { return this.exec(/^\d\d/, a) }, m: function (a) + { + return this.exec(/^\d\d?/, + a) + }, ss: function (a) { return this.exec(/^\d\d/, a) }, s: function (a) { return this.exec(/^\d\d?/, a) }, SSS: function (a) { return this.exec(/^\d{1,3}/, a) }, SS: function (a) { a = this.exec(/^\d\d?/, a); a.value *= 10; return a }, S: function (a) { a = this.exec(/^\d/, a); a.value *= 100; return a }, Z: function (a) { a = this.exec(/^[\+-]\d{2}[0-5]\d/, a); a.value = -60 * (a.value / 100 | 0) - a.value % 100; return a }, ZZ: function (a) { a = /^([\+-])(\d{2}):([0-5]\d)/.exec(a) || ["", "", "", ""]; return { value: -(60 * (a[1] + a[2] | 0) + (a[1] + a[3] | 0)), length: a[0].length } }, h12: function (a, + b) { return (12 === a ? 0 : a) + 12 * b }, exec: function (a, b) { a = (a.exec(b) || [""])[0]; return { value: a | 0, length: a.length } }, find: function (a, b) { for (var d = -1, c = 0, h = 0, g = a.length, l; h < g; h++)l = a[h], !b.indexOf(l) && l.length > c && (d = h, c = l.length); return { value: d, length: c } }, pre: function (a) { return a }, res: n +}; function t(a, b, d, c) { var h = {}, g; for (g in a) h[g] = a[g]; for (g in b || {}) !!d ^ !!h[g] || (h[g] = b[g]); c && (h.res = c); return h } var u = { _formatter: q, _parser: r }, w, x; +u.compile = function (a) { for (var b = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, d, c = [a]; d = b.exec(a);)c[c.length] = d[0]; return c }; u.format = function (a, b, d) { var c = this || x; b = "string" === typeof b ? c.compile(b) : b; var h = a.getTimezoneOffset(); a = c.addMinutes(a, d ? h : 0); c = c._formatter; var g = ""; a.getTimezoneOffset = function () { return d ? 0 : h }; for (var l = 1, v = b.length, k; l < v; l++)k = b[l], g += c[k] ? c.post(c[k](a, b[0])) : k.replace(/\[(.*)]/, "$1"); return g }; +u.preparse = function (a, b) +{ + var d = this || x; b = "string" === typeof b ? d.compile(b) : b; var c = { Y: 1970, M: 1, D: 1, H: 0, A: 0, h: 0, m: 0, s: 0, S: 0, Z: 0, _index: 0, _length: 0, _match: 0 }, h = /\[(.*)]/; d = d._parser; var g = 0; a = d.pre(a); for (var l = 1, v = b.length, k, p; l < v; l++) if (k = b[l], d[k]) { p = d[k](a.slice(g), b[0]); if (!p.length) break; g += p.length; c[p.token || k.charAt(0)] = p.value; c._match++ } + else if (k === a.charAt(g) || " " === k) g++; else if (h.test(k) && !a.slice(g).indexOf(h.exec(k)[1])) g += k.length - 2; else { "..." === k && (g = a.length); break } c.H = c.H || d.h12(c.h, + c.A); c._index = g; c._length = a.length; return c +}; u.parse = function (a, b, d) { var c = this || x; b = "string" === typeof b ? c.compile(b) : b; a = c.preparse(a, b); return c.isValid(a) ? (a.M -= 100 > a.Y ? 22801 : 1, d || ~c._parser.find(b, "ZZ").value ? new Date(Date.UTC(a.Y, a.M, a.D, a.H, a.m + a.Z, a.s, a.S)) : new Date(a.Y, a.M, a.D, a.H, a.m, a.s, a.S)) : new Date(NaN) }; +u.isValid = function (a, b) { var d = this || x; a = "string" === typeof a ? d.preparse(a, b) : a; d = [31, 28 + d.isLeapYear(a.Y) | 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][a.M - 1]; return !(1 > a._index || 1 > a._length || a._index - a._length || 1 > a._match || 1 > a.Y || 9999 < a.Y || 1 > a.M || 12 < a.M || 1 > a.D || a.D > d || 0 > a.H || 23 < a.H || 0 > a.m || 59 < a.m || 0 > a.s || 59 < a.s || 0 > a.S || 999 < a.S || -840 > a.Z || 720 < a.Z) }; u.transform = function (a, b, d, c) { let h = this || x; return h.format(h.parse(a, b), d, c) }; u.addYears = function (a, b) { return (this || x).addMonths(a, 12 * b) }; +u.addMonths = function (a, b) { a = new Date(a.getTime()); a.setMonth(a.getMonth() + b); return a }; u.addDays = function (a, b) { a = new Date(a.getTime()); a.setDate(a.getDate() + b); return a }; u.addHours = function (a, b) { return (this || x).addMinutes(a, 60 * b) }; u.addMinutes = function (a, b) { return (this || x).addSeconds(a, 60 * b) }; u.addSeconds = function (a, b) { return (this || x).addMilliseconds(a, 1E3 * b) }; u.addMilliseconds = function (a, b) { return new Date(a.getTime() + b) }; +u.subtract = function (a, b) { var d = a.getTime() - b.getTime(); return { toMilliseconds: function () { return d }, toSeconds: function () { return d / 1E3 }, toMinutes: function () { return d / 6E4 }, toHours: function () { return d / 36E5 }, toDays: function () { return d / 864E5 } } }; u.isLeapYear = function (a) { return !(a % 4) && !!(a % 100) || !(a % 400) }; u.isSameDay = function (a, b) { return a.toDateString() === b.toDateString() }; u.locale = function (a, b) { e[a] || (e[a] = b) }; u.plugin = function (a, b) { f[a] || (f[a] = b) }; w = t(u); x = t(u); +x.locale = function (a) { a = "function" === typeof a ? a : x.locale[a]; if (!a) return m; m = a(u); var b = e[m] || {}, d = t(n, b.res, !0); a = t(q, b.formatter, !0, d); b = t(r, b.parser, !0, d); x._formatter = w._formatter = a; x._parser = w._parser = b; for (var c in f) x.extend(f[c]); return m }; x.extend = function (a) { var b = t(x._parser.res, a.res), d = a.extender || {}; x._formatter = t(x._formatter, a.formatter, !1, b); x._parser = t(x._parser, a.parser, !1, b); for (var c in d) x[c] || (x[c] = d[c]) }; +x.plugin = function (a) { (a = "function" === typeof a ? a : x.plugin[a]) && x.extend(f[a(u, w)] || {}) }; export default x \ No newline at end of file diff --git a/apps/admin/src/lib/dateFormat.ts b/apps/admin/src/lib/dateFormat.ts new file mode 100644 index 0000000..4ad9a0e --- /dev/null +++ b/apps/admin/src/lib/dateFormat.ts @@ -0,0 +1,14 @@ + +/** + * @type {any} + */ +// @ts-ignore +import date from "./date"; + +export function getDate() +{ + const D_CurrentDate = new Date(); + // @ts-ignore + const S_FixedDate = date.format(D_CurrentDate, "YYYY-MM-DD"); + return S_FixedDate; +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9f37a8c..4e34002 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,15 +23,13 @@ "name": "cpg-admin", "version": "0.1.0", "dependencies": { - "@babel/eslint-parser": "^7.5.4", - "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", - "@types/jest": "^26.0.15", "@types/node": "^12.0.0", "@types/query-string": "^6.3.0", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", + "date-and-time": "^2.3.1", "dotenv": "^10.0.0", "eslint": "^8.14.0", "eslint-config-custom": "*", @@ -106,6 +104,11 @@ "version": "2.0.1", "license": "Python-2.0" }, + "apps/admin/node_modules/date-and-time": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.3.1.tgz", + "integrity": "sha512-OaIRmSJXifwEN21rMVVDs0Kz8uhJ3wWPYd86atkRiqN54liaMQYEbbrgjZQea75YXOBWL4ZFb3rG/waenw1TEg==" + }, "apps/admin/node_modules/eslint": { "version": "8.15.0", "license": "MIT", @@ -932,31 +935,6 @@ "semver": "bin/semver.js" } }, - "node_modules/@babel/eslint-parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.17.0.tgz", - "integrity": "sha512-PUEJ7ZBXbRkbq3qqM/jZ2nIuakUBqCYc7Qf52Lj7dlZ6zERnqisdHioL0l4wwQZnmskMeasqUNzLBFKs3nylXA==", - "dependencies": { - "eslint-scope": "^5.1.1", - "eslint-visitor-keys": "^2.1.0", - "semver": "^6.3.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || >=14.0.0" - }, - "peerDependencies": { - "@babel/core": ">=7.11.0", - "eslint": "^7.5.0 || ^8.0.0" - } - }, - "node_modules/@babel/eslint-parser/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/@babel/generator": { "version": "7.17.10", "license": "MIT", @@ -5549,44 +5527,6 @@ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" } }, - "node_modules/@testing-library/jest-dom": { - "version": "5.16.4", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.9.2", - "@types/testing-library__jest-dom": "^5.9.1", - "aria-query": "^5.0.0", - "chalk": "^3.0.0", - "css": "^3.0.0", - "css.escape": "^1.5.1", - "dom-accessibility-api": "^0.5.6", - "lodash": "^4.17.15", - "redent": "^3.0.0" - }, - "engines": { - "node": ">=8", - "npm": ">=6", - "yarn": ">=1" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/aria-query": { - "version": "5.0.0", - "license": "Apache-2.0", - "engines": { - "node": ">=6.0" - } - }, - "node_modules/@testing-library/jest-dom/node_modules/chalk": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@testing-library/react": { "version": "11.2.7", "license": "MIT", @@ -5940,27 +5880,6 @@ "@types/istanbul-lib-report": "*" } }, - "node_modules/@types/jest": { - "version": "26.0.24", - "license": "MIT", - "dependencies": { - "jest-diff": "^26.0.0", - "pretty-format": "^26.0.0" - } - }, - "node_modules/@types/jest/node_modules/pretty-format": { - "version": "26.6.2", - "license": "MIT", - "dependencies": { - "@jest/types": "^26.6.2", - "ansi-regex": "^5.0.0", - "ansi-styles": "^4.0.0", - "react-is": "^17.0.1" - }, - "engines": { - "node": ">= 10" - } - }, "node_modules/@types/json-schema": { "version": "7.0.11", "license": "MIT" @@ -6239,13 +6158,6 @@ "version": "1.0.8", "license": "MIT" }, - "node_modules/@types/testing-library__jest-dom": { - "version": "5.14.3", - "license": "MIT", - "dependencies": { - "@types/jest": "*" - } - }, "node_modules/@types/through": { "version": "0.0.30", "dev": true, @@ -9441,15 +9353,6 @@ "node": ">=4" } }, - "node_modules/css": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "inherits": "^2.0.4", - "source-map": "^0.6.1", - "source-map-resolve": "^0.6.0" - } - }, "node_modules/css-blank-pseudo": { "version": "0.1.4", "license": "CC0-1.0", @@ -9756,18 +9659,6 @@ "url": "https://github.com/sponsors/fb55" } }, - "node_modules/css.escape": { - "version": "1.5.1", - "license": "MIT" - }, - "node_modules/css/node_modules/source-map-resolve": { - "version": "0.6.0", - "license": "MIT", - "dependencies": { - "atob": "^2.1.2", - "decode-uri-component": "^0.2.0" - } - }, "node_modules/cssdb": { "version": "4.4.0", "license": "CC0-1.0" @@ -17766,13 +17657,6 @@ "dom-walk": "^0.1.0" } }, - "node_modules/min-indent": { - "version": "1.0.1", - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/mini-create-react-context": { "version": "0.4.1", "license": "MIT", @@ -27074,17 +26958,6 @@ "node": "*" } }, - "node_modules/redent": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "indent-string": "^4.0.0", - "strip-indent": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/redux": { "version": "4.2.0", "license": "MIT", @@ -29588,16 +29461,6 @@ "node": ">=6" } }, - "node_modules/strip-indent": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "min-indent": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-json-comments": { "version": "3.1.1", "license": "MIT", @@ -33619,23 +33482,6 @@ } } }, - "@babel/eslint-parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.17.0.tgz", - "integrity": "sha512-PUEJ7ZBXbRkbq3qqM/jZ2nIuakUBqCYc7Qf52Lj7dlZ6zERnqisdHioL0l4wwQZnmskMeasqUNzLBFKs3nylXA==", - "requires": { - "eslint-scope": "^5.1.1", - "eslint-visitor-keys": "^2.1.0", - "semver": "^6.3.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" - } - } - }, "@babel/generator": { "version": "7.17.10", "requires": { @@ -36516,32 +36362,6 @@ } } }, - "@testing-library/jest-dom": { - "version": "5.16.4", - "requires": { - "@babel/runtime": "^7.9.2", - "@types/testing-library__jest-dom": "^5.9.1", - "aria-query": "^5.0.0", - "chalk": "^3.0.0", - "css": "^3.0.0", - "css.escape": "^1.5.1", - "dom-accessibility-api": "^0.5.6", - "lodash": "^4.17.15", - "redent": "^3.0.0" - }, - "dependencies": { - "aria-query": { - "version": "5.0.0" - }, - "chalk": { - "version": "3.0.0", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - } - } - }, "@testing-library/react": { "version": "11.2.7", "requires": { @@ -36822,24 +36642,6 @@ "@types/istanbul-lib-report": "*" } }, - "@types/jest": { - "version": "26.0.24", - "requires": { - "jest-diff": "^26.0.0", - "pretty-format": "^26.0.0" - }, - "dependencies": { - "pretty-format": { - "version": "26.6.2", - "requires": { - "@jest/types": "^26.6.2", - "ansi-regex": "^5.0.0", - "ansi-styles": "^4.0.0", - "react-is": "^17.0.1" - } - } - } - }, "@types/json-schema": { "version": "7.0.11" }, @@ -37073,12 +36875,6 @@ "@types/tapable": { "version": "1.0.8" }, - "@types/testing-library__jest-dom": { - "version": "5.14.3", - "requires": { - "@types/jest": "*" - } - }, "@types/through": { "version": "0.0.30", "dev": true, @@ -39114,16 +38910,14 @@ "cpg-admin": { "version": "file:apps/admin", "requires": { - "@babel/eslint-parser": "^7.5.4", - "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", - "@types/jest": "^26.0.15", "@types/node": "^12.0.0", "@types/query-string": "^6.3.0", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@types/react-router-dom": "^5.3.2", + "date-and-time": "*", "dotenv": "^10.0.0", "eslint": "^8.14.0", "eslint-config-custom": "*", @@ -39178,6 +38972,11 @@ "argparse": { "version": "2.0.1" }, + "date-and-time": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.3.1.tgz", + "integrity": "sha512-OaIRmSJXifwEN21rMVVDs0Kz8uhJ3wWPYd86atkRiqN54liaMQYEbbrgjZQea75YXOBWL4ZFb3rG/waenw1TEg==" + }, "eslint": { "version": "8.15.0", "requires": { @@ -39746,23 +39545,6 @@ "crypto-random-string": { "version": "1.0.0" }, - "css": { - "version": "3.0.0", - "requires": { - "inherits": "^2.0.4", - "source-map": "^0.6.1", - "source-map-resolve": "^0.6.0" - }, - "dependencies": { - "source-map-resolve": { - "version": "0.6.0", - "requires": { - "atob": "^2.1.2", - "decode-uri-component": "^0.2.0" - } - } - } - }, "css-blank-pseudo": { "version": "0.1.4", "requires": { @@ -39941,9 +39723,6 @@ "css-what": { "version": "6.1.0" }, - "css.escape": { - "version": "1.5.1" - }, "cssdb": { "version": "4.4.0" }, @@ -45220,9 +44999,6 @@ "dom-walk": "^0.1.0" } }, - "min-indent": { - "version": "1.0.1" - }, "mini-create-react-context": { "version": "0.4.1", "requires": { @@ -51255,13 +51031,6 @@ } } }, - "redent": { - "version": "3.0.0", - "requires": { - "indent-string": "^4.0.0", - "strip-indent": "^3.0.0" - } - }, "redux": { "version": "4.2.0", "requires": { @@ -52954,12 +52723,6 @@ "strip-final-newline": { "version": "2.0.0" }, - "strip-indent": { - "version": "3.0.0", - "requires": { - "min-indent": "^1.0.0" - } - }, "strip-json-comments": { "version": "3.1.1" }, diff --git a/packages/lib/Time.d.ts b/packages/lib/Time.d.ts index b5b61b1..7151635 100644 --- a/packages/lib/Time.d.ts +++ b/packages/lib/Time.d.ts @@ -1,2 +1,3 @@ export declare function getTime(): any; export declare function getDate(removeDays?: boolean): any; +export declare function formatDate(date: Date, format: string): string; diff --git a/packages/lib/Time.js b/packages/lib/Time.js index 532bd88..286d0d6 100644 --- a/packages/lib/Time.js +++ b/packages/lib/Time.js @@ -1,7 +1,11 @@ "use strict"; exports.__esModule = true; -exports.getDate = exports.getTime = void 0; +exports.getDate = exports.getTime = exports.formatDate = void 0; var date_and_time_1 = require("date-and-time"); +function formatDate(date, format) { + return date_and_time_1.format(date, format); +} +exports.formatDate = formatDate; function getTime() { var D_CurrentDate = new Date(); return date_and_time_1.format(D_CurrentDate, "YYYY-MM-DD HH:mm:ss"); diff --git a/packages/lib/Time.ts b/packages/lib/Time.ts index 5932b23..9b54bbe 100644 --- a/packages/lib/Time.ts +++ b/packages/lib/Time.ts @@ -1,5 +1,11 @@ import dateFormat from "date-and-time"; + +export function formatDate(date: Date, format: string): string +{ + return dateFormat.format(date, format); +} + export function getTime() { const D_CurrentDate = new Date();