Refactor code

This commit is contained in:
2026-02-03 12:17:47 +01:00
parent ea5eb6fa59
commit 8572e22c5d
185 changed files with 1268 additions and 1458 deletions

View File

@ -0,0 +1,39 @@
import { z } from "zod/v4";
export const createArtworkTimelapseUploadSchema = z.object({
artworkId: z.string().min(1),
fileName: z.string().min(1),
mimeType: z.string().min(1),
sizeBytes: z.number().int().positive(),
});
export type CreateArtworkTimelapseUploadInput = z.infer<
typeof createArtworkTimelapseUploadSchema
>;
export const confirmArtworkTimelapseUploadSchema = z.object({
artworkId: z.string().min(1),
s3Key: z.string().min(1),
fileName: z.string().min(1),
mimeType: z.string().min(1),
sizeBytes: z.number().int().positive(),
});
export type ConfirmArtworkTimelapseUploadInput = z.infer<
typeof confirmArtworkTimelapseUploadSchema
>;
export const setArtworkTimelapseEnabledSchema = z.object({
artworkId: z.string().min(1),
enabled: z.boolean(),
});
export type SetArtworkTimelapseEnabledInput = z.infer<
typeof setArtworkTimelapseEnabledSchema
>;
export const deleteArtworkTimelapseSchema = z.object({
artworkId: z.string().min(1),
});
export type DeleteArtworkTimelapseInput = z.infer<typeof deleteArtworkTimelapseSchema>;

9
src/schemas/auth.ts Normal file
View File

@ -0,0 +1,9 @@
import { z } from "zod/v4";
export const registerFirstUserSchema = z.object({
name: z.string().min(1).max(200),
email: z.string().email().max(320),
password: z.string().min(8).max(128),
});
export type RegisterFirstUserInput = z.infer<typeof registerFirstUserSchema>;

View File

@ -0,0 +1,34 @@
import { z } from "zod/v4";
export const publicCommissionRequestSchema = z
.object({
typeId: z.string().min(1).optional().nullable(),
customCardId: z.string().min(1).optional().nullable(),
optionId: z.string().min(1).optional().nullable(),
extraIds: z.array(z.string().min(1)).default([]),
customerName: z.string().min(1).max(200),
customerEmail: z.string().email().max(320),
customerSocials: z.string().max(2000).optional().nullable(),
message: z.string().min(1).max(20_000),
})
.superRefine((data, ctx) => {
const hasType = Boolean(data.typeId);
const hasCustom = Boolean(data.customCardId);
if (!hasType && !hasCustom) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["typeId"],
message: "Missing commission type or custom card",
});
}
if (hasType && hasCustom) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["typeId"],
message: "Only one of typeId or customCardId is allowed",
});
}
});
export type PublicCommissionRequestInput = z.infer<typeof publicCommissionRequestSchema>;

View File

@ -0,0 +1,22 @@
import { z } from "zod/v4";
import { commissionStatusSchema } from "./requests";
export const triStateSchema = z.enum(["any", "true", "false"]);
export const sortingSchema = z.array(
z.object({
id: z.string(),
desc: z.boolean(),
})
);
export const filtersSchema = z.object({
q: z.string().optional(),
email: z.string().optional(),
status: z.union([z.literal("any"), commissionStatusSchema]).default("any"),
hasFiles: triStateSchema.default("any"),
});
export type CommissionRequestsTableSorting = z.infer<typeof sortingSchema>;
export type CommissionRequestsTableFilters = z.infer<typeof filtersSchema>;

View File

@ -0,0 +1,14 @@
import { z } from "zod/v4";
import { commissionStatusSchema } from "./requests";
export const updateCommissionRequestSchema = z.object({
id: z.string().min(1),
status: commissionStatusSchema,
customerName: z.string().min(1).max(200),
customerEmail: z.string().email().max(320),
customerSocials: z.string().max(2000).optional().nullable(),
message: z.string().min(1).max(20_000),
});
export type UpdateCommissionRequestInput = z.infer<typeof updateCommissionRequestSchema>;

View File

@ -0,0 +1,12 @@
import { z } from "zod/v4";
import { COMMISSION_STATUSES } from "@/lib/commissions/kanban";
export const updateCommissionRequestStatusSchema = z.object({
id: z.string().min(1),
status: z.enum(COMMISSION_STATUSES),
});
export type UpdateCommissionRequestStatusInput = z.infer<
typeof updateCommissionRequestStatusSchema
>;

16
src/schemas/users.ts Normal file
View File

@ -0,0 +1,16 @@
import { z } from "zod/v4";
export const createUserSchema = z.object({
name: z.string().min(1).max(200),
email: z.string().email().max(320),
password: z.string().min(8).max(128),
role: z.enum(["user", "admin"]).default("user"),
});
export type CreateUserInput = z.infer<typeof createUserSchema>;
export const resendVerificationSchema = z.object({
email: z.string().email(),
});
export type ResendVerificationInput = z.infer<typeof resendVerificationSchema>;