♻️ adapt zod schema to v4 and move form description below the inptu

This commit is contained in:
Fred KISSIE
2025-11-18 01:07:46 +01:00
parent ee7e7778b6
commit 66b01b764f
2 changed files with 53 additions and 57 deletions

View File

@@ -29,17 +29,14 @@ import { getOrgTierData } from "#private/lib/billing";
import { TierId } from "@server/lib/billing/tiers"; import { TierId } from "@server/lib/billing/tiers";
import { build } from "@server/build"; import { build } from "@server/build";
const paramsSchema = z const paramsSchema = z.strictObject({
.object({
orgId: z.string() orgId: z.string()
}) });
.strict();
const bodySchema = z const bodySchema = z.strictObject({
.object({ logoUrl: z.url(),
logoUrl: z.string().url(), logoWidth: z.coerce.number<number>().min(1),
logoWidth: z.coerce.number().min(1), logoHeight: z.coerce.number<number>().min(1),
logoHeight: z.coerce.number().min(1),
resourceTitle: z.string(), resourceTitle: z.string(),
resourceSubtitle: z.string().optional(), resourceSubtitle: z.string().optional(),
orgTitle: z.string().optional(), orgTitle: z.string().optional(),
@@ -48,8 +45,7 @@ const bodySchema = z
.string() .string()
.regex(/^#([0-9a-f]{6}|[0-9a-f]{3})$/i) .regex(/^#([0-9a-f]{6}|[0-9a-f]{3})$/i)
.optional() .optional()
}) });
.strict();
export type UpdateLoginPageBrandingBody = z.infer<typeof bodySchema>; export type UpdateLoginPageBrandingBody = z.infer<typeof bodySchema>;

View File

@@ -50,10 +50,7 @@ export type AuthPageCustomizationProps = {
}; };
const AuthPageFormSchema = z.object({ const AuthPageFormSchema = z.object({
logoUrl: z logoUrl: z.url().refine(
.string()
.url()
.refine(
async (url) => { async (url) => {
try { try {
const response = await fetch(url); const response = await fetch(url);
@@ -68,11 +65,11 @@ const AuthPageFormSchema = z.object({
} }
}, },
{ {
message: "Invalid logo URL, must be a valid image URL" error: "Invalid logo URL, must be a valid image URL"
} }
), ),
logoWidth: z.coerce.number().min(1), logoWidth: z.coerce.number<number>().min(1),
logoHeight: z.coerce.number().min(1), logoHeight: z.coerce.number<number>().min(1),
orgTitle: z.string().optional(), orgTitle: z.string().optional(),
orgSubtitle: z.string().optional(), orgSubtitle: z.string().optional(),
resourceTitle: z.string(), resourceTitle: z.string(),
@@ -272,7 +269,7 @@ export default function AuthPageBrandingForm({
)} )}
/> />
<span className="self-center relative top-2.5"> <span className="relative top-8">
<XIcon className="text-muted-foreground size-4" /> <XIcon className="text-muted-foreground size-4" />
</span> </span>
@@ -300,7 +297,7 @@ export default function AuthPageBrandingForm({
<> <>
<Separator /> <Separator />
<div className="flex flex-col gap-3"> <div className="flex flex-col gap-5">
<FormField <FormField
control={form.control} control={form.control}
name="orgTitle" name="orgTitle"
@@ -311,6 +308,10 @@ export default function AuthPageBrandingForm({
"brandingOrgTitle" "brandingOrgTitle"
)} )}
</FormLabel> </FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormDescription> <FormDescription>
{t( {t(
"brandingOrgDescription", "brandingOrgDescription",
@@ -320,9 +321,6 @@ export default function AuthPageBrandingForm({
} }
)} )}
</FormDescription> </FormDescription>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
@@ -337,6 +335,10 @@ export default function AuthPageBrandingForm({
"brandingOrgSubtitle" "brandingOrgSubtitle"
)} )}
</FormLabel> </FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormDescription> <FormDescription>
{t( {t(
"brandingOrgDescription", "brandingOrgDescription",
@@ -346,9 +348,6 @@ export default function AuthPageBrandingForm({
} }
)} )}
</FormDescription> </FormDescription>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
@@ -359,7 +358,7 @@ export default function AuthPageBrandingForm({
<Separator /> <Separator />
<div className="flex flex-col gap-3"> <div className="flex flex-col gap-5">
<FormField <FormField
control={form.control} control={form.control}
name="resourceTitle" name="resourceTitle"
@@ -368,6 +367,10 @@ export default function AuthPageBrandingForm({
<FormLabel> <FormLabel>
{t("brandingResourceTitle")} {t("brandingResourceTitle")}
</FormLabel> </FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormDescription> <FormDescription>
{t( {t(
"brandingResourceDescription", "brandingResourceDescription",
@@ -377,9 +380,6 @@ export default function AuthPageBrandingForm({
} }
)} )}
</FormDescription> </FormDescription>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
@@ -394,6 +394,9 @@ export default function AuthPageBrandingForm({
"brandingResourceSubtitle" "brandingResourceSubtitle"
)} )}
</FormLabel> </FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormDescription> <FormDescription>
{t( {t(
"brandingResourceDescription", "brandingResourceDescription",
@@ -403,9 +406,6 @@ export default function AuthPageBrandingForm({
} }
)} )}
</FormDescription> </FormDescription>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}