diff --git a/frontend/components/global/FileInput.vue b/frontend/components/global/FileInput.vue index a2a0910..e0e3beb 100644 --- a/frontend/components/global/FileInput.vue +++ b/frontend/components/global/FileInput.vue @@ -6,11 +6,19 @@ import { useToast } from "~/composables/global/useToast"; // types type Props = { - modelValue: File[]; + modelValue: { + id: number; + file_link: string; + date: string; + size: number; + name: string; + }[]; + loading?: boolean; }; type Emits = { "update:modelValue": [value: any]; + change: [value: File]; }; // props @@ -50,7 +58,8 @@ const onDrop = (files: File[] | null) => { } else { if (modelValue.value.length + files.length <= 3) { files?.forEach((item) => { - emit("update:modelValue", [...modelValue.value, item]); + emit("change", item); + resetFileDialog(); }); } else { addToast({ @@ -78,22 +87,27 @@ const { isOverDropZone } = useDropZone(dropZoneRef, { dataTypes: ["image/jpeg", "image/png", "image/jpg"], }); -const { open: openDialog, onChange } = useFileDialog({ +const { + open: openDialog, + onChange, + reset: resetFileDialog, +} = useFileDialog({ accept: "image/*", directory: false, }); onChange((files: any) => { let arr: File[] = []; - Object.keys(files).forEach((item) => { - arr.push(files[item]); + Object.keys(files).forEach((_, index) => { + arr.push(files[index]); }); onDrop(arr); }); -const deleteFile = (index: number) => { +const removeAttachment = (id: number) => { + let target = modelValue.value.findIndex((i) => i.id == id); const clone = [...modelValue.value]; - clone.splice(index, 1); + clone.splice(target, 1); emit("update:modelValue", clone); }; @@ -103,10 +117,22 @@ const deleteFile = (index: number) => {
- +

برای آپلود کلیک کنید یا فایل خود را اینجا بیاندازید

@@ -121,24 +147,12 @@ const deleteFile = (index: number) => { v-auto-animate class="flex flex-row-reverse items-center justify-between w-full px-2 animate__animated animate__fadeIn" > -
  • -
    -

    {{ item.name }}

    -
    -
    -

    - {{ (item.size / 1024).toFixed(2) }}KB -

    -
    -
    - -
    -
  • +
    diff --git a/frontend/components/global/ToastContainer/ToastBox.vue b/frontend/components/global/ToastContainer/ToastBox.vue index d12d88e..40db762 100644 --- a/frontend/components/global/ToastContainer/ToastBox.vue +++ b/frontend/components/global/ToastContainer/ToastBox.vue @@ -1,5 +1,4 @@ \ No newline at end of file + diff --git a/frontend/components/global/product-detail/Slider.vue b/frontend/components/global/product-detail/Slider.vue index e1110d2..41d0e00 100644 --- a/frontend/components/global/product-detail/Slider.vue +++ b/frontend/components/global/product-detail/Slider.vue @@ -1,11 +1,10 @@ \ No newline at end of file + diff --git a/frontend/components/product/ChatBox/ChatBoxContainer.vue b/frontend/components/product/ChatBox/ChatBoxContainer.vue index cedb98c..91eafa5 100644 --- a/frontend/components/product/ChatBox/ChatBoxContainer.vue +++ b/frontend/components/product/ChatBox/ChatBoxContainer.vue @@ -29,17 +29,17 @@ const { isPending: isChatPending, isFetchingNextPage: isNextChatPagePending, hasNextPage: hasMoreChat, - fetchNextPage: loadMoreChat + fetchNextPage: loadMoreChat, } = useGetChat(id, isOpen); const isCreateMessagePending = useIsMutating({ - mutationKey: [MUTATION_KEYS.create_chat] + mutationKey: [MUTATION_KEYS.create_chat], }); const canLoadMoreChat = ref(false); const isChatScrollLocked = useScrollLock(chatContainerEl); const { y: chatContainerScrollY } = useScroll(chatContainerEl, { - behavior: "smooth" + behavior: "smooth", }); useInfiniteScroll( @@ -56,11 +56,11 @@ useInfiniteScroll( distance: 10, direction: "top", throttle: 1000, - canLoadMore: () => canLoadMoreChat.value + canLoadMore: () => canLoadMoreChat.value, } ); -// method +// methods const scrollToBottom = () => { chatContainerScrollY.value = chatContainerEl.value?.scrollHeight ?? 0; @@ -116,7 +116,7 @@ whenever( }, 2000); }, { - once: true + once: true, } ); @@ -131,16 +131,15 @@ whenever( -
    +
    Please sign in first
    diff --git a/frontend/components/product/ChatBox/ChatButton.vue b/frontend/components/product/ChatBox/ChatButton.vue index 22ab002..114b7c2 100644 --- a/frontend/components/product/ChatBox/ChatButton.vue +++ b/frontend/components/product/ChatBox/ChatButton.vue @@ -1,24 +1,21 @@ diff --git a/frontend/components/product/ChatBox/ChatInput.vue b/frontend/components/product/ChatBox/ChatInput.vue index 69cfea4..d59a17c 100644 --- a/frontend/components/product/ChatBox/ChatInput.vue +++ b/frontend/components/product/ChatBox/ChatInput.vue @@ -1,5 +1,4 @@ @@ -303,4 +316,4 @@ const sendMessage = async () => { transform: translate(-50%, -50%) rotate(443deg); } } - \ No newline at end of file + diff --git a/frontend/components/product/ChatBox/ChatMessage.vue b/frontend/components/product/ChatBox/ChatMessage.vue index c142dce..97ecf3b 100644 --- a/frontend/components/product/ChatBox/ChatMessage.vue +++ b/frontend/components/product/ChatBox/ChatMessage.vue @@ -1,14 +1,13 @@ \ No newline at end of file + diff --git a/frontend/components/product/ProductComments.vue b/frontend/components/product/ProductComments.vue index 2d38b65..1b0bcd8 100644 --- a/frontend/components/product/ProductComments.vue +++ b/frontend/components/product/ProductComments.vue @@ -1,5 +1,4 @@