diff --git a/backend/controllers/userController.js b/backend/controllers/userController.js
index 45bbd0b..df2b699 100644
--- a/backend/controllers/userController.js
+++ b/backend/controllers/userController.js
@@ -90,4 +90,21 @@ exports.UploadPhoto=catchAsync(async(req,res,next)=>{
// exports.AvailableUsersToCreateGroup=catchAsync(async(req,res)=>{
-// })
\ No newline at end of file
+// })
+
+exports.getUserById=catchAsync(async(req,res)=>{
+
+ try {
+ const users = await User.findById(req.params.id);
+ if (!users) {
+ return res.status(404).json({ message: 'Item not found' });
+ }
+ res.status(200).json({
+ status:'success',
+ users
+ })
+ } catch (err) {
+ console.error(err);
+ res.status(500).json({ message: 'Server error' });
+ }
+})
\ No newline at end of file
diff --git a/backend/routes/userRouter.js b/backend/routes/userRouter.js
index ae9debe..e5c9123 100644
--- a/backend/routes/userRouter.js
+++ b/backend/routes/userRouter.js
@@ -12,6 +12,6 @@ router.post('/login',authController.login);
router.post('/ispresent',authController.isUserPresent)
router.post('/protect',authController.protect,authController.send);
router.post('/uploadPhoto',authController.protect,userController.uploadUserPhoto,userController.UploadPhoto)
-
+router.get('/:id',authController.protect,userController.getUserById)
module.exports=router;
\ No newline at end of file
diff --git a/frontend/src/App.js b/frontend/src/App.js
index eb5b42d..c93c6f3 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -13,6 +13,7 @@ import Settings from './pages/Settings';
import Root,{loader as loadingAction} from './pages/Root';
import Search from './pages/Search';
+import Profile from './pages/Profile';
const router = createBrowserRouter([
@@ -54,6 +55,10 @@ const router = createBrowserRouter([
{
path:"search",
element:
+ },
+ {
+ path:":id",
+ element:
}
]
diff --git a/frontend/src/components/SettingsComponents/ShareProfile.js b/frontend/src/components/SettingsComponents/ShareProfile.js
new file mode 100644
index 0000000..d163142
--- /dev/null
+++ b/frontend/src/components/SettingsComponents/ShareProfile.js
@@ -0,0 +1,67 @@
+import React, { useState } from "react";
+import ShareIcon from "@mui/icons-material/Share";
+import CloseIcon from "@mui/icons-material/Close";
+import { Modal } from "@mui/material";
+import { useLocation } from "react-router-dom";
+import ContentCopyIcon from "@mui/icons-material/ContentCopy";
+import { toast } from "react-toastify";
+
+export default function ShareProfile({ id }) {
+ const [showModal, setShowModal] = useState(false);
+ const location = useLocation();
+
+ const copyToClipboard = async () => {
+ console.log(window.location.origin);
+ toast.info("Copied!", {
+ position: "top-center",
+ autoClose: 2500,
+ hideProgressBar: false,
+ closeOnClick: true,
+ pauseOnHover: true,
+ draggable: true,
+ progress: undefined,
+ });
+ return await window.navigator.clipboard.writeText(
+ `${window.location.origin}/home/${id}`
+ );
+ };
+
+ return (
+ <>
+
+
+ setShowModal(false)}
+ className="flex items-center justify-center"
+ >
+
+
+
Share Profile
+
+
+
+
+
{`${window.location.origin}/home/${id}`}
+
+
+
+
+
+ >
+ );
+}
diff --git a/frontend/src/pages/Profile.js b/frontend/src/pages/Profile.js
new file mode 100644
index 0000000..5a8d64f
--- /dev/null
+++ b/frontend/src/pages/Profile.js
@@ -0,0 +1,74 @@
+import React, { useEffect, useState } from "react";
+import { useNavigate, useParams } from "react-router-dom";
+import LoadingPage from "./LoadingPage";
+import { Avatar } from "@mui/material";
+import SendIcon from "@mui/icons-material/Send";
+import { useDispatch, useSelector } from "react-redux";
+import { AddUser } from "../services/Actions/Chat/action";
+
+export default function Profile() {
+ const { id } = useParams();
+ const [userData, setUserData] = useState(null);
+ const dispatch=useDispatch();
+ const state=useSelector((state)=>state.chat.AllChats);
+ const navigate = useNavigate()
+
+ useEffect(() => {
+ const getData = async () => {
+ const cookie = localStorage.getItem("jwt");
+ const response = await fetch(
+ `${process.env.REACT_APP_API_URL}/api/v1/users/${id}`,
+ {
+ headers: {
+ "Content-type": "application/json",
+ Authorization: `Bearer ${cookie}`,
+ },
+ }
+ );
+ const data = await response.json();
+
+ setUserData(data.users);
+ };
+ getData();
+ }, [id]);
+
+ const accessChatHandler = (values) => {
+ const isPresent = state.find((data) => {
+ return data.email === values.email;
+ });
+ dispatch(AddUser(values, state));
+ setTimeout(() => {
+ navigate("/home/message", { replace: true });
+ }, 2000);
+ };
+
+ if (userData === null) return ;
+
+ return (
+
+
+
+
+
Email :
+
{userData.email}
+
+
+
Gender :
+
{userData.gender}
+
+
+
+
+ );
+}
diff --git a/frontend/src/pages/Search.js b/frontend/src/pages/Search.js
index 06636d5..5baaf0c 100644
--- a/frontend/src/pages/Search.js
+++ b/frontend/src/pages/Search.js
@@ -50,7 +50,6 @@ export default function Search() {
}
const searchHandler=async(value)=>{
-
SetisLoading(true);
const cookie=localStorage.getItem('jwt');
const response=await fetch(`${process.env.REACT_APP_API_URL}/api/v1/users?search=${value}`,{
@@ -72,6 +71,8 @@ export default function Search() {
const accessChatHandler=(values)=>{
+ console.log(values)
+
const isPresent=state.find((data)=>{
return data.email===values.email
});
diff --git a/frontend/src/pages/Settings.js b/frontend/src/pages/Settings.js
index 8912912..9d2d68e 100644
--- a/frontend/src/pages/Settings.js
+++ b/frontend/src/pages/Settings.js
@@ -2,19 +2,18 @@ import React from "react";
import Profile from "../components/SettingsComponents/Profile";
import InputName from "../components/SettingsComponents/InputName";
import InputEmail from "../components/SettingsComponents/InputEmail";
-import { useState,useEffect} from "react";
-import {setUser} from '../services/Actions/User/actions'
-import { useDispatch } from 'react-redux';
+import { useState, useEffect } from "react";
+import { setUser } from "../services/Actions/User/actions";
+import { useDispatch } from "react-redux";
import { ToastContainer, toast } from "react-toastify";
-import InfoIcon from '@mui/icons-material/Info';
+import InfoIcon from "@mui/icons-material/Info";
+import ShareProfile from "../components/SettingsComponents/ShareProfile";
export default function Settings() {
-
- const dispatch=useDispatch();
+ const dispatch = useDispatch();
const storedData = JSON.parse(localStorage.getItem("info"));
const [name, setName] = useState(storedData.name);
const [email, setEmail] = useState(storedData.email);
-
const resetData = () => {
setName(storedData.name);
setEmail(storedData.email);
@@ -63,13 +62,10 @@ export default function Settings() {
}
);
const data = await response.json();
- if (data.status === "success")
- {
+ if (data.status === "success") {
notify("success");
dispatch(setUser(data.updatedUser));
- }
-
- else notify("error");
+ } else notify("error");
};
updateData();
};
@@ -80,12 +76,15 @@ export default function Settings() {
-
- Public profile
+
+
Public profile
+
-
-
To update your profile picture, select an image and upload it.
+
+
+ To update your profile picture, select an image and upload it.
+