mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-07 11:16:37 +00:00
♻️ adapt zod schema to v4 and move form description below the inptu
This commit is contained in:
@@ -29,27 +29,23 @@ 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(),
|
orgSubtitle: z.string().optional(),
|
||||||
orgSubtitle: z.string().optional(),
|
primaryColor: z
|
||||||
primaryColor: 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>;
|
||||||
|
|
||||||
|
|||||||
@@ -50,29 +50,26 @@ export type AuthPageCustomizationProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const AuthPageFormSchema = z.object({
|
const AuthPageFormSchema = z.object({
|
||||||
logoUrl: z
|
logoUrl: z.url().refine(
|
||||||
.string()
|
async (url) => {
|
||||||
.url()
|
try {
|
||||||
.refine(
|
const response = await fetch(url);
|
||||||
async (url) => {
|
return (
|
||||||
try {
|
response.status === 200 &&
|
||||||
const response = await fetch(url);
|
(response.headers.get("content-type") ?? "").startsWith(
|
||||||
return (
|
"image/"
|
||||||
response.status === 200 &&
|
)
|
||||||
(response.headers.get("content-type") ?? "").startsWith(
|
);
|
||||||
"image/"
|
} catch (error) {
|
||||||
)
|
return false;
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
message: "Invalid logo URL, must be a valid image URL"
|
|
||||||
}
|
}
|
||||||
),
|
},
|
||||||
logoWidth: z.coerce.number().min(1),
|
{
|
||||||
logoHeight: z.coerce.number().min(1),
|
error: "Invalid logo URL, must be a valid image URL"
|
||||||
|
}
|
||||||
|
),
|
||||||
|
logoWidth: z.coerce.number<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>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user