import React, { useEffect, useState } from "react"; // next import Image from "next/image"; import type { NextPage } from "next"; // react hook form import { useForm } from "react-hook-form"; // react dropzone import Dropzone from "react-dropzone"; // hooks import useUser from "lib/hooks/useUser"; // layouts import ProjectLayout from "layouts/ProjectLayout"; // services import userService from "lib/services/user.service"; import fileServices from "lib/services/file.services"; // ui import { Button, Input, Spinner } from "ui"; // types import type { IUser } from "types"; import { UserIcon } from "@heroicons/react/24/outline"; const defaultValues: Partial = { avatar: "", first_name: "", last_name: "", email: "", }; const Profile: NextPage = () => { const [image, setImage] = useState(null); const [isImageUploading, setIsImageUploading] = useState(false); const { user: myProfile, mutateUser } = useUser(); const onSubmit = (formData: IUser) => { userService .updateUser(formData) .then((response) => { console.log(response); mutateUser(response, false); }) .catch((error) => { console.log(error); }); }; const { register, handleSubmit, reset, watch, setValue, formState: { errors, isSubmitting }, } = useForm({ defaultValues }); useEffect(() => { reset({ ...defaultValues, ...myProfile }); }, [myProfile, reset]); return (
{myProfile ? ( <>
{ setImage(files[0]); }} > {({ getRootProps, getInputProps }) => (

Profile Picture

{(!watch("avatar") || watch("avatar") === "") && (!image || image === null) ? ( ) : (
{myProfile.first_name}
)}

Max file size is 500kb. Supported file types are .jpg and .png.

)}

Details

{/*
{myProfile.is_email_verified || ( )}
*/}
) : (
)}
); }; export default Profile;