From 2ac8fcfd2184aa34bc83156406f46e0eeeac519c Mon Sep 17 00:00:00 2001 From: Abhinav Raut Date: Mon, 20 Jan 2025 01:08:15 +0530 Subject: [PATCH] fix: csat toggle in inbox form. --- .../src/components/admin/inbox/EditInbox.vue | 3 +- .../components/admin/inbox/EmailInboxForm.vue | 121 +++++++++--------- .../src/components/admin/inbox/formSchema.js | 2 +- 3 files changed, 64 insertions(+), 62 deletions(-) diff --git a/frontend/src/components/admin/inbox/EditInbox.vue b/frontend/src/components/admin/inbox/EditInbox.vue index d7dc2a28..e7ea88a5 100644 --- a/frontend/src/components/admin/inbox/EditInbox.vue +++ b/frontend/src/components/admin/inbox/EditInbox.vue @@ -27,8 +27,7 @@ const breadcrumbLinks = [ const submitForm = (values) => { const payload = { - name: values.name, - from: values.from, + ...values, channel: inbox.value.channel, config: { imap: [{ ...values.imap }], diff --git a/frontend/src/components/admin/inbox/EmailInboxForm.vue b/frontend/src/components/admin/inbox/EmailInboxForm.vue index b1badf23..ed199ed1 100644 --- a/frontend/src/components/admin/inbox/EmailInboxForm.vue +++ b/frontend/src/components/admin/inbox/EmailInboxForm.vue @@ -3,64 +3,7 @@ class="space-y-6" :schema="formSchema" :form="form" - :field-config="{ - name: { - description: 'Name for your inbox.' - }, - from: { - label: 'From email address', - description: 'From email address. e.g. My Support ' - }, - csat_enabled: { - label: 'CSAT', - description: 'Send a CSAT survey after a conversation is marked as resolved.' - }, - imap: { - label: 'IMAP', - password: { - inputProps: { - type: 'password', - placeholder: '••••••••' - } - }, - read_interval: { - label: 'Emails scan interval' - } - }, - smtp: { - label: 'SMTP', - max_conns: { - label: 'Max connections', - description: 'Maximum number of concurrent connections to the server.' - }, - max_msg_retries: { - label: 'Retries', - description: 'Number of times to retry when a message fails.' - }, - idle_timeout: { - label: 'Idle timeout', - description: `IdleTimeout is the maximum time to wait for new activity on a connection - before closing it and removing it from the pool.` - }, - wait_timeout: { - label: 'Wait timeout', - description: `PoolWaitTimeout is the maximum time to wait to obtain a connection from - a pool before timing out. This may happen when all open connections are - busy sending e-mails and they're not returning to the pool fast enough. - This is also the timeout used when creating new SMTP connections. - ` - }, - auth_protocol: { - label: 'Auth protocol' - }, - password: { - inputProps: { - type: 'password', - placeholder: '••••••••' - } - } - } - }" + :field-config="fieldConfig" @submit="submitForm" > @@ -91,10 +34,70 @@ const props = defineProps({ }, isLoading: { type: Boolean, - required: false, + required: false } }) +const fieldConfig = { + name: { + description: 'Name for your inbox.' + }, + from: { + label: 'From email address', + description: 'From email address. e.g. My Support ' + }, + csat_enabled: { + label: 'CSAT', + description: 'Send a CSAT survey after a conversation is marked as resolved.', + component: 'switch', + }, + imap: { + label: 'IMAP', + password: { + inputProps: { + type: 'password', + placeholder: '••••••••' + } + }, + read_interval: { + label: 'Emails scan interval' + } + }, + smtp: { + label: 'SMTP', + max_conns: { + label: 'Max connections', + description: 'Maximum number of concurrent connections to the server.' + }, + max_msg_retries: { + label: 'Retries', + description: 'Number of times to retry when a message fails.' + }, + idle_timeout: { + label: 'Idle timeout', + description: `IdleTimeout is the maximum time to wait for new activity on a connection + before closing it and removing it from the pool.` + }, + wait_timeout: { + label: 'Wait timeout', + description: `PoolWaitTimeout is the maximum time to wait to obtain a connection from + a pool before timing out. This may happen when all open connections are + busy sending e-mails and they're not returning to the pool fast enough. + This is also the timeout used when creating new SMTP connections. + ` + }, + auth_protocol: { + label: 'Auth protocol' + }, + password: { + inputProps: { + type: 'password', + placeholder: '••••••••' + } + } + } +} + const form = useForm({ validationSchema: toTypedSchema(formSchema), initialValues: props.initialValues diff --git a/frontend/src/components/admin/inbox/formSchema.js b/frontend/src/components/admin/inbox/formSchema.js index 5829ffcf..22bcd698 100644 --- a/frontend/src/components/admin/inbox/formSchema.js +++ b/frontend/src/components/admin/inbox/formSchema.js @@ -4,7 +4,7 @@ import { isGoDuration } from '@/utils/strings' export const formSchema = z.object({ name: z.string().describe('Name').default(''), from: z.string().describe('From address').default(''), - csat_enabled: z.boolean().describe('Enable CSAT').optional(), + csat_enabled: z.boolean().describe('CSAT').default(false), imap: z .object({ host: z.string().describe('Host').default('imap.gmail.com'),