@griddo/ax 1.57.11 → 1.57.15
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 +5 -2
- package/src/components/Fields/DateField/index.tsx +2 -2
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/index.tsx +11 -20
- package/src/components/Gallery/index.tsx +4 -1
- package/src/components/Modal/style.tsx +1 -0
- package/src/containers/Gallery/actions.tsx +5 -5
- package/src/helpers/dates.tsx +14 -7
- package/src/modules/Sites/SitesList/SiteModal/style.tsx +2 -1
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.15",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -157,6 +157,9 @@
|
|
|
157
157
|
"prettier": "^2.3.0",
|
|
158
158
|
"react-test-render": "1.1.2"
|
|
159
159
|
},
|
|
160
|
+
"resolutions": {
|
|
161
|
+
"react-error-overlay": "6.0.9"
|
|
162
|
+
},
|
|
160
163
|
"babel": {
|
|
161
164
|
"presets": [
|
|
162
165
|
"react-app",
|
|
@@ -238,5 +241,5 @@
|
|
|
238
241
|
"publishConfig": {
|
|
239
242
|
"access": "public"
|
|
240
243
|
},
|
|
241
|
-
"gitHead": "
|
|
244
|
+
"gitHead": "69e8e17f1eab8b9b3a84c0ce164d20e47d7ed733"
|
|
242
245
|
}
|
|
@@ -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);
|
|
@@ -8,7 +8,8 @@ import { Icon, DragAndDrop } from "@ax/components";
|
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
10
10
|
const GalleryDragAndDrop = (props: IProps) => {
|
|
11
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
isImageSelected,
|
|
12
13
|
validFormats,
|
|
13
14
|
site,
|
|
14
15
|
allowUpload,
|
|
@@ -65,7 +66,7 @@ const GalleryDragAndDrop = (props: IProps) => {
|
|
|
65
66
|
const handleUploadFile = async (files: Array<any>) => {
|
|
66
67
|
if (files[0]) {
|
|
67
68
|
if (!checkType(files[0].type)) {
|
|
68
|
-
uploadError("Invalid format");
|
|
69
|
+
uploadError(true, "Invalid format");
|
|
69
70
|
} else {
|
|
70
71
|
try {
|
|
71
72
|
const newImage = await uploadImage(files[0], site);
|
|
@@ -81,6 +82,7 @@ const GalleryDragAndDrop = (props: IProps) => {
|
|
|
81
82
|
|
|
82
83
|
const handleTryAgain = () => {
|
|
83
84
|
setInDropZone(false);
|
|
85
|
+
uploadError(false);
|
|
84
86
|
};
|
|
85
87
|
|
|
86
88
|
const handleFileClick = () => {
|
|
@@ -130,25 +132,14 @@ const GalleryDragAndDrop = (props: IProps) => {
|
|
|
130
132
|
</S.DragIcon>
|
|
131
133
|
<S.DragTitle>Select an image to see details</S.DragTitle>
|
|
132
134
|
</S.StatusWrapper>
|
|
133
|
-
|
|
134
135
|
);
|
|
135
136
|
|
|
136
137
|
return (
|
|
137
138
|
<S.Wrapper hidden={isImageSelected}>
|
|
138
|
-
<S.DragAndDropWrapper
|
|
139
|
-
inDropZone={inDropZone}
|
|
140
|
-
uploading={isUploading}
|
|
141
|
-
success={isSuccess}
|
|
142
|
-
error={isError}
|
|
143
|
-
>
|
|
139
|
+
<S.DragAndDropWrapper inDropZone={inDropZone} uploading={isUploading} success={isSuccess} error={isError}>
|
|
144
140
|
{allowUpload ? renderDragAndDrop() : renderPlaceholder()}
|
|
145
141
|
</S.DragAndDropWrapper>
|
|
146
|
-
<S.UploadingWrapper
|
|
147
|
-
inDropZone={inDropZone}
|
|
148
|
-
uploading={isUploading}
|
|
149
|
-
success={isSuccess}
|
|
150
|
-
error={isError}
|
|
151
|
-
>
|
|
142
|
+
<S.UploadingWrapper inDropZone={inDropZone} uploading={isUploading} success={isSuccess} error={isError}>
|
|
152
143
|
<S.StatusWrapper>
|
|
153
144
|
<S.UploadingStatus>
|
|
154
145
|
<S.DragIcon>
|
|
@@ -184,9 +175,9 @@ interface IGalleryDragAndDropProps {
|
|
|
184
175
|
site: number | string;
|
|
185
176
|
allowUpload: boolean;
|
|
186
177
|
refreshImages: () => Promise<void>;
|
|
187
|
-
isUploading: boolean
|
|
188
|
-
isSuccess: boolean
|
|
189
|
-
isError: boolean
|
|
178
|
+
isUploading: boolean;
|
|
179
|
+
isSuccess: boolean;
|
|
180
|
+
isError: boolean;
|
|
190
181
|
errorMsg: string;
|
|
191
182
|
}
|
|
192
183
|
|
|
@@ -200,7 +191,7 @@ const mapStateToProps = (state: IRootState) => ({
|
|
|
200
191
|
interface IDispatchProps {
|
|
201
192
|
getSiteImages(params: IGetSiteImages): Promise<void>;
|
|
202
193
|
selectImage(item: IImage): void;
|
|
203
|
-
uploadError: (error: string) => Promise<void>;
|
|
194
|
+
uploadError: (error: boolean, msg?: string) => Promise<void>;
|
|
204
195
|
uploadImage: (imageFile: File, site: number | string) => Promise<IImage>;
|
|
205
196
|
}
|
|
206
197
|
|
|
@@ -213,4 +204,4 @@ const mapDispatchToProps = {
|
|
|
213
204
|
|
|
214
205
|
type IProps = IGalleryDragAndDropProps & IDispatchProps;
|
|
215
206
|
|
|
216
|
-
export default connect(mapStateToProps, mapDispatchToProps)(memo(GalleryDragAndDrop));
|
|
207
|
+
export default connect(mapStateToProps, mapDispatchToProps)(memo(GalleryDragAndDrop));
|
|
@@ -17,7 +17,7 @@ const itemsPerPage = 50;
|
|
|
17
17
|
const firstPage = 1;
|
|
18
18
|
|
|
19
19
|
const Gallery = (props: IProps): JSX.Element => {
|
|
20
|
-
const { data, isLoading, getSiteImages, selectImage, getImageSelected, toggleModal, site } = props;
|
|
20
|
+
const { data, isLoading, getSiteImages, selectImage, getImageSelected, toggleModal, site, uploadError } = props;
|
|
21
21
|
|
|
22
22
|
const tabs = [];
|
|
23
23
|
if (site) tabs.unshift(...["Local", "Global"]);
|
|
@@ -48,6 +48,7 @@ const Gallery = (props: IProps): JSX.Element => {
|
|
|
48
48
|
pageRef.current = getParams().page;
|
|
49
49
|
|
|
50
50
|
useEffect(() => {
|
|
51
|
+
uploadError(false);
|
|
51
52
|
const params = getParams();
|
|
52
53
|
getSiteImages({ ...params, page: firstPage });
|
|
53
54
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -220,11 +221,13 @@ const mapStateToProps = (state: IRootState) => ({
|
|
|
220
221
|
interface IDispatchProps {
|
|
221
222
|
getSiteImages(params: IGetSiteImages): Promise<void>;
|
|
222
223
|
selectImage(item: IImage): void;
|
|
224
|
+
uploadError: (error: boolean, msg?: string) => Promise<void>;
|
|
223
225
|
}
|
|
224
226
|
|
|
225
227
|
const mapDispatchToProps = {
|
|
226
228
|
getSiteImages: galleryActions.getSiteImages,
|
|
227
229
|
selectImage: galleryActions.selectImage,
|
|
230
|
+
uploadError: galleryActions.uploadError,
|
|
228
231
|
};
|
|
229
232
|
|
|
230
233
|
type IProps = IGalleryProps & IDispatchProps;
|
|
@@ -47,8 +47,8 @@ function setUploadSuccess(isSuccess: boolean): ISetUploadSuccess {
|
|
|
47
47
|
return { type: SET_UPLOAD_SUCCESS, payload: { isUploading: false, isSuccess } };
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function setUploadError(errorMsg = ""): ISetUploadError {
|
|
51
|
-
return { type: SET_UPLOAD_ERROR, payload: { inDropZone: false, isUploading: false, isError
|
|
50
|
+
function setUploadError(isError: boolean, errorMsg = ""): ISetUploadError {
|
|
51
|
+
return { type: SET_UPLOAD_ERROR, payload: { inDropZone: false, isUploading: false, isError, errorMsg } };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function getSiteImages(props: IGetSiteImages): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
|
|
@@ -110,7 +110,7 @@ function uploadImage(imageFile: File, site: number | string): (dispatch: Dispatc
|
|
|
110
110
|
// dispatch(setInDropZone(false));
|
|
111
111
|
return { ...result.data, file: image };
|
|
112
112
|
} else {
|
|
113
|
-
dispatch(setUploadError("Error uploading image"));
|
|
113
|
+
dispatch(setUploadError(true, "Error uploading image"));
|
|
114
114
|
}
|
|
115
115
|
} catch (e) {
|
|
116
116
|
console.log(e);
|
|
@@ -118,9 +118,9 @@ function uploadImage(imageFile: File, site: number | string): (dispatch: Dispatc
|
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
function uploadError(error: string): (dispatch: Dispatch) => Promise<void> {
|
|
121
|
+
function uploadError(error: boolean, msg?: string): (dispatch: Dispatch) => Promise<void> {
|
|
122
122
|
return async (dispatch) => {
|
|
123
|
-
dispatch(setUploadError(error));
|
|
123
|
+
dispatch(setUploadError(error, msg));
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
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;
|
|
@@ -4,8 +4,9 @@ export const Form = styled.div`
|
|
|
4
4
|
display: flex;
|
|
5
5
|
height: 100%;
|
|
6
6
|
width: 100%;
|
|
7
|
-
padding: ${(p) => p.theme.spacing.m};
|
|
7
|
+
padding: ${(p) => `${p.theme.spacing.m} ${p.theme.spacing.m} 0 ${p.theme.spacing.m}`};
|
|
8
8
|
flex-direction: column;
|
|
9
|
+
overflow: auto;
|
|
9
10
|
`;
|
|
10
11
|
|
|
11
12
|
export const FieldsWrapper = styled.div`
|