mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-18 21:44:06 +01:00
fix: no need minimum require for bio
This commit is contained in:
parent
49eb128549
commit
0c719a093d
@ -24,10 +24,9 @@ interface ProfileData {
|
||||
type EditProfileFormProps = {
|
||||
profileData: ProfileData;
|
||||
uid: string;
|
||||
sessionUserId: string;
|
||||
};
|
||||
|
||||
export default function EditProfileForm({ profileData, uid, sessionUserId }: EditProfileFormProps) {
|
||||
export default function EditProfileForm({ profileData, uid }: EditProfileFormProps) {
|
||||
const router = useRouter();
|
||||
const client = createSupabaseClient();
|
||||
const profileForm = useForm<z.infer<typeof profileSchema>>({
|
||||
@ -90,6 +89,7 @@ export default function EditProfileForm({ profileData, uid, sessionUserId }: Edi
|
||||
<FormField
|
||||
control={profileForm.control}
|
||||
name="avatars"
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
render={({ field: { value, onChange, ...fieldProps } }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Avatar</FormLabel>
|
||||
|
||||
@ -33,7 +33,7 @@ export default async function ProfilePage({ params }: ProfilePageProps) {
|
||||
<div className="my-5">
|
||||
<span className="text-2xl font-bold">Update Profile</span>
|
||||
</div>
|
||||
<EditProfileForm profileData={profileData} uid={uid} sessionUserId={user.id} />
|
||||
<EditProfileForm profileData={profileData} uid={uid} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -4,24 +4,21 @@ const MAX_FILE_SIZE = 500000;
|
||||
const ACCEPTED_IMAGE_TYPES = ["image/jpeg", "image/jpg", "image/png"];
|
||||
|
||||
const profileAvatarSchema = z
|
||||
.custom<File>(
|
||||
(val) =>
|
||||
val && typeof val === "object" && "size" in val && "type" in val,
|
||||
{
|
||||
message: "Input must be a file.",
|
||||
},
|
||||
)
|
||||
.refine((file) => file.size < MAX_FILE_SIZE, {
|
||||
message: "File can't be bigger than 5MB.",
|
||||
})
|
||||
.refine((file) => ACCEPTED_IMAGE_TYPES.includes(file.type), {
|
||||
message: "File format must be either jpg, jpeg, or png.",
|
||||
}).optional();
|
||||
.custom<File>((val) => val && typeof val === "object" && "size" in val && "type" in val, {
|
||||
message: "Input must be a file.",
|
||||
})
|
||||
.refine((file) => file.size < MAX_FILE_SIZE, {
|
||||
message: "File can't be bigger than 5MB.",
|
||||
})
|
||||
.refine((file) => ACCEPTED_IMAGE_TYPES.includes(file.type), {
|
||||
message: "File format must be either jpg, jpeg, or png.",
|
||||
})
|
||||
.optional();
|
||||
|
||||
export const profileSchema = z.object({
|
||||
username: z.string().min(3).max(50).optional(),
|
||||
full_name: z.string().min(4).max(100).optional(),
|
||||
bio: z.string().min(10).max(1000).optional(),
|
||||
updated_at: z.string().datetime().optional(),
|
||||
avatars: profileAvatarSchema,
|
||||
username: z.string().min(3).max(50).optional(),
|
||||
full_name: z.string().min(4).max(100).optional(),
|
||||
bio: z.string().max(1000).optional(),
|
||||
updated_at: z.string().datetime().optional(),
|
||||
avatars: profileAvatarSchema,
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user