feat: set default date and time in CallCenterTab, update input styles

This commit is contained in:
hamed
2026-07-16 12:38:22 +03:30
parent d4fd6c0020
commit 65083854cb
3 changed files with 13 additions and 4 deletions
@@ -137,6 +137,9 @@ describe('PatientDetailPage (پرونده تب‌دار)', () => {
expect(await screen.findByText('ثبت تماس جدید')).toBeInTheDocument();
expect(screen.getByText('تاریخچه تماس‌ها')).toBeInTheDocument();
expect(await screen.findByText('تماسی ثبت نشده است.')).toBeInTheDocument();
// زمان تماس پیش‌فرض روی «الان» است، نه خالی.
const timeInput = document.querySelector('input[type="time"]') as HTMLInputElement;
expect(timeInput.value).toMatch(/^\d{2}:\d{2}$/);
});
it('links "سرویس جدید" on the services tab to the new-session route', async () => {
+9 -3
View File
@@ -526,13 +526,19 @@ function MessagesTab({ uuid }: { uuid: string }) {
interface Call { uuid: string; subject: string; summary?: string | null; outcome: string; called_at: number; personnel?: string | null }
const pad2 = (n: number) => String(n).padStart(2, '0');
/** تاریخ امروز میلادی به فرمت YYYY-MM-DD (ورودی PersianDateInput). */
const nowDate = () => { const d = new Date(); return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`; };
/** ساعت الان به فرمت HH:MM. */
const nowTime = () => { const d = new Date(); return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`; };
/** کال سنتر — patient call log: register a call + filterable history (all / success / missed). */
function CallCenterTab({ uuid }: { uuid: string }) {
const qc = useQueryClient();
const userName = useAuthStore((s) => s.userName);
const [filter, setFilter] = useState<'all' | 'success' | 'missed'>('all');
const [date, setDate] = useState('');
const [time, setTime] = useState('');
const [date, setDate] = useState(nowDate);
const [time, setTime] = useState(nowTime);
const [subject, setSubject] = useState('');
const [summary, setSummary] = useState('');
const [outcome, setOutcome] = useState<'success' | 'missed'>('success');
@@ -553,7 +559,7 @@ function CallCenterTab({ uuid }: { uuid: string }) {
const calledAt = iso ? Math.floor(new Date(iso).getTime() / 1000) : Math.floor(Date.now() / 1000);
return api.post(`/api/v1/patient/${uuid}/call`, { subject, summary, outcome, called_at: calledAt, personnel: userName });
},
onSuccess: () => { invalidate(); setDate(''); setTime(''); setSubject(''); setSummary(''); setOutcome('success'); toast.success('تماس ثبت شد'); },
onSuccess: () => { invalidate(); setDate(nowDate()); setTime(nowTime()); setSubject(''); setSummary(''); setOutcome('success'); toast.success('تماس ثبت شد'); },
onError: (e: any) => toast.error(e.message),
});
const del = useMutation({
+1 -1
View File
@@ -633,7 +633,7 @@ table.t tbody tr:last-child td { border-bottom: none; }
transition: .15s;
}
.field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.field input, .field select { border: none; outline: none; background: none; flex: 1; min-width: 60px; color: var(--text); font-family: inherit; font-size: 14px; }
.field input, .field select, .field textarea { border: none; outline: none; background: none; flex: 1; min-width: 60px; color: var(--text); font-family: inherit; font-size: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: .14s; cursor: pointer; font-family: inherit; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }