@antscorp/antsomi-ui 1.3.6-beta.4 → 1.3.6-beta.40
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/es/components/atoms/Input/Input.d.ts +11 -17
- package/es/components/atoms/Input/Input.js +7 -11
- package/es/components/atoms/SelectAssociatedTag/constants.d.ts +1 -1
- package/es/components/atoms/SelectAssociatedTag/constants.js +4 -4
- package/es/components/atoms/Switch/Switch.js +2 -1
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +3 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +3 -0
- package/es/components/icons/TaskAltIcon.d.ts +3 -0
- package/es/components/icons/TaskAltIcon.js +7 -0
- package/es/components/icons/UnsubscribeIcon.d.ts +3 -0
- package/es/components/icons/UnsubscribeIcon.js +7 -0
- package/es/components/icons/UnsubscribersIcon.d.ts +3 -0
- package/es/components/icons/UnsubscribersIcon.js +7 -0
- package/es/components/icons/index.d.ts +3 -0
- package/es/components/icons/index.js +3 -0
- package/es/components/molecules/CodeStructure/CodeStructure.d.ts +23 -2
- package/es/components/molecules/CodeStructure/CodeStructure.js +136 -26
- package/es/components/molecules/CodeStructure/constants.js +2 -2
- package/es/components/molecules/CodeStructure/styled.d.ts +3 -0
- package/es/components/molecules/CodeStructure/styled.js +6 -0
- package/es/components/molecules/CodeStructure/type.d.ts +2 -2
- package/es/components/molecules/CodeStructure/type.js +2 -2
- package/es/components/molecules/CodeStructure/utils.d.ts +12 -2
- package/es/components/molecules/CodeStructure/utils.js +5 -3
- package/es/components/molecules/DrawerDetail/DrawerDetail.js +10 -5
- package/es/components/molecules/DrawerDetail/types.d.ts +1 -0
- package/es/components/molecules/Dropdown/style.scss +6 -4
- package/es/components/molecules/EditingListV2/EditingList.js +5 -2
- package/es/components/molecules/EditingListV2/components/List/List.js +16 -6
- package/es/components/molecules/EditingListV2/components/Loadable.d.ts +0 -6
- package/es/components/molecules/EditingListV2/components/Loadable.js +0 -1
- package/es/components/molecules/EditingListV2/components/Popover/Popover.js +6 -12
- package/es/components/molecules/EditingListV2/components/index.d.ts +0 -3
- package/es/components/molecules/EditingListV2/components/index.js +0 -3
- package/es/components/molecules/EditingListV2/types.d.ts +2 -0
- package/es/components/molecules/InputSelectAttribute/index.js +5 -2
- package/es/components/molecules/InputSelectAttribute/styled.js +7 -2
- package/es/components/molecules/SearchPopover/SearchPopover.d.ts +0 -1
- package/es/components/molecules/SearchPopover/SearchPopover.js +1 -2
- package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.js +2 -2
- package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +2 -2
- package/es/components/molecules/SearchPopover/types.d.ts +1 -0
- package/es/components/molecules/TagifyInput/TagifyInput.js +27 -10
- package/es/components/molecules/TagifyInput/constants.d.ts +2 -1
- package/es/components/molecules/TagifyInput/constants.js +2 -1
- package/es/components/molecules/TagifyInput/utils.js +5 -2
- package/es/components/molecules/TagifyInput/utils.style.js +3 -2
- package/es/components/molecules/UploadImage/index.d.ts +102 -3
- package/es/components/molecules/UploadImage/index.js +48 -110
- package/es/components/molecules/UploadImage/styled.d.ts +2 -1
- package/es/components/molecules/VirtualizedMenu/types.d.ts +1 -0
- package/es/components/organism/TicketEditorV2/Content.d.ts +27 -0
- package/es/components/organism/TicketEditorV2/Content.js +296 -0
- package/es/components/organism/TicketEditorV2/Service.d.ts +49 -0
- package/es/components/organism/TicketEditorV2/Service.js +58 -0
- package/es/components/organism/TicketEditorV2/TicketEditorV2.d.ts +20 -0
- package/es/components/organism/TicketEditorV2/TicketEditorV2.js +124 -0
- package/es/components/organism/TicketEditorV2/components/DropdownComponent.d.ts +9 -0
- package/es/components/organism/TicketEditorV2/components/DropdownComponent.js +45 -0
- package/es/components/organism/TicketEditorV2/components/Message.d.ts +2 -0
- package/es/components/organism/TicketEditorV2/components/Message.js +31 -0
- package/es/components/organism/TicketEditorV2/components/MessageComponent.d.ts +10 -0
- package/es/components/organism/TicketEditorV2/components/MessageComponent.js +64 -0
- package/es/components/organism/TicketEditorV2/components/icons/AddTicketIcon.d.ts +2 -0
- package/es/components/organism/TicketEditorV2/components/icons/AddTicketIcon.js +5 -0
- package/es/components/organism/TicketEditorV2/components/icons/TicketIcon.d.ts +2 -0
- package/es/components/organism/TicketEditorV2/components/icons/TicketIcon.js +5 -0
- package/es/components/organism/TicketEditorV2/constant.d.ts +17 -0
- package/es/components/organism/TicketEditorV2/constant.js +17 -0
- package/es/components/organism/TicketEditorV2/constants/index.d.ts +1 -0
- package/es/components/organism/TicketEditorV2/constants/index.js +1 -0
- package/es/components/organism/TicketEditorV2/constants/queryKeys.d.ts +5 -0
- package/es/components/organism/TicketEditorV2/constants/queryKeys.js +5 -0
- package/es/components/organism/TicketEditorV2/index.d.ts +1 -0
- package/es/components/organism/TicketEditorV2/index.js +1 -0
- package/es/components/organism/TicketEditorV2/queries/index.d.ts +3 -0
- package/es/components/organism/TicketEditorV2/queries/index.js +3 -0
- package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.d.ts +12 -0
- package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.js +14 -0
- package/es/components/organism/TicketEditorV2/queries/useGetListComments.d.ts +13 -0
- package/es/components/organism/TicketEditorV2/queries/useGetListComments.js +18 -0
- package/es/components/organism/TicketEditorV2/queries/useGetListUser.d.ts +11 -0
- package/es/components/organism/TicketEditorV2/queries/useGetListUser.js +14 -0
- package/es/components/organism/TicketEditorV2/styled.d.ts +54 -0
- package/es/components/organism/TicketEditorV2/styled.js +871 -0
- package/es/components/organism/TicketEditorV2/util.d.ts +46 -0
- package/es/components/organism/TicketEditorV2/util.js +408 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/constants/queries.d.ts +1 -0
- package/es/constants/queries.js +1 -0
- package/es/locales/en/translation.json +2 -1
- package/es/locales/i18n.d.ts +2 -0
- package/es/locales/vi/translation.json +2 -1
- package/es/queries/ThirdParty/index.d.ts +1 -0
- package/es/queries/ThirdParty/index.js +1 -0
- package/es/queries/ThirdParty/useStoreSavedMedia.d.ts +1 -0
- package/es/queries/ThirdParty/useStoreSavedMedia.js +12 -0
- package/es/queries/index.d.ts +0 -1
- package/es/queries/index.js +0 -1
- package/es/services/MediaTemplateDesign/UploadFile/index.d.ts +1 -1
- package/es/services/MediaTemplateDesign/UploadFile/index.js +2 -2
- package/package.json +2 -2
- package/es/components/molecules/EditingListV2/components/Action/Action.d.ts +0 -6
- package/es/components/molecules/EditingListV2/components/Action/Action.js +0 -10
- package/es/components/molecules/EditingListV2/components/Action/index.d.ts +0 -1
- package/es/components/molecules/EditingListV2/components/Action/index.js +0 -1
- package/es/components/molecules/EditingListV2/components/Search/Search.d.ts +0 -4
- package/es/components/molecules/EditingListV2/components/Search/Search.js +0 -8
- package/es/components/molecules/EditingListV2/components/Search/index.d.ts +0 -1
- package/es/components/molecules/EditingListV2/components/Search/index.js +0 -1
- package/es/components/molecules/EditingListV2/components/Title/Title.d.ts +0 -9
- package/es/components/molecules/EditingListV2/components/Title/Title.js +0 -16
- package/es/components/molecules/EditingListV2/components/Title/index.d.ts +0 -1
- package/es/components/molecules/EditingListV2/components/Title/index.js +0 -1
- package/es/components/molecules/EditingListV2/styled.d.ts +0 -5
- package/es/components/molecules/EditingListV2/styled.js +0 -38
- package/es/components/molecules/SearchPopover/styles.scss +0 -7
- package/es/queries/Media/index.d.ts +0 -1
- package/es/queries/Media/index.js +0 -1
- package/es/queries/Media/useGetListingSavedMedia.d.ts +0 -12
- package/es/queries/Media/useGetListingSavedMedia.js +0 -15
|
@@ -1,35 +1,134 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UploadProps as AntdUploadProps } from 'antd/lib/upload';
|
|
3
3
|
export type MediaMode = 'image' | 'video';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Props for the UploadImage component.
|
|
6
|
+
*/
|
|
7
|
+
export interface UploadImageProps extends AntdUploadProps {
|
|
8
|
+
/**
|
|
9
|
+
* Heading text for the image upload modal.
|
|
10
|
+
* @default "Image Selection"
|
|
11
|
+
*/
|
|
5
12
|
labelHeadingModal?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Label for the button used to select an image.
|
|
15
|
+
* @default "Select Image from computer"
|
|
16
|
+
*/
|
|
6
17
|
labelButtonSelect?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Label for the modal confirming image deletion.
|
|
20
|
+
* @default "Delete Image"
|
|
21
|
+
*/
|
|
7
22
|
labelModalDelete?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Placeholder text for the search input inside the modal.
|
|
25
|
+
* @default "Search image..."
|
|
26
|
+
*/
|
|
8
27
|
searchPlaceholder?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Callback triggered when an image is removed.
|
|
30
|
+
*/
|
|
9
31
|
onRemoveImage?: Function;
|
|
32
|
+
/**
|
|
33
|
+
* Callback triggered when an image is selected or changed.
|
|
34
|
+
*/
|
|
10
35
|
onChangeImage?: Function;
|
|
36
|
+
/**
|
|
37
|
+
* The currently selected image object.
|
|
38
|
+
*/
|
|
11
39
|
selectedImage?: UploadMediaObject;
|
|
40
|
+
/**
|
|
41
|
+
* Controls the visibility of the image upload modal.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
12
44
|
isOpen?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Determines if the component should operate in input mode.
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
13
49
|
isInputMode?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Name of the icon to be displayed.
|
|
52
|
+
* @default "image-3"
|
|
53
|
+
*/
|
|
14
54
|
iconName?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Mode in which the media should be handled.
|
|
57
|
+
* @default "image"
|
|
58
|
+
*/
|
|
15
59
|
mode?: MediaMode;
|
|
16
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Width of the upload component.
|
|
62
|
+
* @default "100%"
|
|
63
|
+
*/
|
|
64
|
+
width?: string | number;
|
|
65
|
+
/**
|
|
66
|
+
* List of validation errors related to the upload.
|
|
67
|
+
* @default []
|
|
68
|
+
*/
|
|
17
69
|
errors?: Array<any>;
|
|
70
|
+
/**
|
|
71
|
+
* Allowed file extensions for the upload.
|
|
72
|
+
* @default [".jpg", ".png", ".jfif", ".jpeg", ".gif", ".webp"]
|
|
73
|
+
*/
|
|
18
74
|
extensions?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Maximum file size allowed for upload (in MB).
|
|
77
|
+
* @default 10
|
|
78
|
+
*/
|
|
19
79
|
maxSize?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Title text for the upload section.
|
|
82
|
+
*/
|
|
20
83
|
title?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Whether to display the image URL after upload.
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
21
88
|
showImageURL?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Placeholder text for the upload input field.
|
|
91
|
+
* @default "Enter image URL"
|
|
92
|
+
*/
|
|
22
93
|
placeholder?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Domain-specific media folder or endpoint.
|
|
96
|
+
* @default "https://sandbox-media-template.antsomi.com/cdp"
|
|
97
|
+
*/
|
|
23
98
|
domainMedia: string;
|
|
99
|
+
/**
|
|
100
|
+
* Unique slug identifier for media categorization.
|
|
101
|
+
* @default "api/v1"
|
|
102
|
+
*/
|
|
24
103
|
slug: string;
|
|
104
|
+
/**
|
|
105
|
+
* Configuration parameters for API requests.
|
|
106
|
+
*/
|
|
25
107
|
paramConfigs?: {
|
|
108
|
+
/**
|
|
109
|
+
* Authentication token for media uploads.
|
|
110
|
+
* @default ""
|
|
111
|
+
*/
|
|
26
112
|
token?: string;
|
|
113
|
+
/**
|
|
114
|
+
* User identifier for media ownership.
|
|
115
|
+
* @default ""
|
|
116
|
+
*/
|
|
27
117
|
userId?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Account identifier for media association.
|
|
120
|
+
* @default ""
|
|
121
|
+
*/
|
|
28
122
|
accountId: string;
|
|
29
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Whether the image upload is required.
|
|
126
|
+
*/
|
|
30
127
|
required?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Indicates if the input is currently focused.
|
|
130
|
+
*/
|
|
31
131
|
focused?: boolean;
|
|
32
|
-
useSync?: boolean;
|
|
33
132
|
}
|
|
34
133
|
interface UploadMediaObject {
|
|
35
134
|
url: string;
|
|
@@ -3,15 +3,19 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
4
4
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
5
5
|
// Libraries
|
|
6
|
-
import {
|
|
6
|
+
import { useEffect, useState, useRef, useMemo } from 'react';
|
|
7
7
|
import Upload from 'antd/lib/upload';
|
|
8
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
9
|
+
import { cloneDeep, flattenDeep } from 'lodash';
|
|
10
|
+
import { useInView } from 'react-intersection-observer';
|
|
8
11
|
// Hooks
|
|
9
|
-
import {
|
|
12
|
+
import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounce';
|
|
13
|
+
import { useStoreSavedMedia } from '@antscorp/antsomi-ui/es/queries';
|
|
10
14
|
// Assets
|
|
11
15
|
import PlaceholderImage from '@antscorp/antsomi-ui/es/assets/images/placeholder-image.png';
|
|
12
16
|
import MediaIcon from './MediaIcon';
|
|
13
17
|
// Service
|
|
14
|
-
import { uploadFile, createSavedMedia, deleteSavedMedia,
|
|
18
|
+
import { uploadFile, createSavedMedia, deleteSavedMedia, } from '@antscorp/antsomi-ui/es/services/MediaTemplateDesign/UploadFile';
|
|
15
19
|
// Atoms
|
|
16
20
|
import { Button, Icon, Text, message, Spin, Input, Space, } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
17
21
|
// Molecules
|
|
@@ -19,11 +23,10 @@ import { Modal, InputSearch, Select } from '@antscorp/antsomi-ui/es/components/m
|
|
|
19
23
|
// Styled
|
|
20
24
|
import { Boxed, ErrorMessage, Image, Overlay, Paragraph, TextStyled, UploadImageWrapper, WrapperBtn, WrapperIcon, WrapperInputMode, WrapperListImages, } from './styled';
|
|
21
25
|
// Utils
|
|
22
|
-
import {
|
|
26
|
+
import { safeParse } from '@antscorp/antsomi-ui/es/utils';
|
|
23
27
|
import { getMediaTypeByMode, getReplacementExtension } from './utils';
|
|
24
28
|
// Constants
|
|
25
|
-
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
26
|
-
import { useGetListingSavedMedia } from '@antscorp/antsomi-ui/es/queries/Media';
|
|
29
|
+
import { QUERY_KEYS, THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
27
30
|
const flexStyleCenter = {
|
|
28
31
|
display: 'flex',
|
|
29
32
|
gap: '15px',
|
|
@@ -40,111 +43,45 @@ const SORT_OPTIONS = {
|
|
|
40
43
|
label: 'Sort by Size',
|
|
41
44
|
},
|
|
42
45
|
};
|
|
43
|
-
const POST_TRIGGER_CHANGE_SAVED_MEDIA = 'upload-image-refresh-saved-media';
|
|
44
|
-
const LazyThumbnail = lazy(() => import('./MediaThumb'));
|
|
45
|
-
const PATH = '@antscorp/antsomi-ui/es/components/molecules/UploadImage/index.tsx';
|
|
46
46
|
export const UploadImage = props => {
|
|
47
|
-
const { labelHeadingModal, labelButtonSelect, labelModalDelete, searchPlaceholder, onRemoveImage, onChangeImage: onChangeMedia, isOpen, isInputMode, width, placeholder, extensions, maxSize, title, showImageURL: showMediaURL, selectedImage: selectedMediaProp, required, focused, domainMedia, slug, paramConfigs, errors, iconName, mode,
|
|
47
|
+
const { labelHeadingModal, labelButtonSelect, labelModalDelete, searchPlaceholder, onRemoveImage, onChangeImage: onChangeMedia, isOpen, isInputMode, width, placeholder, extensions, maxSize, title, showImageURL: showMediaURL, selectedImage: selectedMediaProp, required, focused, domainMedia, slug, paramConfigs, errors, iconName, mode, } = props;
|
|
48
48
|
const { Dragger } = Upload;
|
|
49
|
-
const [storeSavedMedia, setStoreSavedMedia] = useState([]);
|
|
50
49
|
const [selectedMedia, setSelectedMedia] = useState(selectedMediaProp || { url: '' });
|
|
51
50
|
const [isModalOpen, setIsModalOpen] = useState(isOpen);
|
|
52
|
-
const [
|
|
51
|
+
const [textSearchDebounce, textSearch, setTextSearch] = useDebounce('', 350);
|
|
53
52
|
const [sortOption, setSortOption] = useState(SORT_OPTIONS.BY_UPLOAD_DATE.value);
|
|
54
53
|
const [loading, setLoading] = useState(false);
|
|
55
54
|
const [isOpenConfirmDelete, setOpenConfirmDelete] = useState(false);
|
|
56
|
-
const [triggerRefresh, setTriggerRefresh] = useState(1);
|
|
57
55
|
const uploadFilesRef = useRef([]);
|
|
58
56
|
const uploadFilesTimeoutRef = useRef();
|
|
59
57
|
const deleteMediaRef = useRef();
|
|
60
58
|
const isError = safeParse(errors, []).length > 0;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
const queryClient = useQueryClient();
|
|
60
|
+
const paramsMemo = useMemo(() => ({
|
|
61
|
+
...paramConfigs,
|
|
62
|
+
type: getMediaTypeByMode(mode),
|
|
63
|
+
}), [paramConfigs, mode]);
|
|
64
|
+
const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading: isLoadingStore, refetch, } = useStoreSavedMedia(domainMedia, slug, paramsMemo);
|
|
65
|
+
const flattenedMedia = useMemo(() => {
|
|
66
|
+
const flattened = cloneDeep(flattenDeep(data?.pages));
|
|
67
|
+
// Filter media based on search text
|
|
68
|
+
const filteredMedia = textSearchDebounce
|
|
69
|
+
? flattened.filter(media => media.name?.toLowerCase().includes(textSearchDebounce.toLowerCase()))
|
|
70
|
+
: flattened;
|
|
71
|
+
// Sort media based on the selected sort option
|
|
72
|
+
if (sortOption === SORT_OPTIONS.BY_SIZE.value) {
|
|
73
|
+
return filteredMedia.sort((media1, media2) => media1.size - media2.size);
|
|
73
74
|
}
|
|
74
|
-
return () =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, []);
|
|
75
|
+
return filteredMedia.sort((media1, media2) => media1.createdAt && media2.createdAt
|
|
76
|
+
? media1.createdAt.isAfter(media2.createdAt)
|
|
77
|
+
? -1
|
|
78
|
+
: 1
|
|
79
|
+
: 0);
|
|
80
|
+
}, [data?.pages, sortOption, textSearchDebounce]);
|
|
80
81
|
// When selectedMediaProp onChange
|
|
81
82
|
useEffect(() => {
|
|
82
83
|
setSelectedMedia(selectedMediaProp || { url: '' });
|
|
83
84
|
}, [selectedMediaProp]);
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
if (sortOption === SORT_OPTIONS.BY_SIZE.value) {
|
|
86
|
-
setListMedia(listMedia ? [...listMedia].sort((media1, media2) => media1.size - media2.size) : []);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
setListMedia(listMedia
|
|
90
|
-
? [...listMedia].sort((media1, media2) => media1.createdAt && media2.createdAt
|
|
91
|
-
? media1.createdAt.isAfter(media2.createdAt)
|
|
92
|
-
? -1
|
|
93
|
-
: 1
|
|
94
|
-
: 0)
|
|
95
|
-
: []);
|
|
96
|
-
}
|
|
97
|
-
}, [sortOption]);
|
|
98
|
-
const handleGetStoreSavedMedia = async (domain, slug, paramConfigs) => {
|
|
99
|
-
try {
|
|
100
|
-
setLoading(true);
|
|
101
|
-
const type = getMediaTypeByMode(mode);
|
|
102
|
-
const params = {
|
|
103
|
-
...paramConfigs,
|
|
104
|
-
type,
|
|
105
|
-
};
|
|
106
|
-
const result = await getListingSavedMedia(domain, slug, params);
|
|
107
|
-
if (result) {
|
|
108
|
-
setStoreSavedMedia(result || []);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
handleError(error, {
|
|
113
|
-
path: PATH,
|
|
114
|
-
name: 'handleGetStoreSavedMedia',
|
|
115
|
-
args: {
|
|
116
|
-
error,
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
// eslint-disable-next-line no-console
|
|
120
|
-
console.log('error :>', error);
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
setLoading(false);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
const { data: savedMedias, isLoading } = useGetListingSavedMedia({
|
|
127
|
-
domain: domainMedia,
|
|
128
|
-
slug,
|
|
129
|
-
params: {
|
|
130
|
-
...paramConfigs,
|
|
131
|
-
type: getMediaTypeByMode(mode),
|
|
132
|
-
},
|
|
133
|
-
refresh: triggerRefresh,
|
|
134
|
-
});
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (savedMedias) {
|
|
137
|
-
setStoreSavedMedia(savedMedias || []);
|
|
138
|
-
}
|
|
139
|
-
}, [savedMedias]);
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
if (useSync) {
|
|
142
|
-
window.postMessage({
|
|
143
|
-
type: POST_TRIGGER_CHANGE_SAVED_MEDIA,
|
|
144
|
-
triggerRefresh,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}, [triggerRefresh]);
|
|
148
85
|
const showModal = (e) => {
|
|
149
86
|
e.stopPropagation();
|
|
150
87
|
setIsModalOpen(true);
|
|
@@ -162,6 +99,14 @@ export const UploadImage = props => {
|
|
|
162
99
|
const onChangeSort = (option) => {
|
|
163
100
|
setSortOption(option);
|
|
164
101
|
};
|
|
102
|
+
const { ref } = useInView({
|
|
103
|
+
triggerOnce: false,
|
|
104
|
+
onChange: inView => {
|
|
105
|
+
if (inView && hasNextPage && !isFetchingNextPage) {
|
|
106
|
+
fetchNextPage();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
});
|
|
165
110
|
const renderListMedia = (listMediaRender) => listMediaRender.map((media, idx) => (_jsxs(WrapperListImages, { className: "ants-group", children: [_jsxs(Boxed, { children: [_jsx(Image, { src: mode === 'video' ? media.thumbnail : media.url, alt: "img", loading: "lazy" }), _jsxs(WrapperBtn, { className: "group-hover", children: [_jsx(Button, { onClick: () => handleSelectMedia(media), style: { backgroundColor: 'rgb(255,255,255)' }, children: "USE" }), _jsx(Button, { onClick: () => handleRemoveUploadedMedia(media), style: { backgroundColor: 'rgb(255,255,255)' }, children: _jsx(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: THEME.token?.colorPrimary } }) })] }), _jsx(Overlay, { className: "group-hover" })] }), _jsx(Paragraph, { style: {
|
|
166
111
|
overflow: 'hidden',
|
|
167
112
|
textOverflow: 'ellipsis',
|
|
@@ -171,16 +116,7 @@ export const UploadImage = props => {
|
|
|
171
116
|
}, title: media.name, children: media.name }), _jsxs(Paragraph, { children: ["Uploaded: ", media.createdAt.format('DD/MM/YYYY'), " at ", media.createdAt.format('hh:mm:ss A')] }), _jsxs(Paragraph, { children: ["Size: ", media.sizeString] })] }, idx)));
|
|
172
117
|
const onChangeSearchImage = (e) => {
|
|
173
118
|
const { value } = e.target;
|
|
174
|
-
|
|
175
|
-
setListMedia(storeSavedMedia
|
|
176
|
-
? storeSavedMedia
|
|
177
|
-
.filter(item => item.name.toLocaleLowerCase().includes(value.trim().toLocaleLowerCase()))
|
|
178
|
-
.slice(0, 15)
|
|
179
|
-
: []);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
setListMedia(storeSavedMedia);
|
|
183
|
-
}
|
|
119
|
+
setTextSearch(value.trim());
|
|
184
120
|
};
|
|
185
121
|
const handleRemoveMedia = () => {
|
|
186
122
|
if (onRemoveImage) {
|
|
@@ -198,7 +134,9 @@ export const UploadImage = props => {
|
|
|
198
134
|
if (res && res.data && res.data.code === 200 && res.data.data) {
|
|
199
135
|
const { success_media = [] } = res.data.data;
|
|
200
136
|
if (Array.isArray(success_media) && success_media.length) {
|
|
201
|
-
|
|
137
|
+
queryClient.invalidateQueries([QUERY_KEYS.GET_LIST_SAVED_MEDIA, domainMedia, slug, paramsMemo], {
|
|
138
|
+
exact: false,
|
|
139
|
+
});
|
|
202
140
|
}
|
|
203
141
|
}
|
|
204
142
|
setOpenConfirmDelete(false);
|
|
@@ -272,7 +210,7 @@ export const UploadImage = props => {
|
|
|
272
210
|
})));
|
|
273
211
|
await Promise.all(arrPromise);
|
|
274
212
|
setLoading(false);
|
|
275
|
-
|
|
213
|
+
refetch({ refetchPage: (_page, index) => index === 0 });
|
|
276
214
|
}
|
|
277
215
|
else {
|
|
278
216
|
setLoading(false);
|
|
@@ -316,7 +254,7 @@ export const UploadImage = props => {
|
|
|
316
254
|
justifyContent: 'space-between',
|
|
317
255
|
alignItems: 'center',
|
|
318
256
|
marginBottom: 20,
|
|
319
|
-
}, children: [_jsx(InputSearch, { style: { width: 232 }, onChange: onChangeSearchImage, placeholder: searchPlaceholder }), _jsx(Select, { defaultValue: SORT_OPTIONS.BY_UPLOAD_DATE.value, value: sortOption, options: Object.values(SORT_OPTIONS), style: { width: 232 }, onChange: onChangeSort })] }), _jsx(Spin, { spinning: loading ||
|
|
257
|
+
}, children: [_jsx(InputSearch, { value: textSearch, style: { width: 232 }, onChange: onChangeSearchImage, placeholder: searchPlaceholder }), _jsx(Select, { defaultValue: SORT_OPTIONS.BY_UPLOAD_DATE.value, value: sortOption, options: Object.values(SORT_OPTIONS), style: { width: 232 }, onChange: onChangeSort })] }), _jsx(Spin, { spinning: loading || isFetchingNextPage || isLoadingStore, children: _jsx(Dragger, { ...props, accept: extensions?.join(','),
|
|
320
258
|
// action={`${APP_CONFIG.API_URL}/file-upload/file?&_token=${userInfo?.token}&_user_id=${userInfo?.user_id}&_account_id=${userInfo?.account_id}`}
|
|
321
259
|
// beforeUpload={handleBeforeUploadFile}
|
|
322
260
|
// onChange={onChangeFileUpload}
|
|
@@ -326,13 +264,13 @@ export const UploadImage = props => {
|
|
|
326
264
|
}, children: [_jsx(Icon, { type: `icon-ants-${iconName}`, size: 36, style: { color: THEME.token?.colorIcon } }), _jsxs("div", { style: { ...flexStyleCenter, justifyContent: 'flex-start' }, children: [_jsx(TextStyled, { className: "ant-upload-text", children: "Drag & Drop file here" }), _jsx("span", { children: "or" }), _jsx(Button, { style: { backgroundColor: '#ffffff' }, children: labelButtonSelect }), _jsx(Button, { onClick: handleRemoveMedia, style: {
|
|
327
265
|
display: 'none !important',
|
|
328
266
|
backgroundColor: '#ffffff',
|
|
329
|
-
}, children: _jsx(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: THEME.token?.colorPrimary } }) })] })] }) }) }),
|
|
267
|
+
}, children: _jsx(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: THEME.token?.colorPrimary } }) })] })] }) }) }), _jsxs("div", { style: {
|
|
330
268
|
display: 'flex',
|
|
331
269
|
flexWrap: 'wrap',
|
|
332
270
|
gap: '35px',
|
|
333
271
|
paddingTop: 20,
|
|
334
272
|
width: '100%',
|
|
335
|
-
}, children: renderListMedia(
|
|
273
|
+
}, children: [renderListMedia(flattenedMedia), _jsx("div", { ref: ref })] })] })] }));
|
|
336
274
|
};
|
|
337
275
|
UploadImage.defaultProps = {
|
|
338
276
|
isOpen: false,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
1
2
|
export declare const WrapperListImages: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
3
|
export declare const TextStyled: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
3
4
|
export declare const Boxed: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -6,7 +7,7 @@ export declare const WrapperBtn: import("styled-components").StyledComponent<"di
|
|
|
6
7
|
export declare const Paragraph: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
7
8
|
export declare const Overlay: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
9
|
export declare const WrapperInputMode: import("styled-components").StyledComponent<"div", any, {
|
|
9
|
-
width?:
|
|
10
|
+
width?: CSSProperties['width'];
|
|
10
11
|
}, never>;
|
|
11
12
|
export declare const WrapperIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
13
|
export declare const ErrorMessage: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const Content: ({ apiKey, domain, portalId, token, action, ticketId, listUsers, domainTicket, config, ticketDetails, listComment, userId, fetchgetTicketComments, isLoadingComment, isLoadingDetails, isLoadingDataSouce, accountManage, timeZone, isLoadingSelectedAccount, accountEdit, initOwnerId, isAllAccount, dataSelectInput, setDataSelectInput, }: {
|
|
2
|
+
apiKey: any;
|
|
3
|
+
domain: any;
|
|
4
|
+
portalId: any;
|
|
5
|
+
token: any;
|
|
6
|
+
action: any;
|
|
7
|
+
ticketId: any;
|
|
8
|
+
listUsers: any;
|
|
9
|
+
domainTicket: any;
|
|
10
|
+
config: any;
|
|
11
|
+
ticketDetails: any;
|
|
12
|
+
listComment: any;
|
|
13
|
+
userId: any;
|
|
14
|
+
fetchgetTicketComments: any;
|
|
15
|
+
isLoadingComment: any;
|
|
16
|
+
isLoadingDetails: any;
|
|
17
|
+
isLoadingDataSouce: any;
|
|
18
|
+
accountManage: any;
|
|
19
|
+
timeZone: any;
|
|
20
|
+
isLoadingSelectedAccount: any;
|
|
21
|
+
accountEdit: any;
|
|
22
|
+
initOwnerId: any;
|
|
23
|
+
isAllAccount: any;
|
|
24
|
+
dataSelectInput: any;
|
|
25
|
+
setDataSelectInput: any;
|
|
26
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export default Content;
|