Compare commits
2 Commits
a30ec6f952
...
094640bffb
| Author | SHA1 | Date |
|---|---|---|
|
|
094640bffb | |
|
|
dfcfdae1f8 |
|
|
@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS plans (
|
||||||
name VARCHAR(100) NOT NULL,
|
name VARCHAR(100) NOT NULL,
|
||||||
slug VARCHAR(100) UNIQUE NOT NULL,
|
slug VARCHAR(100) UNIQUE NOT NULL,
|
||||||
description TEXT,
|
description TEXT,
|
||||||
|
price NUMERIC(10,2) NOT NULL DEFAULT 0,
|
||||||
price_monthly NUMERIC(10,2) NOT NULL DEFAULT 0,
|
price_monthly NUMERIC(10,2) NOT NULL DEFAULT 0,
|
||||||
price_yearly NUMERIC(10,2) NOT NULL DEFAULT 0,
|
price_yearly NUMERIC(10,2) NOT NULL DEFAULT 0,
|
||||||
max_professionals INT NOT NULL DEFAULT 1,
|
max_professionals INT NOT NULL DEFAULT 1,
|
||||||
|
|
@ -201,6 +202,7 @@ CREATE TABLE IF NOT EXISTS appointments (
|
||||||
notes TEXT,
|
notes TEXT,
|
||||||
client_name VARCHAR(200), -- for walk-ins
|
client_name VARCHAR(200), -- for walk-ins
|
||||||
client_phone VARCHAR(20),
|
client_phone VARCHAR(20),
|
||||||
|
client_email VARCHAR(200),
|
||||||
source VARCHAR(20) DEFAULT 'manual', -- manual, online, whatsapp
|
source VARCHAR(20) DEFAULT 'manual', -- manual, online, whatsapp
|
||||||
cancelled_at TIMESTAMPTZ,
|
cancelled_at TIMESTAMPTZ,
|
||||||
cancellation_reason TEXT,
|
cancellation_reason TEXT,
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ export default function Agenda() {
|
||||||
const [newDate, setNewDate] = useState(today.toISOString().split('T')[0]);
|
const [newDate, setNewDate] = useState(today.toISOString().split('T')[0]);
|
||||||
const [newTime, setNewTime] = useState('10:00');
|
const [newTime, setNewTime] = useState('10:00');
|
||||||
const [newNotes, setNewNotes] = useState('');
|
const [newNotes, setNewNotes] = useState('');
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (professionals.length > 0 && !newProf) {
|
if (professionals.length > 0 && !newProf) {
|
||||||
|
|
@ -247,8 +248,8 @@ export default function Agenda() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<button className="btn btn-secondary" onClick={() => setShowModal(false)}>Cancelar</button>
|
<button className="btn btn-secondary" disabled={submitting} onClick={() => setShowModal(false)}>Cancelar</button>
|
||||||
<button className="btn btn-primary" onClick={async () => {
|
<button className="btn btn-primary" disabled={submitting} onClick={async () => {
|
||||||
const [h, m] = newTime.split(':').map(Number);
|
const [h, m] = newTime.split(':').map(Number);
|
||||||
const selectedSvc = services.find(s => s.id === newService);
|
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';
|
const slug = localStorage.getItem('agendapro_tenant_slug') || 'barbearia-premium';
|
||||||
|
|
||||||
|
setSubmitting(true);
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/tenant/agenda', {
|
const res = await fetch('/api/tenant/agenda', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
@ -288,8 +290,10 @@ export default function Agenda() {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
} finally {
|
||||||
|
setSubmitting(false);
|
||||||
}
|
}
|
||||||
}}>Agendar</button>
|
}}>{submitting ? 'Agendando...' : 'Agendar'}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue