mudanças no dashboard
This commit is contained in:
@@ -47,6 +47,7 @@ import {
|
||||
Store,
|
||||
Clock,
|
||||
ArrowRight,
|
||||
CheckCircle2,
|
||||
} from 'lucide-react';
|
||||
|
||||
const periods: Record<string, (date: Date) => boolean> = {
|
||||
@@ -136,6 +137,12 @@ function DashboardInner({ shop }: { shop: BarberShop }) {
|
||||
const [barberName, setBarberName] = useState('');
|
||||
const [barberSpecs, setBarberSpecs] = useState('');
|
||||
|
||||
// Settings states
|
||||
const [editShopName, setEditShopName] = useState(shop.name);
|
||||
const [editShopAddress, setEditShopAddress] = useState(shop.address || '');
|
||||
const [isSavingSettings, setIsSavingSettings] = useState(false);
|
||||
const [showSaveSuccess, setShowSaveSuccess] = useState(false);
|
||||
|
||||
const periodMatch = periods[period];
|
||||
|
||||
// Agendamentos filtrados pela barbearia logada e pela janela de tempo selecionada
|
||||
@@ -332,6 +339,24 @@ function DashboardInner({ shop }: { shop: BarberShop }) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSaveSettings = async () => {
|
||||
setIsSavingSettings(true);
|
||||
setShowSaveSuccess(false);
|
||||
try {
|
||||
await updateShopDetails(shop.id, {
|
||||
name: editShopName,
|
||||
address: editShopAddress,
|
||||
});
|
||||
setShowSaveSuccess(true);
|
||||
setTimeout(() => setShowSaveSuccess(false), 3000);
|
||||
} catch (err) {
|
||||
console.error('Error saving settings:', err);
|
||||
alert('Erro ao guardar as definições. Tente novamente.');
|
||||
} finally {
|
||||
setIsSavingSettings(false);
|
||||
}
|
||||
};
|
||||
|
||||
const tabs = [
|
||||
{ id: 'overview' as TabId, label: 'Visão Geral', icon: BarChart3 },
|
||||
{ id: 'appointments' as TabId, label: 'Agendamentos', icon: Calendar },
|
||||
@@ -1196,6 +1221,41 @@ function DashboardInner({ shop }: { shop: BarberShop }) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="pt-6 border-t border-slate-200">
|
||||
<h3 className="text-sm font-semibold text-slate-900 mb-4">Informações da Barbearia</h3>
|
||||
<div className="space-y-4">
|
||||
<Input
|
||||
label="Nome da Barbearia"
|
||||
value={editShopName}
|
||||
onChange={(e) => setEditShopName(e.target.value)}
|
||||
placeholder="O nome da sua barbearia"
|
||||
/>
|
||||
<Input
|
||||
label="Morada Completa"
|
||||
value={editShopAddress}
|
||||
onChange={(e) => setEditShopAddress(e.target.value)}
|
||||
placeholder="Rua, Número, Código Postal, Localidade"
|
||||
/>
|
||||
|
||||
<div className="pt-2 flex items-center gap-4">
|
||||
<Button
|
||||
onClick={handleSaveSettings}
|
||||
disabled={isSavingSettings}
|
||||
className="bg-indigo-600 hover:bg-indigo-700 w-full sm:w-auto"
|
||||
>
|
||||
{isSavingSettings ? 'A Guardar...' : 'Guardar Alterações'}
|
||||
</Button>
|
||||
|
||||
{showSaveSuccess && (
|
||||
<span className="text-sm font-medium text-emerald-600 flex items-center gap-1 animate-in fade-in duration-300">
|
||||
<CheckCircle2 size={16} />
|
||||
Guardado com sucesso!
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user