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