Ajuste Convenios e Particular

This commit is contained in:
Leonardo
2026-03-13 21:09:34 -03:00
parent 06fb369beb
commit 587079e414
13 changed files with 971 additions and 277 deletions

View File

@@ -9,7 +9,7 @@ import { useServices } from '@/features/agenda/composables/useServices'
const toast = useToast()
const tenantStore = useTenantStore()
const { services, loading, error: servicesError, load, save, remove } = useServices()
const { services, loading, error: servicesError, load, save, toggle, remove } = useServices()
const ownerId = ref(null)
const tenantId = ref(null)
@@ -97,10 +97,19 @@ async function saveNew () {
}
}
async function toggleService (svc) {
try {
await toggle(svc.id, !svc.active)
toast.add({ severity: 'success', summary: svc.active ? 'Desativado' : 'Ativado', detail: `Serviço ${svc.active ? 'desativado' : 'ativado'}.`, life: 3000 })
} catch {
toast.add({ severity: 'error', summary: 'Erro', detail: servicesError.value || 'Falha ao atualizar.', life: 4000 })
}
}
async function confirmRemove (id) {
try {
await remove(id)
toast.add({ severity: 'success', summary: 'Removido', detail: 'Serviço removido.', life: 3000 })
toast.add({ severity: 'success', summary: 'Removido', detail: 'Serviço removido permanentemente.', life: 3000 })
} catch {
toast.add({ severity: 'error', summary: 'Erro', detail: servicesError.value || 'Falha ao remover.', life: 4000 })
}
@@ -242,7 +251,7 @@ onMounted(async () => {
</Card>
<!-- Lista de serviços -->
<Card v-for="svc in services" :key="svc.id">
<Card v-for="svc in services" :key="svc.id" :class="{ 'opacity-60': !svc.active }">
<template #content>
<!-- Modo edição -->
@@ -305,7 +314,15 @@ onMounted(async () => {
</div>
</div>
<div class="flex items-center gap-2">
<Tag value="Ativo" severity="success" />
<Tag :value="svc.active ? 'Ativo' : 'Inativo'" :severity="svc.active ? 'success' : 'secondary'" />
<Button
:icon="svc.active ? 'pi pi-eye-slash' : 'pi pi-eye'"
:severity="svc.active ? 'secondary' : 'success'"
outlined
size="small"
v-tooltip.top="svc.active ? 'Desativar' : 'Ativar'"
@click="toggleService(svc)"
/>
<Button icon="pi pi-pencil" severity="secondary" outlined size="small" v-tooltip.top="'Editar'" @click="startEdit(svc)" />
<Button icon="pi pi-trash" severity="danger" outlined size="small" v-tooltip.top="'Remover'" @click="confirmRemove(svc.id)" />
</div>