Skip to content

Commit

Permalink
profile updated
Browse files Browse the repository at this point in the history
  • Loading branch information
shahidmonowarr committed Dec 30, 2022
1 parent 29e5db7 commit bcda3f0
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 23 deletions.
24 changes: 12 additions & 12 deletions .firebase/hosting.YnVpbGQ.cache
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
fakeDB.JSON,1665991988396,26f5f4c6a32f6a8b6b3093aabb24155034f49fb09b4981718ce2fd395704790d
favicon.ico,1655560771700,5e12c71418e52a573911a3e5128e1b55e316b5912f8e749f649084d26d4f483b
manifest.json,1655353656276,aff3449bdc238776f5d6d967f19ec491b36aed5fb7f23ccff6500736fd58494a
robots.txt,1655353657779,bfe106a3fb878dc83461c86818bf74fc1bdc7f28538ba613cd3e775516ce8b49
asset-manifest.json,1668264959715,4b0683c1bf9a6f0e730227008e2cdfea7e6378543828d68cd17bb38122b7e290
index.html,1668264959715,c5334f6f23e98fac21b700b352c87b4f265f89e256faeb31020cb7f43ef80805
static/js/787.beb77ff5.chunk.js,1668264959731,864efbac16a80e6f42adeaa335e089695d7873578a88cd006045ebb9cfa16cbe
static/js/787.beb77ff5.chunk.js.map,1668264959731,a49faf1fb700667092e4f4cad92519fb3364e7fccfe2c911b0346534a2a9dcbd
static/js/main.2883c151.js.LICENSE.txt,1668264959731,a4bf333c58f9e94274c19b9aee77a652337affee13e747a3e15415ca14c01597
static/media/logo.e89c1383872aa95a5c3c.png,1668264959731,0562a877f82e12c660fc14436a6da61e9a7033cda1b7e95fd9d4e0d9e0a06d57
static/media/review.8693276546367883219d.jpg,1668264959731,6e79fc230beb384db59ceec9ebcdf2eb74b2270d4c032860146711b7f4e501bb
static/css/main.de4b8238.css,1668264959731,54fca6cecb0c5f83f3e8dba196c42f31ba0d897d7cdb42dd5791c26741682afa
static/css/main.de4b8238.css.map,1668264959731,242ffef8b7c3e8b7ec9cd97b16c6f398385cdd5fa389d429805488d839b28afb
static/js/main.2883c151.js,1668264959731,0d30768cd06fc26f8f873d25bf1e8e0f27ae4c3735c8c9f9c07b586c9c37dedc
static/js/main.2883c151.js.map,1668264959731,37a392a9c0216a59f8fe8efee57ba2c6ca214bb4687029823e14b7d0b8c6e260
asset-manifest.json,1672341754706,5fd4b01d8ceb8e15a4d8c717a01bb911893a8e1a3659a6247dca806ade5cbcad
index.html,1672341754706,456ecf16bf9902a55c2f6f7b02f5fff3899aeb903cb180cb638d76929c0d4c21
fakeDB.JSON,1672332265410,63b437b0ebaee613776f1bf6fd8b96ba4a412e234701a10f98be5f12cb3b1b78
static/js/787.beb77ff5.chunk.js,1672341754722,864efbac16a80e6f42adeaa335e089695d7873578a88cd006045ebb9cfa16cbe
static/js/787.beb77ff5.chunk.js.map,1672341754737,a49faf1fb700667092e4f4cad92519fb3364e7fccfe2c911b0346534a2a9dcbd
static/js/main.27441a80.js.LICENSE.txt,1672341754737,a4bf333c58f9e94274c19b9aee77a652337affee13e747a3e15415ca14c01597
static/media/review.8693276546367883219d.jpg,1672341754737,6e79fc230beb384db59ceec9ebcdf2eb74b2270d4c032860146711b7f4e501bb
static/css/main.8ad47871.css,1672341754737,5bd5ed44ba62088eff9ce66bc3d6c291419aefb4f19ece36fcf91be1eae87c1a
static/media/logo.e89c1383872aa95a5c3c.png,1672341754737,0562a877f82e12c660fc14436a6da61e9a7033cda1b7e95fd9d4e0d9e0a06d57
static/css/main.8ad47871.css.map,1672341754737,bd96a7cabf25d7eb542f815dda8f55ccfdc3af3f8f93e4e2fa926cb37fc0e5ac
static/js/main.27441a80.js,1672341754722,0e8e54f3d44ce67f8a912198e8ceed846fe4e5f8a8c52551484c0774a98918ab
static/js/main.27441a80.js.map,1672341754737,1f79f494e484a1e20350e2f6010f9876a2226866d919787d30e521d0bd2ec642
170 changes: 159 additions & 11 deletions src/Pages/Dashboard/DashboardHome/DashboardHome.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,170 @@
import React from "react";
import axios from "axios";
import { signOut } from "firebase/auth";
import React, { useEffect, useState } from "react";
import { Card, Col, Row } from "react-bootstrap";
import { useAuthState } from "react-firebase-hooks/auth";
import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
import auth from "../../../firebase.init";

const DashboardHome = () => {
const [userProfile, setUserProfile] = useState([]);
const [user] = useAuthState(auth);
const navigate = useNavigate();

useEffect(() => {
if (user) {
fetch(`https://tech-specter.onrender.com/userProfile?email=${user.email}`, {
method: "GET",
headers: {
authorization: `Bearer ${localStorage.getItem("accessToken")}`,
},
})
.then((res) => {
// console.log("res", res);
if (res.status === 401 || res.status === 403) {
signOut(auth);
localStorage.removeItem("accessToken");
navigate("/");
}
return res.json();
})
.then((data) => {
console.log("data", data);
const myProfile = data.filter(
(singleData) => singleData.email === user.email
);
setUserProfile(myProfile);
});
}
}, [user]);

const handleProfileUpdate = (event) => {
event.preventDefault();
const profile = {
name: user.displayName,
email: user.email,
image: event.target.image.value,
bloodGroup: event.target.bloodGroup.value,
status: event.target.status.value,
phone: event.target.phone.value,
address: event.target.address.value,
about: event.target.about.value,
};
axios.post("https://tech-specter.onrender.com/userProfile", profile).then((res) => {
const { data } = res;
if (data.insertedId) {
toast("Your Profile is Updated");
event.target.reset();
navigate("/dashboard");
}
console.log(res);
});
};
return (
<div className="container">
<div className="container add-product">
<h2>
Welcome to Dashboard, <span style={{color:'#e64088'}}>{user.displayName}</span>.
Welcome to Dashboard,{" "}
<span style={{ color: "#e64088" }}>{user?.displayName}</span>.
</h2>
<div className="drone-media mx-5 mb-5">
<img
style={{width:'90%', height: 'auto'}}
className="vert-move img-fluid"
src="https://i.ibb.co/7k02WGG/6195525-3156627.jpg"
alt=""
/>
</div>
<Row>
<Col md="6">
{userProfile.map((profile) => (
<Card
key={profile._id}
profile={profile}
style={{ height: "97%" }}
className="mx-1 mb-3 shadow"
>
<div className="text-center">
<Card.Img
style={{ width: "60%", height: "150px" }}
variant="top"
src={profile.image}
/>
</div>
<Card.Body className="text-start ">
<Card.Title
style={{ color: "#42a5f5" }}
className="text-uppercase"
>
Name: {profile.name}
</Card.Title>
<Card.Title>Email: {profile.email}</Card.Title>
<Card.Title>
Blood Group:{" "}
<span className="text-uppercase">{profile.bloodGroup}</span>
</Card.Title>
<Card.Title>Phone NO: {profile.phone}</Card.Title>
<Card.Text>Present Status: {profile.status}</Card.Text>
<Card.Text>Address: {profile.address}</Card.Text>
<Card.Text>About Me: {profile.about}</Card.Text>
</Card.Body>
</Card>
))}
</Col>
<Col md="6">
<div className="card py-2">
<h3 className="text-secondary text-uppercase fw-bold text-center">
Update Your Profile
</h3>
<form onSubmit={handleProfileUpdate}>
<input
className="form-control md-form w-75 mb-1"
value={user?.displayName}
disabled
type="text"
/>
<input
className="form-control md-form w-75 mb-1"
value={user?.email}
disabled
type="email"
/>
<input
className="form-control md-form w-75 mb-1"
type="text"
name="image"
placeholder="Profile Image URL"
/>
<input
className="form-control text-uppercase md-form w-75 mb-1"
type="text"
name="bloodGroup"
placeholder="Your Blood Group"
/>
<input
className="form-control md-form w-75 mb-1"
type="text"
name="status"
placeholder="Your Current Status"
/>
<input
className="form-control w-75 mb-1"
type="number"
placeholder="Your Phone Number"
name="phone"
/>
<input
className="form-control w-75 mb-1"
type="text"
name="address"
placeholder="Your Address"
/>
<input
className="form-control w-75 mb-1"
type="text"
name="about"
placeholder="About You"
/>
<input
className="form-control w-75 mb-1 submit-btn"
type="submit"
/>
</form>
</div>
</Col>
</Row>
</div>
);
};
Expand Down

0 comments on commit bcda3f0

Please sign in to comment.