|
24 | 24 | </TabsTrigger>
|
25 | 25 | </TabsList>
|
26 | 26 | </Tabs>
|
27 |
| - <span |
28 |
| - class="text-muted-foreground hover:text-foreground transition-colors duration-200 cursor-pointer" |
29 |
| - variant="ghost" |
30 |
| - @click="toggleFullscreen" |
31 |
| - > |
32 |
| - <component |
33 |
| - :is="isFullscreen ? Minimize2 : Maximize2" |
34 |
| - :size="isFullscreen ? '18' : '15'" |
35 |
| - :class="{ 'mr-2': !isFullscreen, 'mr-1 mb-2': isFullscreen }" |
36 |
| - /> |
37 |
| - </span> |
| 27 | + <Button class="text-muted-foreground" variant="ghost" @click="toggleFullscreen"> |
| 28 | + <component :is="isFullscreen ? Minimize2 : Maximize2" /> |
| 29 | + </Button> |
38 | 30 | </div>
|
39 | 31 |
|
40 | 32 | <!-- To, CC, and BCC fields -->
|
|
43 | 35 | v-if="messageType === 'reply'"
|
44 | 36 | >
|
45 | 37 | <div class="flex items-center space-x-2">
|
46 |
| - <label class="w-12 text-sm font-medium text-muted-foreground">To:</label> |
| 38 | + <label class="w-12 text-sm font-medium text-muted-foreground">TO:</label> |
47 | 39 | <Input
|
48 | 40 | type="text"
|
49 | 41 | :placeholder="t('replyBox.emailAddresess')"
|
50 | 42 | v-model="to"
|
51 | 43 | class="flex-grow px-3 py-2 text-sm border rounded focus:ring-2 focus:ring-ring"
|
52 |
| - @blur="validateEmails('to')" |
| 44 | + @blur="validateEmails" |
53 | 45 | />
|
54 | 46 | </div>
|
55 | 47 | <div class="flex items-center space-x-2">
|
|
59 | 51 | :placeholder="t('replyBox.emailAddresess')"
|
60 | 52 | v-model="cc"
|
61 | 53 | class="flex-grow px-3 py-2 text-sm border rounded focus:ring-2 focus:ring-ring"
|
62 |
| - @blur="validateEmails('cc')" |
| 54 | + @blur="validateEmails" |
63 | 55 | />
|
64 | 56 | <Button
|
65 | 57 | size="sm"
|
|
76 | 68 | :placeholder="t('replyBox.emailAddresess')"
|
77 | 69 | v-model="bcc"
|
78 | 70 | class="flex-grow px-3 py-2 text-sm border rounded focus:ring-2 focus:ring-ring"
|
79 |
| - @blur="validateEmails('bcc')" |
| 71 | + @blur="validateEmails" |
80 | 72 | />
|
81 | 73 | </div>
|
82 | 74 | </div>
|
@@ -221,9 +213,11 @@ const editorPlaceholder = t('replyBox.editor.placeholder')
|
221 | 213 | const toggleBcc = async () => {
|
222 | 214 | showBcc.value = !showBcc.value
|
223 | 215 | await nextTick()
|
224 |
| - // If hiding BCC field, clear the content |
| 216 | + // If hiding BCC field, clear the content and validate email bcc so it doesn't show errors. |
225 | 217 | if (!showBcc.value) {
|
226 | 218 | bcc.value = ''
|
| 219 | + await nextTick() |
| 220 | + validateEmails() |
227 | 221 | }
|
228 | 222 | }
|
229 | 223 |
|
@@ -255,37 +249,32 @@ const enableSend = computed(() => {
|
255 | 249 | })
|
256 | 250 |
|
257 | 251 | /**
|
258 |
| - * Validate email addresses in the To, CC, and BCC fields |
259 |
| - * @param {string} field - 'to', 'cc', or 'bcc' |
| 252 | + * Validates email addresses in To, CC, and BCC fields. |
| 253 | + * Populates `emailErrors` with invalid emails grouped by field. |
260 | 254 | */
|
261 |
| -const validateEmails = (field) => { |
262 |
| - const emails = field === 'to' ? to.value : field === 'cc' ? cc.value : bcc.value |
263 |
| - const emailList = emails |
264 |
| - .split(',') |
265 |
| - .map((e) => e.trim()) |
266 |
| - .filter((e) => e !== '') |
| 255 | +const validateEmails = async () => { |
| 256 | + emailErrors.value = [] |
| 257 | + await nextTick() |
267 | 258 |
|
268 |
| - const invalidEmails = emailList.filter((email) => !validateEmail(email)) |
| 259 | + const fields = ['to', 'cc', 'bcc'] |
| 260 | + const values = { to: to.value, cc: cc.value, bcc: bcc.value } |
269 | 261 |
|
270 |
| - // Clear existing errors |
271 |
| - emailErrors.value = [] |
| 262 | + fields.forEach((field) => { |
| 263 | + const invalid = values[field] |
| 264 | + .split(',') |
| 265 | + .map((e) => e.trim()) |
| 266 | + .filter((e) => e && !validateEmail(e)) |
272 | 267 |
|
273 |
| - // Add new error if there are invalid emails |
274 |
| - if (invalidEmails.length > 0) { |
275 |
| - emailErrors.value = [ |
276 |
| - ...emailErrors.value, |
277 |
| - `${t('replyBox.invalidEmailsIn')} '${field}': ${invalidEmails.join(', ')}` |
278 |
| - ] |
279 |
| - } |
| 268 | + if (invalid.length) |
| 269 | + emailErrors.value.push(`${t('replyBox.invalidEmailsIn')} '${field}': ${invalid.join(', ')}`) |
| 270 | + }) |
280 | 271 | }
|
281 | 272 |
|
282 | 273 | /**
|
283 | 274 | * Send the reply or private note
|
284 | 275 | */
|
285 | 276 | const handleSend = async () => {
|
286 |
| - validateEmails('to') |
287 |
| - validateEmails('cc') |
288 |
| - validateEmails('bcc') |
| 277 | + await validateEmails() |
289 | 278 | if (emailErrors.value.length > 0) {
|
290 | 279 | emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
291 | 280 | variant: 'destructive',
|
|
0 commit comments