Skip to content

Commit 25f2373

Browse files
committed
feat: translate admin email inbox forms
1 parent 3888793 commit 25f2373

File tree

9 files changed

+241
-139
lines changed

9 files changed

+241
-139
lines changed

cmd/conversation.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,19 +586,19 @@ func handleCreateConversation(r *fastglue.Request) error {
586586
)
587587
// Validate required fields
588588
if inboxID <= 0 {
589-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.required", "name", "`inbox_id`"), nil, envelope.InputError)
589+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`inbox_id`"), nil, envelope.InputError)
590590
}
591591
if strings.TrimSpace(subject) == "" {
592-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.required", "name", "`subject`"), nil, envelope.InputError)
592+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`subject`"), nil, envelope.InputError)
593593
}
594594
if strings.TrimSpace(content) == "" {
595-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.required", "name", "`content`"), nil, envelope.InputError)
595+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`content`"), nil, envelope.InputError)
596596
}
597597
if strings.TrimSpace(email) == "" {
598-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.required", "name", "`contact_email`"), nil, envelope.InputError)
598+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`contact_email`"), nil, envelope.InputError)
599599
}
600600
if firstName == "" {
601-
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.required", "name", "`first_name`"), nil, envelope.InputError)
601+
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`first_name`"), nil, envelope.InputError)
602602
}
603603

604604
user, err := app.user.GetAgent(auser.ID)

frontend/src/features/admin/inbox/EmailInboxForm.vue

Lines changed: 74 additions & 65 deletions
Large diffs are not rendered by default.

frontend/src/features/admin/inbox/InboxDataTableDropDown.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,39 @@
22
<DropdownMenu>
33
<DropdownMenuTrigger as-child>
44
<Button variant="ghost" class="w-8 h-8 p-0">
5-
<span class="sr-only">Open menu</span>
5+
<span class="sr-only"></span>
66
<MoreHorizontal class="w-4 h-4" />
77
</Button>
88
</DropdownMenuTrigger>
99
<DropdownMenuContent>
10-
<DropdownMenuItem @click="editInbox(props.inbox.id)">Edit</DropdownMenuItem>
11-
<DropdownMenuItem @click="() => (alertOpen = true)">Delete</DropdownMenuItem>
10+
<DropdownMenuItem @click="editInbox(props.inbox.id)">{{
11+
$t('globals.buttons.edit')
12+
}}</DropdownMenuItem>
13+
<DropdownMenuItem @click="() => (alertOpen = true)">{{
14+
$t('globals.buttons.delete')
15+
}}</DropdownMenuItem>
1216
<DropdownMenuItem @click="toggleInbox(props.inbox.id)" v-if="props.inbox.enabled">
13-
Disable
17+
{{ $t('globals.buttons.disable') }}
1418
</DropdownMenuItem>
15-
<DropdownMenuItem @click="toggleInbox(props.inbox.id)" v-else>Enable</DropdownMenuItem>
19+
<DropdownMenuItem @click="toggleInbox(props.inbox.id)" v-else>{{
20+
$t('globals.buttons.enable')
21+
}}</DropdownMenuItem>
1622
</DropdownMenuContent>
1723
</DropdownMenu>
1824

1925
<AlertDialog :open="alertOpen" @update:open="alertOpen = $event">
2026
<AlertDialogContent>
2127
<AlertDialogHeader>
22-
<AlertDialogTitle>Delete Inbox</AlertDialogTitle>
28+
<AlertDialogTitle>{{ $t('admin.inbox.delete_confirmation_title') }}</AlertDialogTitle>
2329
<AlertDialogDescription>
24-
This action cannot be undone. This will permanently delete the inbox.
30+
{{ $t('admin.inbox.delete_confirmation') }}
2531
</AlertDialogDescription>
2632
</AlertDialogHeader>
2733
<AlertDialogFooter>
28-
<AlertDialogCancel>Cancel</AlertDialogCancel>
29-
<AlertDialogAction @click="handleDelete">Delete</AlertDialogAction>
34+
<AlertDialogCancel>{{ $t('globals.buttons.cancel') }}</AlertDialogCancel>
35+
<AlertDialogAction @click="handleDelete">{{
36+
$t('globals.buttons.delete')
37+
}}</AlertDialogAction>
3038
</AlertDialogFooter>
3139
</AlertDialogContent>
3240
</AlertDialog>

