Skip to content

Commit 158a08a

Browse files
authored
[TOOL-3598] Dashboard: Add error message in create ecosystem form for image size (#6411)
1 parent 67354dc commit 158a08a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/create/components/client/create-ecosystem-form.client.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ const formSchema = z.object({
3131
.refine((name) => /^[a-zA-Z0-9 ]*$/.test(name), {
3232
message: "Name can only contain letters, numbers and spaces",
3333
}),
34-
logo: z.instanceof(File, {
35-
message: "Logo is required",
36-
}),
34+
logo: z
35+
.instanceof(File, {
36+
message: "Logo is required",
37+
})
38+
.refine((file) => file.size <= 500 * 1024, {
39+
message: "Logo size must be less than 500KB",
40+
}),
3741
permission: z.union([z.literal("PARTNER_WHITELIST"), z.literal("ANYONE")]),
3842
});
3943

@@ -118,8 +122,9 @@ export function CreateEcosystemForm(props: { teamSlug: string }) {
118122
accept="image/png, image/jpeg"
119123
onUpload={(files) => {
120124
if (files[0]) {
121-
form.setValue("logo", files[0]);
122-
form.clearErrors("logo");
125+
form.setValue("logo", files[0], {
126+
shouldValidate: true,
127+
});
123128
}
124129
}}
125130
/>

0 commit comments

Comments
 (0)