From 9d9b5838c41a2e3af4515b0ccbe8bad973a7cf11 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Tue, 20 Aug 2024 16:19:39 +0330 Subject: [PATCH] working on uploading image --- src/core/components/Profile/Update/form.jsx | 131 +++++++++++++++++++ src/core/components/Profile/Update/index.jsx | 3 +- src/core/components/Profile/index.jsx | 11 +- src/core/utils/routes.js | 2 +- 4 files changed, 142 insertions(+), 5 deletions(-) diff --git a/src/core/components/Profile/Update/form.jsx b/src/core/components/Profile/Update/form.jsx index e69de29..c1b41a0 100644 --- a/src/core/components/Profile/Update/form.jsx +++ b/src/core/components/Profile/Update/form.jsx @@ -0,0 +1,131 @@ +"use client"; + +import { Autocomplete, Avatar, Backdrop, Badge, Box, Grid, TextField } from "@mui/material"; +import StyledForm from "@/core/components/StyledForm"; +import useRequest from "@/lib/hooks/useRequest"; +import { Controller, useForm } from "react-hook-form"; +import { useAuth } from "@/lib/contexts/auth"; +import AddCircleIcon from "@mui/icons-material/AddCircle"; +import DataSAverOn from "@mui/icons-material/DataSAverOn"; +import { useState } from "react"; + +const degreeItems = ["دیپلم", "کارشناسی", "کارشناسی ارشد", "دکترا"]; + +const Form = () => { + const request = useRequest(); + const { user } = useAuth(); + const [uploadBackDrop, setUploadBackDrop] = useState(false); + const defaultValues = { + first_name: user.data.first_name, + last_name: user.data.last_name, + degree: user.data.degree, + major: user.data.major, + mobile: user.data.mobile, + avatar: user.data.avatar, + }; + + console.log("defaultValues", defaultValues); + + const { + control, + watch, + register, + handleSubmit, + setValue, + formState: { isSubmitting }, + } = useForm({ defaultValues: defaultValues }); + + return ( + + + } + > + setUploadBackDrop(true)} + onMouseLeave={() => setUploadBackDrop(false)} + alt={watch("first_name")} + src={`${process.env.NEXT_PUBLIC_API_URL}/${watch("avatar")}`} + sx={{ width: 150, height: 150, border: "1px solid #e1e1e1", cursor: "pointer" }} + /> + + theme.zIndex.drawer + 1, + position: "absolute", width: 150, height: 150, + marginLeft: "auto", marginRight: "auto", + borderRadius: "50%", + }} + open={uploadBackDrop} + > + + + + + + + + + + + + + + + ( + { + onChange(newValue); + }} + options={degreeItems} + renderInput={(params) => ( + + )} + /> + )} + /> + + + + + + + ); +}; +export default Form; \ No newline at end of file diff --git a/src/core/components/Profile/Update/index.jsx b/src/core/components/Profile/Update/index.jsx index bb244ea..e4183ac 100644 --- a/src/core/components/Profile/Update/index.jsx +++ b/src/core/components/Profile/Update/index.jsx @@ -12,6 +12,7 @@ import { } from "@mui/material"; import { useTheme } from "@mui/material/styles"; import CloseIcon from "@mui/icons-material/Close"; +import Form from "./form"; const Update = ({ open, setOpen }) => { const theme = useTheme(); @@ -37,7 +38,7 @@ const Update = ({ open, setOpen }) => { - form will come here +