fix(dashboard): fix date conversion offset, calendar arrow directions, payment duplicate warning, attendance class filter, and session auto-generation
This commit is contained in:
@@ -294,12 +294,13 @@ const props = defineProps({
|
||||
courseId: { type: [String, Object], required: true },
|
||||
professorId: { type: [String, Object], default: null },
|
||||
defaultSessionCount: { type: Number, default: 12 },
|
||||
startDate: { type: [String, Date], default: '' },
|
||||
days: { type: Array, default: () => [] },
|
||||
startTime: { type: String, default: '' },
|
||||
endTime: { type: String, default: '' }
|
||||
});
|
||||
|
||||
const { toPersianDigits, toLatinDigits, toGregorianIso, formatJalali, getTodayJalali } = usePersianDate();
|
||||
const { toPersianDigits, toLatinDigits, toGregorianIso, formatJalali, getTodayJalali, parseToMoment, toJalaliPickerValue } = usePersianDate();
|
||||
const { showSuccess, showError } = useToast();
|
||||
|
||||
const sessions = ref([]);
|
||||
@@ -407,16 +408,17 @@ const weekdays = [
|
||||
|
||||
const autoForm = reactive({
|
||||
sessionCount: props.defaultSessionCount || 12,
|
||||
startDate: getTodayJalali(),
|
||||
startDate: toJalaliPickerValue(props.startDate) || getTodayJalali(),
|
||||
startTime: props.startTime || '19:00',
|
||||
endTime: props.endTime || '20:30',
|
||||
selectedDays: props.days?.length ? [...props.days] : [6, 2]
|
||||
selectedDays: props.days?.length ? props.days.map(Number) : [6, 2]
|
||||
});
|
||||
|
||||
watch(
|
||||
() => [props.days, props.startTime, props.endTime, props.defaultSessionCount],
|
||||
() => [props.startDate, props.days, props.startTime, props.endTime, props.defaultSessionCount],
|
||||
() => {
|
||||
if (props.days?.length) autoForm.selectedDays = [...props.days];
|
||||
if (props.startDate) autoForm.startDate = toJalaliPickerValue(props.startDate) || autoForm.startDate;
|
||||
if (props.days?.length) autoForm.selectedDays = props.days.map(Number);
|
||||
if (props.startTime) autoForm.startTime = props.startTime;
|
||||
if (props.endTime) autoForm.endTime = props.endTime;
|
||||
if (props.defaultSessionCount) autoForm.sessionCount = props.defaultSessionCount;
|
||||
@@ -519,9 +521,8 @@ const generateSessionsPreview = () => {
|
||||
}
|
||||
|
||||
const list = [];
|
||||
const latinStartDate = toLatinDigits(autoForm.startDate);
|
||||
let currentMoment = moment(latinStartDate, ['jYYYY/jMM/jDD', 'YYYY-MM-DD', 'YYYY/MM/DD', moment.ISO_8601]);
|
||||
if (!currentMoment.isValid()) {
|
||||
const currentMoment = parseToMoment(autoForm.startDate);
|
||||
if (!currentMoment || !currentMoment.isValid()) {
|
||||
showError('تاریخ شروع نامعتبر است');
|
||||
return;
|
||||
}
|
||||
@@ -532,7 +533,7 @@ const generateSessionsPreview = () => {
|
||||
|
||||
while (count < targetCount && safetyLimit > 0) {
|
||||
safetyLimit--;
|
||||
if (autoForm.selectedDays.includes(currentMoment.day())) {
|
||||
if (autoForm.selectedDays.map(Number).includes(currentMoment.day())) {
|
||||
count++;
|
||||
list.push({
|
||||
sessionNumber: count,
|
||||
|
||||
Reference in New Issue
Block a user