frontend/src/features/admin/inbox/formSchema.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
11
import * as z from 'zod'
22
import { isGoDuration } from '@/utils/strings'
33

4-
export const formSchema = z.object({
5-
name: z.string().min(1, 'Required'),
6-
from: z.string().min(1, 'Required'),
4+
export const createFormSchema = (t) => z.object({
5+
name: z.string().min(1, t('globals.messages.required')),
6+
from: z.string().min(1, t('globals.messages.required')),
77
enabled: z.boolean().optional(),
88
csat_enabled: z.boolean().optional(),
99
imap: z.object({
10-
host: z.string().min(1, 'Required'),
10+
host: z.string().min(1, t('globals.messages.required')),
1111
port: z.number().min(1).max(65535),
12-
mailbox: z.string().min(1, 'Required'),
13-
username: z.string().min(1, 'Required'),
14-
password: z.string().min(1, 'Required'),
12+
mailbox: z.string().min(1, t('globals.messages.required')),
13+
username: z.string().min(1, t('globals.messages.required')),
14+
password: z.string().min(1, t('globals.messages.required')),
1515
tls_type: z.enum(['none', 'starttls', 'tls']),
1616
tls_skip_verify: z.boolean().optional(),
17-
scan_inbox_since: z.string().min(1, 'Required').refine(isGoDuration, {
18-
message: 'Invalid duration. Please use a valid duration format (e.g. 1h, 30m, 1h30m, 48h, etc.)'
17+
scan_inbox_since: z.string().min(1, t('globals.messages.required')).refine(isGoDuration, {
18+
message: t('globals.messages.goDuration')
1919
}),
20-
read_interval: z.string().min(1, 'Required').refine(isGoDuration)
20+
read_interval: z.string().min(1, t('globals.messages.required')).refine(isGoDuration, {
21+
message: t('globals.messages.goDuration')
22+
})
2123
}),
2224

2325
smtp: z.object({
24-
host: z.string().min(1, 'Required'),
26+
host: z.string().min(1, t('globals.messages.required')),
2527
port: z.number().min(1).max(65535),
26-
username: z.string().min(1, 'Required'),
27-
password: z.string().min(1, 'Required'),
28+
username: z.string().min(1, t('globals.messages.required')),
29+
password: z.string().min(1, t('globals.messages.required')),
2830
max_conns: z.number().min(1),
2931
max_msg_retries: z.number().min(0).max(100),
30-
idle_timeout: z.string().min(1, 'Required').refine(isGoDuration),
31-
wait_timeout: z.string().min(1, 'Required').refine(isGoDuration),
32+
idle_timeout: z.string().min(1, t('globals.messages.required')).refine(isGoDuration, {
33+
message: t('globals.messages.goDuration')
34+
}),
35+
wait_timeout: z.string().min(1, t('globals.messages.required')).refine(isGoDuration, {
36+
message: t('globals.messages.goDuration')
37+
}),
3238
tls_type: z.enum(['none', 'starttls', 'tls']),
3339
tls_skip_verify: z.boolean().optional(),
3440
hello_hostname: z.string().optional(),

frontend/src/views/admin/inbox/EditInbox.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import { Spinner } from '@/components/ui/spinner'
1515
import { EMITTER_EVENTS } from '@/constants/emitterEvents.js'
1616
import { useEmitter } from '@/composables/useEmitter'
1717
import { handleHTTPError } from '@/utils/http'
18+
import { useI18n } from 'vue-i18n'
1819
1920
const emitter = useEmitter()
21+
const { t } = useI18n()
2022
const formLoading = ref(false)
2123
const isLoading = ref(false)
2224
const inbox = ref({})
@@ -41,7 +43,7 @@ const submitForm = (values) => {
4143
}
4244
4345
// Set dummy SMTP passwords to empty strings
44-
payload.config.smtp.forEach(smtp => {
46+
payload.config.smtp.forEach((smtp) => {
4547
if (smtp.password?.includes('')) {
4648
smtp.password = ''
4749
}
@@ -54,12 +56,10 @@ const updateInbox = async (payload) => {
5456
isLoading.value = true
5557
await api.updateInbox(inbox.value.id, payload)
5658
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
57-
title: 'Success',
58-
description: 'Inbox updated succcessfully'
59+
description: t('admin.inbox.updated')
5960
})
6061
} catch (error) {
6162
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
62-
title: 'Error',
6363
variant: 'destructive',
6464
description: handleHTTPError(error).message
6565
})
@@ -84,7 +84,6 @@ onMounted(async () => {
8484
inbox.value = inboxData
8585
} catch (error) {
8686
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
87-
title: 'Error',
8887
variant: 'destructive',
8988
description: handleHTTPError(error).message
9089
})

frontend/src/views/admin/inbox/InboxList.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="flex justify-between mb-5">
55
<div></div>
66
<router-link :to="{ name: 'new-inbox' }">
7-
<Button>New Inbox</Button>
7+
<Button>{{ $t('admin.inbox.new') }}</Button>
88
</router-link>
99
</div>
1010
<div>
@@ -23,11 +23,12 @@ import DataTable from '@/components/datatable/DataTable.vue'
2323
import { EMITTER_EVENTS } from '@/constants/emitterEvents.js'
2424
import { useEmitter } from '@/composables/useEmitter'
2525
import { useRouter } from 'vue-router'
26-
26+
import { useI18n } from 'vue-i18n'
2727
import { format } from 'date-fns'
2828
import { Spinner } from '@/components/ui/spinner'
2929
import api from '@/api'
3030
31+
const { t } = useI18n()
3132
const router = useRouter()
3233
const emitter = useEmitter()
3334
const isLoading = ref(false)
@@ -44,7 +45,6 @@ const getInboxes = async () => {
4445
data.value = response.data.data
4546
} catch (error) {
4647
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
47-
title: 'Error',
4848
variant: 'destructive',
4949
description: handleHTTPError(error).message
5050
})
@@ -58,7 +58,7 @@ const columns = [
5858
{
5959
accessorKey: 'name',
6060
header: function () {
61-
return h('div', { class: 'text-center' }, 'Name')
61+
return h('div', { class: 'text-center' }, t('form.field.name'))
6262
},
6363
cell: function ({ row }) {
6464
return h('div', { class: 'text-center font-medium' }, row.getValue('name'))
@@ -67,15 +67,15 @@ const columns = [
6767
{
6868
accessorKey: 'channel',
6969
header: function () {
70-
return h('div', { class: 'text-center' }, 'Channel')
70+
return h('div', { class: 'text-center' }, t('form.field.channel'))
7171
},
7272
cell: function ({ row }) {
7373
return h('div', { class: 'text-center font-medium' }, row.getValue('channel'))
7474
}
7575
},
7676
{
7777
accessorKey: 'enabled',
78-
header: () => h('div', { class: 'text-center' }, 'Enabled'),
78+
header: () => h('div', { class: 'text-center' }, t('form.field.enabled')),
7979
cell: ({ row }) => {
8080
const enabled = row.getValue('enabled')
8181
return h('div', { class: 'text-center' }, enabled ? 'Yes' : 'No')
@@ -84,7 +84,7 @@ const columns = [
8484
{
8585
accessorKey: 'created_at',
8686
header: function () {
87-
return h('div', { class: 'text-center' }, 'Created at')
87+
return h('div', { class: 'text-center' }, t('form.field.createdAt'))
8888
},
8989
cell: function ({ row }) {
9090
return h('div', { class: 'text-center' }, format(row.getValue('created_at'), 'PPpp'))
@@ -93,7 +93,7 @@ const columns = [
9393
{
9494
accessorKey: 'updated_at',
9595
header: function () {
96-
return h('div', { class: 'text-center' }, 'Updated at')
96+
return h('div', { class: 'text-center' }, t('form.field.updatedAt'))
9797
},
9898
cell: function ({ row }) {
9999
return h('div', { class: 'text-center' }, format(row.getValue('updated_at'), 'PPpp'))

0 commit comments

Comments
 (0)