Add image upload and edit functions

This commit is contained in:
2025-12-20 16:34:50 +01:00
parent 96fa12993b
commit dfb6f7042a
72 changed files with 7413 additions and 81 deletions

View File

@ -0,0 +1,9 @@
import { z } from "zod/v4"
export const albumSchema = z.object({
name: z.string().min(3, "Name is required. Min 3 characters."),
slug: z.string().min(3, "Slug is required. Min 3 characters.").regex(/^[a-z]+$/, "Only lowercase letters are allowed (no numbers, spaces, or uppercase)"),
description: z.string().optional(),
})
export type albumSchema = z.infer<typeof albumSchema>

View File

@ -0,0 +1,9 @@
import { z } from "zod/v4"
export const categorySchema = z.object({
name: z.string().min(3, "Name is required. Min 3 characters."),
slug: z.string().min(3, "Slug is required. Min 3 characters.").regex(/^[a-z]+$/, "Only lowercase letters are allowed (no numbers, spaces, or uppercase)"),
description: z.string().optional(),
})
export type categorySchema = z.infer<typeof categorySchema>

View File

@ -0,0 +1,47 @@
import { z } from "zod/v4";
export const fileUploadSchema = z.object({
file: z
.custom<FileList>()
.refine((files) => files instanceof FileList && files.length > 0, {
message: "Image file is required",
}),
})
const isFileList = (v: unknown): v is FileList =>
typeof FileList !== "undefined" && v instanceof FileList;
export const fileBulkUploadSchema = z.object({
file: z
.custom<FileList>((v) => isFileList(v), "Please choose one or more files")
.refine((files) => files.length > 0, {
message: "At least one image file is required",
}),
})
export const artworkSchema = z.object({
name: z.string().min(1, "Name is required"),
needsWork: z.boolean(),
nsfw: z.boolean(),
published: z.boolean(),
setAsHeader: z.boolean(),
altText: z.string().optional(),
description: z.string().optional(),
notes: z.string().optional(),
month: z.number().optional(),
year: z.number().optional(),
creationDate: z.date().optional(),
// fileId: z.string(),
// albumId: z.string().optional(),
// typeId: z.string().optional(),
metadataId: z.string().optional(),
categoryIds: z.array(z.string()).optional(),
colorIds: z.array(z.string()).optional(),
// sortContextIds: z.array(z.string()).optional(),
tagIds: z.array(z.string()).optional(),
variantIds: z.array(z.string()).optional(),
})

View File

@ -0,0 +1,10 @@
import { z } from "zod/v4"
export const tagSchema = z.object({
name: z.string().min(3, "Name is required. Min 3 characters."),
slug: z.string().min(3, "Slug is required. Min 3 characters.").regex(/^[a-z]+$/, "Only lowercase letters are allowed (no numbers, spaces, or uppercase)"),
description: z.string().optional(),
})
export type tagSchema = z.infer<typeof tagSchema>

View File

@ -0,0 +1,9 @@
import { z } from "zod/v4"
export const typeSchema = z.object({
name: z.string().min(3, "Name is required. Min 3 characters."),
slug: z.string().min(3, "Slug is required. Min 3 characters.").regex(/^[a-z]+$/, "Only lowercase letters are allowed (no numbers, spaces, or uppercase)"),
description: z.string().optional(),
})
export type typeSchema = z.infer<typeof typeSchema>