Skip to content

Commit 5cfa9d1

Browse files
authored
Merge pull request #147 from buggregator/bugfix/update-types
Bugfix/update types
2 parents 7fa65aa + f95b52f commit 5cfa9d1

File tree

12 files changed

+54
-81
lines changed

12 files changed

+54
-81
lines changed

.eslintrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"package.json",
2020
"postcss.config.js",
2121
"tailwind.config.js",
22-
"src/shared/lib/vendor/",
23-
"src/.eslintrc.json"
22+
"src/shared/lib/vendor/"
2423
],
2524
"parserOptions": {
2625
"project": "./tsconfig.json",

nuxt.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ export default defineNuxtConfig({
3232
dir: {
3333
static: 'src/static',
3434
},
35-
imports: {
36-
dirs: [
37-
'composables/**'
38-
]
39-
},
4035
postcss: {
4136
plugins: {
4237
tailwindcss: {},

pages/smtp/[id].vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ useHead({
2121
});
2222
2323
const { events } = useEvents();
24-
const { smtp } = useSmtp();
24+
const { getAttachments } = useSmtp();
2525
const isLoading = ref(false);
2626
const serverEvent = ref<Event | null>(null);
2727
const serverAttachments = ref<Attachment[]>([]);
@@ -61,10 +61,9 @@ const getEvent = async () => {
6161
},
6262
});
6363
64-
await smtp.getAttachments(eventId)
65-
.then((attachments: Attachment[]) => {
66-
serverAttachments.value = attachments;
67-
});
64+
await getAttachments(eventId).then((_attachments: Attachment[]) => {
65+
serverAttachments.value = _attachments;
66+
});
6867
};
6968
7069
onMounted(getEvent);
@@ -89,10 +88,11 @@ onMounted(getEvent);
8988
</div>
9089

9190
<div class="smtp-event__body">
92-
<SmtpPage v-if="event"
93-
:event="event"
94-
:attachments="attachments"
95-
:html-source="html"
91+
<SmtpPage
92+
v-if="event"
93+
:event="event"
94+
:attachments="attachments"
95+
:html-source="html"
9696
/>
9797
</div>
9898
</main>

src/entities/smtp/lib/use-smtp.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import type { ServerEvent, NormalizedEvent } from '~/src/shared/types';
2-
import type { SMTP } from "../types";
1+
import { useSmtpRequests } from "~/src/shared/lib/io";
2+
import type { ServerEvent, NormalizedEvent, EventId } from '~/src/shared/types';
3+
import type { SMTP, Attachment } from "../types";
34
import { normalizeSmtpEvent } from "./normalize-smtp-event";
4-
import { type TUseSmtpApi, useSmtpApi } from "~/src/shared/lib/use-smtp";
55

66
type TUseSmtp = () => {
77
normalizeSmtpEvent: (event: ServerEvent<SMTP>) => NormalizedEvent<SMTP>
8-
smtp: TUseSmtpApi
8+
getAttachments: (id: EventId) => Promise<Attachment[]>
99
}
1010

1111
export const useSmtp: TUseSmtp = () => {
12+
const { getAttachments } = useSmtpRequests();
13+
1214
return {
1315
normalizeSmtpEvent,
14-
smtp: useSmtpApi()
16+
getAttachments
1517
}
1618
}

src/entities/smtp/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Attachment } from '~/src/shared/types';
1+
import type { Attachment, Uuid } from '~/src/shared/types';
22

33
export interface SMTPUser {
44
name: string,
@@ -18,3 +18,11 @@ export interface SMTP {
1818
raw: string,
1919
attachments?: Record<string, Attachment> | Attachment[]
2020
}
21+
22+
export interface SMTPAttachment {
23+
uuid: Uuid,
24+
name: string,
25+
path: string,
26+
size: number,
27+
mime: string,
28+
}

src/entities/var-dump/mocks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import varDumpArrayMock from './var-dump-array.json'
2+
import varCodeMock from './var-dump-code-hightlight.json'
23
import varDumpFalseMock from './var-dump-false.json'
34
import varDumpNumberMock from './var-dump-number.json'
45
import varDumpObjectMock from './var-dump-object.json'
56
import varDumpEmptyStringMock from './var-dump-string-empty.json'
67
import varDumpStringMock from './var-dump-string.json'
78
import varDumpTrueMock from './var-dump-true.json'
8-
import varCodeMock from './var-dump-code-hightlight.json'
99

1010
export {
1111
varDumpArrayMock,

src/screens/smtp/ui/smtp-page/smtp-page.vue

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import moment from "moment";
33
import { computed, ref } from "vue";
44
import { Tab, Tabs } from "vue3-tabs-component";
5-
import type { SMTP } from "~/src/entities/smtp/types";
6-
import type { NormalizedEvent, Attachment } from "~/src/shared/types";
5+
import type { SMTP, Attachment } from "~/src/entities/smtp/types";
6+
import type { NormalizedEvent } from "~/src/shared/types";
77
import {
88
TableBase,
99
TableBaseRow,
@@ -20,7 +20,7 @@ type Props = {
2020
};
2121
2222
const props = withDefaults(defineProps<Props>(), {
23-
attachments: [],
23+
attachments: () => [],
2424
});
2525
2626
const htmlSource = ref(props.htmlSource || props.event.payload.html);
@@ -105,7 +105,7 @@ const date = computed(() =>
105105
suffix="<span class='smtp-page__body-tab-badge'>HTML</span>"
106106
>
107107
<SmtpPagePreview device="tablet">
108-
<div v-html="htmlSource"/>
108+
<div v-html="htmlSource" />
109109
</SmtpPagePreview>
110110
</Tab>
111111
<Tab v-if="isHtml" name="HTML">
@@ -128,18 +128,18 @@ const date = computed(() =>
128128
>
129129
<section class="mb-5">
130130
<div class="flex gap-x-3">
131-
<FileAttachment
132-
v-for="a in attachments"
133-
:key="a.uuid"
134-
:event-id="event.id"
135-
:event="event"
136-
:attachment="a"
137-
/>
131+
<template v-for="a in attachments" :key="a.uuid">
132+
<FileAttachment
133+
:event-id="event.id"
134+
:event="event"
135+
:attachment="a"
136+
/>
137+
</template>
138138
</div>
139139
</section>
140140
</Tab>
141141
<Tab name="Raw">
142-
<CodeSnippet language="html" :code="event.payload.raw"/>
142+
<CodeSnippet language="html" :code="event.payload.raw" />
143143
</Tab>
144144
<Tab name="Tech Info">
145145
<section>
@@ -152,22 +152,22 @@ const date = computed(() =>
152152
{{ event.payload.subject }}
153153
</TableBaseRow>
154154
<TableBaseRow title="From">
155-
<SmtpPageAddresses :addresses="event.payload.from"/>
155+
<SmtpPageAddresses :addresses="event.payload.from" />
156156
</TableBaseRow>
157157
<TableBaseRow title="To">
158-
<SmtpPageAddresses :addresses="event.payload.to"/>
158+
<SmtpPageAddresses :addresses="event.payload.to" />
159159
</TableBaseRow>
160160
<TableBaseRow v-if="event.payload.cc.length" title="Cc">
161-
<SmtpPageAddresses :addresses="event.payload.cc"/>
161+
<SmtpPageAddresses :addresses="event.payload.cc" />
162162
</TableBaseRow>
163163
<TableBaseRow v-if="event.payload.bcc.length" title="Bcc">
164-
<SmtpPageAddresses :addresses="event.payload.bcc"/>
164+
<SmtpPageAddresses :addresses="event.payload.bcc" />
165165
</TableBaseRow>
166166
<TableBaseRow
167167
v-if="event.payload.reply_to.length"
168168
title="Reply to"
169169
>
170-
<SmtpPageAddresses :addresses="event.payload.reply_to"/>
170+
<SmtpPageAddresses :addresses="event.payload.reply_to" />
171171
</TableBaseRow>
172172
</TableBase>
173173
</section>

src/shared/lib/io/use-smtp-requests.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Attachment, EventId } from "../../types";
21
import { type NuxtApp, useNuxtApp } from "#app"; // eslint-disable-line @conarti/feature-sliced/layers-slices
2+
import type { SMTPAttachment } from "~/src/entities/smtp/types";
3+
import type { EventId, Attachment } from "../../types";
34
import { REST_API_URL } from "./constants";
45

56
type TUseSmtpRequests = () => {
@@ -9,7 +10,6 @@ type TUseSmtpRequests = () => {
910
// TODO: add 403 response handling
1011

1112
export const useSmtpRequests: TUseSmtpRequests = () => {
12-
1313
const app: NuxtApp = useNuxtApp()
1414
const { token } = app.$authToken ?? { token: null }
1515
const headers = { "X-Auth-Token": token || '' }
@@ -20,7 +20,13 @@ export const useSmtpRequests: TUseSmtpRequests = () => {
2020
.then((response) => response.json())
2121
.then((response) => {
2222
if (response?.data) {
23-
return response.data as Attachment[]
23+
return (response.data as SMTPAttachment[]).map((attachment) => ({
24+
id: attachment.uuid,
25+
name: attachment.name,
26+
size: attachment.size,
27+
mime: attachment.mime,
28+
uri: attachment.path
29+
}))
2430
}
2531

2632
if (response?.code === 403) {
@@ -32,7 +38,6 @@ export const useSmtpRequests: TUseSmtpRequests = () => {
3238

3339
return [];
3440
})
35-
.then((attachments: Attachment[]) => attachments)
3641

3742
return {
3843
getAttachmentsRestUrl,

src/shared/lib/use-smtp/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/shared/lib/use-smtp/use-smtp-api.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)