fix(dashboard): fix class edit page hang and move session notify action to class edit page
The class edit page hung/looped because ClassSessionsSection.vue still referenced a removed todayJalali() helper in the template, which threw a render error on every reactive update. Switch both usages to the getTodayJalali() composable function. Also remove the duplicate "اطلاعرسانی برگزاری جلسه" notify button/dialog from SessionListView.vue since the same action already exists per-session inside the class edit page.
This commit is contained in:
@@ -232,7 +232,7 @@
|
|||||||
<div v-for="(session, index) in manualSessions" :key="index" class="grid align-items-center mb-2 p-2 border-round surface-ground">
|
<div v-for="(session, index) in manualSessions" :key="index" class="grid align-items-center mb-2 p-2 border-round surface-ground">
|
||||||
<div class="col-12 sm:col-1 text-center font-bold">#{{ toPersianDigits(index + 1) }}</div>
|
<div class="col-12 sm:col-1 text-center font-bold">#{{ toPersianDigits(index + 1) }}</div>
|
||||||
<div class="col-12 sm:col-3">
|
<div class="col-12 sm:col-3">
|
||||||
<InputText v-model="session.date" :placeholder="`تاریخ (${todayJalali()})`" class="w-full text-sm" />
|
<InputText v-model="session.date" :placeholder="`تاریخ (${getTodayJalali()})`" class="w-full text-sm" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 sm:col-2">
|
<div class="col-6 sm:col-2">
|
||||||
<InputText v-model="session.startTime" placeholder="ساعت شروع" class="w-full text-sm" dir="ltr" />
|
<InputText v-model="session.startTime" placeholder="ساعت شروع" class="w-full text-sm" dir="ltr" />
|
||||||
@@ -261,7 +261,7 @@
|
|||||||
label="افزودن ردیف"
|
label="افزودن ردیف"
|
||||||
icon="pi pi-plus"
|
icon="pi pi-plus"
|
||||||
text
|
text
|
||||||
@click="manualSessions.push({ date: todayJalali(), startTime: '19:00', endTime: '20:30', topic: '' })"
|
@click="manualSessions.push({ date: getTodayJalali(), startTime: '19:00', endTime: '20:30', topic: '' })"
|
||||||
/>
|
/>
|
||||||
<Button label="ثبت جلسات" icon="pi pi-save" severity="success" :loading="isSaving" @click="submitManualSessions" />
|
<Button label="ثبت جلسات" icon="pi pi-save" severity="success" :loading="isSaving" @click="submitManualSessions" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -131,19 +131,6 @@
|
|||||||
/>
|
/>
|
||||||
</PermissionGate>
|
</PermissionGate>
|
||||||
|
|
||||||
<PermissionGate permission="sessions:read">
|
|
||||||
<Button
|
|
||||||
icon="pi pi-send"
|
|
||||||
text
|
|
||||||
rounded
|
|
||||||
size="small"
|
|
||||||
severity="info"
|
|
||||||
v-tooltip.top="'اطلاعرسانی برگزاری جلسه'"
|
|
||||||
:loading="notifyingSessionId === (data._id || data.id)"
|
|
||||||
@click="openNotifyHoldingDialog(data)"
|
|
||||||
/>
|
|
||||||
</PermissionGate>
|
|
||||||
|
|
||||||
<PermissionGate permission="sessions:update">
|
<PermissionGate permission="sessions:update">
|
||||||
<Button icon="pi pi-pencil" text rounded size="small" severity="warning" v-tooltip.top="'ویرایش'" @click="$router.push(`/sessions/edit/${data._id || data.id}`)" />
|
<Button icon="pi pi-pencil" text rounded size="small" severity="warning" v-tooltip.top="'ویرایش'" @click="$router.push(`/sessions/edit/${data._id || data.id}`)" />
|
||||||
</PermissionGate>
|
</PermissionGate>
|
||||||
@@ -163,34 +150,6 @@
|
|||||||
:message="bulkDeleteMessage"
|
:message="bulkDeleteMessage"
|
||||||
@confirm="handleDeleteConfirm"
|
@confirm="handleDeleteConfirm"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Dialog
|
|
||||||
v-model:visible="notifyDialogVisible"
|
|
||||||
header="اطلاعرسانی برگزاری جلسه"
|
|
||||||
modal
|
|
||||||
:style="{ width: '450px' }"
|
|
||||||
>
|
|
||||||
<div class="flex flex-column gap-3 py-2">
|
|
||||||
<p class="m-0 line-height-3 text-sm">
|
|
||||||
آیا از ارسال پیامک برگزاری جلسه طبق برنامه به دانشجویان کلاس «{{ selectedSessionForNotify?.class?.name || selectedSessionForNotify?.course?.title || '' }}» اطمینان دارید؟
|
|
||||||
</p>
|
|
||||||
<div v-if="selectedSessionForNotify" class="surface-100 p-3 border-round text-xs flex flex-column gap-1">
|
|
||||||
<div><strong>موضوع جلسه:</strong> {{ selectedSessionForNotify.topic || 'طبق برنامه' }}</div>
|
|
||||||
<div><strong>تاریخ:</strong> {{ formatJalali(selectedSessionForNotify.day || selectedSessionForNotify.date) }}</div>
|
|
||||||
<div><strong>ساعت:</strong> {{ selectedSessionForNotify.startTime || '—' }} تا {{ selectedSessionForNotify.endTime || '—' }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<template #footer>
|
|
||||||
<Button label="انصراف" text severity="secondary" @click="notifyDialogVisible = false" />
|
|
||||||
<Button
|
|
||||||
label="ارسال پیامک"
|
|
||||||
icon="pi pi-send"
|
|
||||||
severity="info"
|
|
||||||
:loading="isNotifying"
|
|
||||||
@click="handleSendSessionHolding"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</Dialog>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -211,7 +170,6 @@ import Column from 'primevue/column';
|
|||||||
import Tag from 'primevue/tag';
|
import Tag from 'primevue/tag';
|
||||||
import Select from 'primevue/select';
|
import Select from 'primevue/select';
|
||||||
import Dropdown from 'primevue/select';
|
import Dropdown from 'primevue/select';
|
||||||
import Dialog from 'primevue/dialog';
|
|
||||||
|
|
||||||
const { formatJalali, toPersianDigits } = usePersianDate();
|
const { formatJalali, toPersianDigits } = usePersianDate();
|
||||||
const { showSuccess, showError } = useToast();
|
const { showSuccess, showError } = useToast();
|
||||||
@@ -242,35 +200,6 @@ const selectedSession = ref(null);
|
|||||||
const bulkDeleteMode = ref(false);
|
const bulkDeleteMode = ref(false);
|
||||||
const isDeleting = ref(false);
|
const isDeleting = ref(false);
|
||||||
|
|
||||||
const notifyDialogVisible = ref(false);
|
|
||||||
const selectedSessionForNotify = ref(null);
|
|
||||||
const notifyingSessionId = ref(null);
|
|
||||||
const isNotifying = ref(false);
|
|
||||||
|
|
||||||
const openNotifyHoldingDialog = (session) => {
|
|
||||||
selectedSessionForNotify.value = session;
|
|
||||||
notifyDialogVisible.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSendSessionHolding = async () => {
|
|
||||||
if (!selectedSessionForNotify.value) return;
|
|
||||||
const id = selectedSessionForNotify.value._id || selectedSessionForNotify.value.id;
|
|
||||||
notifyingSessionId.value = id;
|
|
||||||
isNotifying.value = true;
|
|
||||||
try {
|
|
||||||
const res = await sessionApi.notifyHolding(id);
|
|
||||||
const count = res.data?.sentCount || res.data?.totalStudents || '';
|
|
||||||
showSuccess(`پیامک برگزاری جلسه با موفقیت به ${count ? toPersianDigits(count) + ' نفر از ' : ''}دانشجویان ارسال شد`);
|
|
||||||
notifyDialogVisible.value = false;
|
|
||||||
selectedSessionForNotify.value = null;
|
|
||||||
} catch (err) {
|
|
||||||
showError(err);
|
|
||||||
} finally {
|
|
||||||
notifyingSessionId.value = null;
|
|
||||||
isNotifying.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const statusOptions = [
|
const statusOptions = [
|
||||||
{ label: 'طبق برنامه', value: 'scheduled' },
|
{ label: 'طبق برنامه', value: 'scheduled' },
|
||||||
{ label: 'برگزار شده', value: 'held' },
|
{ label: 'برگزار شده', value: 'held' },
|
||||||
|
|||||||
Reference in New Issue
Block a user