refactor: move modals to seperate package (#1135)

* refactor: move modals to seperate package

* fix: format issue

* fix: lint issues

* fix: format issue

* fix: only used as type
This commit is contained in:
Meier Lukas
2024-09-16 19:53:37 +02:00
committed by GitHub
parent 3ef478c53a
commit 6738296830
44 changed files with 1692 additions and 1389 deletions

View File

@@ -69,23 +69,15 @@ const permissionsSchema = z.object({
id: z.string(),
});
export const createOldmarrImportConfigurationSchema = (existingBoardNames: string[]) =>
z.object({
name: boardNameSchema.refine(
(value) => {
return existingBoardNames.every((name) => name.toLowerCase().trim() !== value.toLowerCase().trim());
},
{
params: createCustomErrorParams("boardAlreadyExists"),
},
),
onlyImportApps: z.boolean().default(false),
distinctAppsByHref: z.boolean().default(true),
screenSize: z.enum(["lg", "md", "sm"]).default("lg"),
sidebarBehaviour: z.enum(["remove-items", "last-section"]).default("last-section"),
});
export const oldmarrImportConfigurationSchema = z.object({
name: boardNameSchema,
onlyImportApps: z.boolean().default(false),
distinctAppsByHref: z.boolean().default(true),
screenSize: z.enum(["lg", "md", "sm"]).default("lg"),
sidebarBehaviour: z.enum(["remove-items", "last-section"]).default("last-section"),
});
export type OldmarrImportConfiguration = z.infer<ReturnType<typeof createOldmarrImportConfigurationSchema>>;
export type OldmarrImportConfiguration = z.infer<typeof oldmarrImportConfigurationSchema>;
export const superRefineJsonImportFile = (value: File | null, context: z.RefinementCtx) => {
if (!value) {
@@ -121,7 +113,7 @@ export const superRefineJsonImportFile = (value: File | null, context: z.Refinem
const importJsonFileSchema = zfd.formData({
file: zfd.file().superRefine(superRefineJsonImportFile),
configuration: zfd.json(createOldmarrImportConfigurationSchema([])),
configuration: zfd.json(oldmarrImportConfigurationSchema),
});
const savePermissionsSchema = createSavePermissionsSchema(zodEnumFromArray(boardPermissions));

View File

@@ -26,5 +26,5 @@ export {
type BoardItemAdvancedOptions,
} from "./shared";
export { passwordRequirements } from "./user";
export { createOldmarrImportConfigurationSchema, superRefineJsonImportFile } from "./board";
export { oldmarrImportConfigurationSchema, superRefineJsonImportFile } from "./board";
export type { OldmarrImportConfiguration } from "./board";