diff --git a/apps/web/src/cockpits/ger/PoliticasPage.tsx b/apps/web/src/cockpits/ger/PoliticasPage.tsx
index a57f1da..6fdd577 100644
--- a/apps/web/src/cockpits/ger/PoliticasPage.tsx
+++ b/apps/web/src/cockpits/ger/PoliticasPage.tsx
@@ -11,6 +11,7 @@ import {
Select,
Skeleton,
Space,
+ Switch,
Table,
Tabs,
Tag,
@@ -232,6 +233,7 @@ interface PromocaoForm {
grpProd?: string;
descPct: number;
periodo: [dayjs.Dayjs, dayjs.Dayjs];
+ ativa?: boolean;
}
function TabPromocoes() {
@@ -271,10 +273,20 @@ function TabPromocoes() {
grpProd: p.grpProd ?? undefined,
descPct: p.descPct,
periodo: [dayjs(p.dataInicio), dayjs(p.dataFim)],
+ ativa: p.ativa,
});
setModalOpen(true);
}
+ async function toggleAtiva(p: Promocao, ativa: boolean) {
+ try {
+ await updateMutation.mutateAsync({ id: p.id, body: { ativa } });
+ } catch {
+ return; // erro já notificado pelo handler global do QueryClient
+ }
+ void msg.success(ativa ? 'Promocao ativada' : 'Promocao desativada');
+ }
+
async function handleSubmit(values: PromocaoForm) {
const [inicio, fim] = values.periodo;
try {
@@ -288,6 +300,7 @@ function TabPromocoes() {
descPct: values.descPct,
dataInicio: inicio.format('YYYY-MM-DD'),
dataFim: fim.format('YYYY-MM-DD'),
+ ativa: values.ativa ?? true,
},
});
void msg.success('Promocao atualizada');
@@ -362,6 +375,19 @@ function TabPromocoes() {
return Ativa;
},
},
+ {
+ title: 'Ativa',
+ width: 70,
+ align: 'center' as const,
+ render: (_: unknown, row: Promocao) => (
+ void toggleAtiva(row, checked)}
+ />
+ ),
+ },
{
title: '',
width: 100,
@@ -446,6 +472,9 @@ function TabPromocoes() {
optionFilterProp="label"
/>
+
+
+
) : (
<>
@@ -509,6 +538,7 @@ interface RegraForm {
codSubgrupo?: number;
descPct: number;
periodo: [dayjs.Dayjs, dayjs.Dayjs];
+ ativa?: boolean;
}
function TabRegras() {
@@ -575,10 +605,20 @@ function TabRegras() {
codSubgrupo: r.codSubgrupo ?? undefined,
descPct: r.descPct,
periodo: [dayjs(r.dataInicio), dayjs(r.dataFim)],
+ ativa: r.ativa,
});
setModalOpen(true);
}
+ async function toggleAtiva(r: RegraDesconto, ativa: boolean) {
+ try {
+ await updateMutation.mutateAsync({ id: r.id, body: { ativa } });
+ } catch {
+ return; // erro já notificado pelo handler global do QueryClient
+ }
+ void msg.success(ativa ? 'Regra ativada' : 'Regra desativada');
+ }
+
async function handleSubmit(values: RegraForm) {
const [inicio, fim] = values.periodo;
try {
@@ -593,6 +633,7 @@ function TabRegras() {
descPct: values.descPct,
dataInicio: inicio.format('YYYY-MM-DD'),
dataFim: fim.format('YYYY-MM-DD'),
+ ativa: values.ativa ?? true,
},
});
void msg.success('Regra atualizada');
@@ -678,6 +719,19 @@ function TabRegras() {
return Ativa;
},
},
+ {
+ title: 'Ativa',
+ width: 70,
+ align: 'center' as const,
+ render: (_: unknown, row: RegraDesconto) => (
+ void toggleAtiva(row, checked)}
+ />
+ ),
+ },
{
title: '',
width: 100,
@@ -783,6 +837,9 @@ function TabRegras() {
optionFilterProp="label"
/>
+
+
+
) : (
<>