Fix error sending reminder SMS

This commit is contained in:
2026-10-06 13:49:03 +03:30
parent 5074c6d791
commit bc01384551
6 changed files with 191 additions and 48 deletions
+40 -1
View File
@@ -5,6 +5,7 @@ import axios from 'axios';
import { api } from '@/lib/api';
import { useAuthStore } from '@/stores/auth';
import {
formatJalaliDayClock,
formatJalaliNumeric,
formatLocalDateInput,
formatLocalDateTimeInput,
@@ -85,6 +86,19 @@ const needsNote = ref(false);
const reminderAt = ref('');
const reminderNotifyApp = ref(true);
const reminderNotifySms = ref(false);
const loadedReminderAt = ref('');
const reminderSentAt = ref<string | null>(null);
const reminderChanged = computed(() => reminderAt.value !== loadedReminderAt.value);
const reminderSentLabel = computed(() =>
reminderSentAt.value && !reminderChanged.value
? formatJalaliDayClock(new Date(reminderSentAt.value))
: '',
);
const smsAssigneesWithoutMobile = computed(() =>
users.value
.filter((u) => assigneeIds.value.includes(u.id) && !u.mobile?.trim())
.map((u) => u.fullName),
);
const typeOpen = ref(false);
const assigneeOpen = ref(false);
@@ -257,6 +271,8 @@ function resetForm() {
isDone.value = false;
needsNote.value = false;
reminderAt.value = '';
loadedReminderAt.value = '';
reminderSentAt.value = null;
reminderNotifyApp.value = true;
reminderNotifySms.value = false;
tab.value = 'main';
@@ -301,6 +317,8 @@ async function load() {
reminderAt.value = data.reminderAt
? formatLocalDateTimeInput(new Date(data.reminderAt))
: '';
loadedReminderAt.value = reminderAt.value;
reminderSentAt.value = data.reminderSentAt ?? null;
reminderNotifyApp.value = data.reminderNotifyApp ?? true;
reminderNotifySms.value = data.reminderNotifySms ?? false;
if (data.person?.id) await ensurePersonLoaded(data.person.id);
@@ -359,7 +377,7 @@ function parseTags(raw: string): string[] {
function payload(): CreateActivityRequest {
const due =
dueDate.value && dueTime.value ? new Date(`${dueDate.value}T${dueTime.value}:00`) : null;
const reminder = reminderAt.value ? new Date(reminderAt.value) : null;
const reminder = parseLocalInput(reminderAt.value);
return {
title: title.value,
type: type.value || 'task',
@@ -395,6 +413,12 @@ function validate() {
if (!dueDate.value || !dueTime.value) return 'تاریخ و ساعت را مشخص کنید.';
if (!assigneeIds.value.length) return 'حداقل یک مسئول فعالیت را انتخاب کنید.';
if (needsNote.value && !description.value.trim()) return 'توضیح این فعالیت را بنویسید.';
if (reminderAt.value && reminderChanged.value) {
const when = parseLocalInput(reminderAt.value);
if (when && when.getTime() < Date.now() - 60_000) {
return 'زمان یادآوری گذشته است؛ زمانی در آینده انتخاب کنید.';
}
}
if (reminderAt.value && !reminderNotifyApp.value && !reminderNotifySms.value) {
return 'برای یادآوری، اعلان یا پیامک را انتخاب کنید.';
}
@@ -765,6 +789,15 @@ watch([id, isNew], () => void load(), { immediate: true });
>
حداقل یکی از روش‌های یادآوری را انتخاب کنید.
</p>
<p
v-if="reminderNotifySms && smsAssigneesWithoutMobile.length"
class="channel-warn"
>
شمارهٔ موبایل برای {{ smsAssigneesWithoutMobile.join('، ') }} ثبت نشده؛ پیامک برایشان ارسال نمی‌شود.
</p>
<p v-if="reminderSentLabel" class="channel-sent">
این یادآوری در {{ reminderSentLabel }} ارسال شد. برای یادآوری دوباره، زمان جدیدی انتخاب کنید.
</p>
</div>
</div>
</div>
@@ -1554,6 +1587,12 @@ watch([id, isNew], () => void load(), { immediate: true });
font-size: 0.8rem;
}
.channel-sent {
margin: 0;
color: #0f766e;
font-size: 0.8rem;
}
.note-card {
display: grid;
gap: 0.45rem;