@griddo/ax 1.57.13 → 1.57.17
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": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "1.57.
|
|
4
|
+
"version": "1.57.17",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -241,5 +241,5 @@
|
|
|
241
241
|
"publishConfig": {
|
|
242
242
|
"access": "public"
|
|
243
243
|
},
|
|
244
|
-
"gitHead": "
|
|
244
|
+
"gitHead": "514381d0a46d139e682ccf1393e65f807eeeb21a"
|
|
245
245
|
}
|
|
@@ -147,7 +147,7 @@ const restoreDataContentBulk = (dataContentId: number[]) => {
|
|
|
147
147
|
return sendRequest(SERVICES.RESTORE_DATA_CONTENT_BULK, { ids: dataContentId });
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
const getDistributorContent = async (siteID: number, data: any) => {
|
|
150
|
+
const getDistributorContent = async (siteID: number | string, data: any) => {
|
|
151
151
|
const { host, endpoint } = SERVICES.GET_DISTRIBUTOR_CONTENT;
|
|
152
152
|
const [prefix, suffix] = endpoint;
|
|
153
153
|
|
|
@@ -31,7 +31,7 @@ const DateField = (props: IDateFieldProps): JSX.Element => {
|
|
|
31
31
|
} = props;
|
|
32
32
|
|
|
33
33
|
const currentDate = new Date();
|
|
34
|
-
const defaultValue = mandatory ? dateToString(currentDate) : null;
|
|
34
|
+
const defaultValue = mandatory ? dateToString(currentDate, "yyyy/MM/dd") : null;
|
|
35
35
|
const stringDate = value && typeof value === "number" ? dateToString(new Date(value * 1000)) : value;
|
|
36
36
|
|
|
37
37
|
const dateValue = stringDate && (isValidDate(stringDate) || isValidDateRange(stringDate)) ? stringDate : defaultValue;
|
|
@@ -74,7 +74,7 @@ const DateField = (props: IDateFieldProps): JSX.Element => {
|
|
|
74
74
|
end: equalRangeDates ? start : end,
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
const selectedDate = getStringifyDateRange(start, end);
|
|
77
|
+
const selectedDate = getStringifyDateRange(start, end, "yyyy/MM/dd");
|
|
78
78
|
|
|
79
79
|
setDates(rangeDates);
|
|
80
80
|
onChange(selectedDate);
|
|
@@ -20,7 +20,8 @@ const ItemList = (props: IProps) => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const getItems = async () => {
|
|
23
|
-
const
|
|
23
|
+
const siteID = currentSite ? currentSite : "global";
|
|
24
|
+
const response = await structuredData.getDistributorContent(siteID, params);
|
|
24
25
|
if (isReqOk(response.status)) {
|
|
25
26
|
setState({ ...context, state: { ...state, selectedItems: response.data } });
|
|
26
27
|
} else {
|
package/src/helpers/dates.tsx
CHANGED
|
@@ -2,13 +2,20 @@ import { format, formatDistanceToNowStrict, addMinutes, isValid, parse } from "d
|
|
|
2
2
|
|
|
3
3
|
const formatString = "dd/MM/yyyy";
|
|
4
4
|
|
|
5
|
-
const dateToString = (date: Date): string => format(new Date(date),
|
|
6
|
-
|
|
5
|
+
const dateToString = (date: Date, formatDate = formatString): string => format(new Date(date), formatDate);
|
|
6
|
+
|
|
7
|
+
const stringToDate = (value: string): Date => {
|
|
8
|
+
const regEx = /^[0-9]{4}[\/][0-9]{2}[\/][0-9]{2}$/g;
|
|
9
|
+
const isInversed = regEx.test(value);
|
|
10
|
+
const formatDate = isInversed ? "yyyy/MM/dd" : "dd/MM/yyyy";
|
|
11
|
+
return parse(value, formatDate, new Date());
|
|
12
|
+
};
|
|
7
13
|
|
|
8
14
|
const isValidDate = (value: string): boolean => {
|
|
9
15
|
// eslint-disable-next-line
|
|
10
|
-
const regEx = /^[0-9]{
|
|
11
|
-
|
|
16
|
+
const regEx = /^[0-9]{4}[\/][0-9]{2}[\/][0-9]{2}$/g;
|
|
17
|
+
const regEx2 = /^[0-9]{2}[\/][0-9]{2}[\/][0-9]{4}$/g;
|
|
18
|
+
if (regEx.test(value) || regEx2.test(value)) {
|
|
12
19
|
const date = stringToDate(value);
|
|
13
20
|
return isValid(date);
|
|
14
21
|
}
|
|
@@ -39,12 +46,12 @@ const getDateRange = (value: string): { start: Date; end: Date | null } => {
|
|
|
39
46
|
|
|
40
47
|
const areEqualDates = (date1: Date, date2: Date): boolean => dateToString(date1) === dateToString(date2);
|
|
41
48
|
|
|
42
|
-
const getStringifyDateRange = (start: Date, end: Date): string => {
|
|
49
|
+
const getStringifyDateRange = (start: Date, end: Date, formatDate?: string): string => {
|
|
43
50
|
const equalRangeDates = areEqualDates(start, end);
|
|
44
51
|
|
|
45
52
|
const stringifyDates = {
|
|
46
|
-
start: start ? dateToString(start) : "",
|
|
47
|
-
end: end ? dateToString(end) : "",
|
|
53
|
+
start: start ? dateToString(start, formatDate) : "",
|
|
54
|
+
end: end ? dateToString(end, formatDate) : "",
|
|
48
55
|
};
|
|
49
56
|
|
|
50
57
|
return end && !equalRangeDates ? `${stringifyDates.start} - ${stringifyDates.end}` : stringifyDates.start;
|