feat(households): hane rolleri, servis, DAL hane kapsamı ve denetim kaydı
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { z } from "zod";
|
||||
import { HOUSEHOLD_ROLES } from "../../features/households/types";
|
||||
import { tr } from "../../i18n/tr";
|
||||
|
||||
export const householdRoleSchema = z.enum(HOUSEHOLD_ROLES);
|
||||
|
||||
export const householdNameSchema = z
|
||||
.string()
|
||||
.trim()
|
||||
.min(2, tr.validation.householdNameMin)
|
||||
.max(80, tr.validation.householdNameMax);
|
||||
|
||||
/** Hane ayarları formu (owner). Tutarlar kuruş cinsinden tamsayı. */
|
||||
export const householdSettingsSchema = z.object({
|
||||
name: householdNameSchema,
|
||||
budgetMonthStartDay: z.coerce.number().int().min(1).max(28),
|
||||
installmentBudgetMode: z.enum(["per_installment", "purchase_month"]),
|
||||
dailyPlanMode: z.enum(["even", "previous_month_pattern"]),
|
||||
includePrivateAccountsInTotals: z.boolean(),
|
||||
extraStoreSavingThresholdMinor: z.coerce.number().int().min(0).max(100_000_00),
|
||||
});
|
||||
|
||||
export const householdCreateSchema = z.object({
|
||||
name: householdNameSchema,
|
||||
/** İlk sahip (owner) olacak kullanıcı. */
|
||||
ownerUserId: z.string().regex(/^[a-f0-9]{24}$/i, tr.validation.selectUser),
|
||||
});
|
||||
|
||||
export const addMemberSchema = z.object({
|
||||
userId: z.string().regex(/^[a-f0-9]{24}$/i, tr.validation.selectUser),
|
||||
role: householdRoleSchema,
|
||||
});
|
||||
|
||||
export type HouseholdSettingsInput = z.input<typeof householdSettingsSchema>;
|
||||
export type HouseholdSettings = z.output<typeof householdSettingsSchema>;
|
||||
export type HouseholdCreateInput = z.input<typeof householdCreateSchema>;
|
||||
export type AddMemberInput = z.input<typeof addMemberSchema>;
|
||||
Reference in New Issue
Block a user