mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 11:01:45 +00:00
feat: endurece mutações financeiras e permite zerar conta
This commit is contained in:
@@ -49,16 +49,17 @@ const DASHBOARD_ENTITIES: ReadonlySet<string> = new Set([
|
||||
|
||||
/**
|
||||
* Revalidates paths for a specific entity.
|
||||
* Also invalidates the dashboard "use cache" tag for financial entities.
|
||||
* Also invalidates the user-scoped dashboard cache tag for financial entities.
|
||||
* @param entity - The entity type
|
||||
*/
|
||||
export function revalidateForEntity(
|
||||
entity: keyof typeof revalidateConfig,
|
||||
userId: string,
|
||||
): void {
|
||||
revalidateConfig[entity].forEach((path) => revalidatePath(path));
|
||||
|
||||
// Invalidate dashboard cache for financial mutations
|
||||
// Invalidate dashboard cache for financial mutations.
|
||||
if (DASHBOARD_ENTITIES.has(entity)) {
|
||||
revalidateTag("dashboard", "max");
|
||||
revalidateTag(`dashboard-${userId}`, "max");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,21 @@ export const uuidSchema = (entityName: string = "ID") =>
|
||||
/**
|
||||
* Optional/nullable decimal string schema
|
||||
*/
|
||||
export const optionalDecimalSchema = z
|
||||
.string()
|
||||
.trim()
|
||||
.optional()
|
||||
.transform((value) =>
|
||||
value && value.length > 0 ? value.replace(",", ".") : null,
|
||||
)
|
||||
.refine(
|
||||
(value) => value === null || !Number.isNaN(Number.parseFloat(value)),
|
||||
"Informe um valor numérico válido.",
|
||||
)
|
||||
.transform((value) => (value === null ? null : Number.parseFloat(value)));
|
||||
export const optionalDecimalSchema = z.union([
|
||||
z.number().nullable(),
|
||||
z
|
||||
.string()
|
||||
.trim()
|
||||
.optional()
|
||||
.transform((value) =>
|
||||
value && value.length > 0 ? value.replace(",", ".") : null,
|
||||
)
|
||||
.refine(
|
||||
(value) => value === null || !Number.isNaN(Number.parseFloat(value)),
|
||||
"Informe um valor numérico válido.",
|
||||
)
|
||||
.transform((value) => (value === null ? null : Number.parseFloat(value))),
|
||||
]);
|
||||
|
||||
/**
|
||||
* Day of month schema (1-31)
|
||||
|
||||
Reference in New Issue
Block a user