From 9274020aea13394ecf18ebc5320de4f96c675128 Mon Sep 17 00:00:00 2001 From: butschster Date: Sun, 5 May 2024 11:03:22 +0400 Subject: [PATCH] Refactors SMTP attachments fetching from HTTP endpoint --- pages/smtp/[id].vue | 18 ++++++-- src/entities/smtp/lib/use-smtp.ts | 11 +++-- src/screens/smtp/ui/smtp-page/smtp-page.vue | 30 ++++++-------- src/shared/lib/io/index.ts | 1 + src/shared/lib/io/use-smtp-requests.ts | 41 +++++++++++++++++++ src/shared/lib/use-smtp/index.ts | 1 + src/shared/lib/use-smtp/use-smtp-api.ts | 16 ++++++++ src/shared/types/events.ts | 9 ++++ .../ui/file-attachment/file-attachment.vue | 2 +- 9 files changed, 105 insertions(+), 24 deletions(-) create mode 100644 src/shared/lib/io/use-smtp-requests.ts create mode 100644 src/shared/lib/use-smtp/index.ts create mode 100644 src/shared/lib/use-smtp/use-smtp-api.ts diff --git a/pages/smtp/[id].vue b/pages/smtp/[id].vue index 6781dba3..36791bea 100644 --- a/pages/smtp/[id].vue +++ b/pages/smtp/[id].vue @@ -7,7 +7,7 @@ import { useSmtp } from "~/src/entities/smtp"; import type { SMTP } from "~/src/entities/smtp/types"; import { REST_API_URL } from "~/src/shared/lib/io"; import { useEvents } from "~/src/shared/lib/use-events"; -import type { EventId, ServerEvent } from "~/src/shared/types"; +import type { Attachment, EventId, ServerEvent } from "~/src/shared/types"; const { normalizeSmtpEvent } = useSmtp(); @@ -21,9 +21,10 @@ useHead({ }); const { events } = useEvents(); - +const { smtp } = useSmtp(); const isLoading = ref(false); const serverEvent = ref(null); +const serverAttachments = ref([]); const event = computed(() => serverEvent.value @@ -31,6 +32,8 @@ const event = computed(() => : null ); +const attachments = computed(() => serverAttachments.value); + const html = computed( () => `