fix: prevenir multiplos agendamentos travando botao durante a submissao
Build and Deploy (Gitea Actions) / build-and-deploy (push) Has been cancelled
Details
Build and Deploy (Gitea Actions) / build-and-deploy (push) Has been cancelled
Details
This commit is contained in:
parent
dfcfdae1f8
commit
094640bffb
|
|
@ -62,6 +62,7 @@ export default function Agenda() {
|
|||
const [newDate, setNewDate] = useState(today.toISOString().split('T')[0]);
|
||||
const [newTime, setNewTime] = useState('10:00');
|
||||
const [newNotes, setNewNotes] = useState('');
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (professionals.length > 0 && !newProf) {
|
||||
|
|
@ -247,8 +248,8 @@ export default function Agenda() {
|
|||
</div>
|
||||
</div>
|
||||
<div className="modal-footer">
|
||||
<button className="btn btn-secondary" onClick={() => setShowModal(false)}>Cancelar</button>
|
||||
<button className="btn btn-primary" onClick={async () => {
|
||||
<button className="btn btn-secondary" disabled={submitting} onClick={() => setShowModal(false)}>Cancelar</button>
|
||||
<button className="btn btn-primary" disabled={submitting} onClick={async () => {
|
||||
const [h, m] = newTime.split(':').map(Number);
|
||||
const selectedSvc = services.find(s => s.id === newService);
|
||||
|
||||
|
|
@ -258,6 +259,7 @@ export default function Agenda() {
|
|||
|
||||
const slug = localStorage.getItem('agendapro_tenant_slug') || 'barbearia-premium';
|
||||
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const res = await fetch('/api/tenant/agenda', {
|
||||
method: 'POST',
|
||||
|
|
@ -288,8 +290,10 @@ export default function Agenda() {
|
|||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
}}>Agendar</button>
|
||||
}}>{submitting ? 'Agendando...' : 'Agendar'}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue