Login: mensaje amigable y ojo de password; agenda: click en celda libre para agendar (estilo Google Calendar)
This commit is contained in:
@@ -301,6 +301,8 @@ const Agenda: FC = () => {
|
||||
const apt = dragApt;
|
||||
setDragApt(null);
|
||||
setDropTarget(null);
|
||||
// Evita que el click posterior al drop abra el modal de nueva cita
|
||||
justDroppedRef.current = true;
|
||||
if ((apt.doctor_id ?? null) === doctorId && aptSlot(apt.time) === slot) return;
|
||||
const nombreCol = doctorId ? (doctors.find((d) => d.id === doctorId)?.name || '') : 'Sin asignar';
|
||||
const horaStr = horaFloatStr(slot);
|
||||
@@ -757,6 +759,42 @@ const Agenda: FC = () => {
|
||||
setCreateOpen(true);
|
||||
};
|
||||
|
||||
// Nueva cita precargada desde una celda libre del grid (fecha/hora/médico
|
||||
// del slot clicado). Se usa un solo click (el drag&drop se distingue con
|
||||
// justDroppedRef: tras un drop real el click posterior se ignora).
|
||||
const justDroppedRef = useRef(false);
|
||||
const openCreateAt = (opts?: { date?: string; time?: string; doctorId?: number | null }) => {
|
||||
setQuickMode(false);
|
||||
const d = opts?.date ?? date;
|
||||
const docId = medicoEmployeeId
|
||||
? String(medicoEmployeeId)
|
||||
: (opts?.doctorId != null ? String(opts.doctorId) : doctorFilter);
|
||||
const t = opts?.time ?? '';
|
||||
setForm((f) => ({ ...f, date: d, time: t, doctor_id: docId }));
|
||||
setQuickForm({
|
||||
name: '',
|
||||
phone: '',
|
||||
doctor_id: docId,
|
||||
date: d,
|
||||
time: t,
|
||||
notes: '',
|
||||
});
|
||||
setCreateOpen(true);
|
||||
};
|
||||
|
||||
const clickCeldaLibre = (e: React.MouseEvent, dateStr: string, slot: number | null, doctorId: number | null) => {
|
||||
if (justDroppedRef.current) {
|
||||
justDroppedRef.current = false;
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
openCreateAt({
|
||||
date: dateStr,
|
||||
time: slot != null ? horaFloatStr(slot) : '',
|
||||
doctorId,
|
||||
});
|
||||
};
|
||||
|
||||
const submitQuick = async () => {
|
||||
if (!quickForm.name.trim() || !quickForm.phone.trim()) {
|
||||
toast.error('Nombre y teléfono son obligatorios');
|
||||
@@ -1270,11 +1308,15 @@ const Agenda: FC = () => {
|
||||
Bloqueado{bloqueo.motivo ? ` — ${bloqueo.motivo}` : ''}
|
||||
</div>
|
||||
) : cell.length === 0 ? (
|
||||
<div className={`rounded-lg border py-1.5 text-center text-[10px] font-medium transition-colors ${
|
||||
quickFilter === 'libres'
|
||||
? 'bg-brand-mint border-emerald-700 text-theme-heading font-semibold'
|
||||
: 'border-dashed border-theme-border-strong text-theme-muted hover:bg-theme-accent-bg'
|
||||
}`}>
|
||||
<div
|
||||
onClick={(e) => clickCeldaLibre(e, date, slot, col.doctorId)}
|
||||
className={`cursor-pointer rounded-lg border py-1.5 text-center text-[10px] font-medium transition-colors ${
|
||||
quickFilter === 'libres'
|
||||
? 'bg-brand-mint border-emerald-700 text-theme-heading font-semibold'
|
||||
: 'border-dashed border-theme-border-strong text-theme-muted hover:bg-theme-accent-bg'
|
||||
}`}
|
||||
title={`Nueva cita aquí — ${horaFloatStr(slot)}`}
|
||||
>
|
||||
Libre
|
||||
</div>
|
||||
) : (
|
||||
@@ -1377,7 +1419,8 @@ const Agenda: FC = () => {
|
||||
</div>
|
||||
) : cell.length === 0 ? (
|
||||
<div
|
||||
className={`rounded border py-1.5 transition-colors ${
|
||||
onClick={(e) => clickCeldaLibre(e, date, slot, col.doctorId)}
|
||||
className={`cursor-pointer rounded border py-1.5 transition-colors ${
|
||||
quickFilter === 'libres'
|
||||
? 'bg-brand-mint border-emerald-700'
|
||||
: 'border-dashed border-theme-border hover:bg-theme-accent-bg'
|
||||
@@ -1481,7 +1524,11 @@ const Agenda: FC = () => {
|
||||
{dayBloqueo.motivo || 'Bloqueado'}
|
||||
</div>
|
||||
) : dayApts.length === 0 ? (
|
||||
<div className="rounded border border-dashed border-theme-border py-1.5 text-center text-[10px] text-theme-muted">
|
||||
<div
|
||||
onClick={(e) => clickCeldaLibre(e, d, null, col.doctorId)}
|
||||
className="cursor-pointer rounded border border-dashed border-theme-border py-1.5 text-center text-[10px] text-theme-muted hover:bg-theme-accent-bg"
|
||||
title="Nueva cita este día"
|
||||
>
|
||||
Libre
|
||||
</div>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user