Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
khubaibkm committed Mar 5, 2024
2 parents d32835f + 1b02b8c commit faac81b
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 192 deletions.
46 changes: 23 additions & 23 deletions .firebase/hosting.ZGlzdA.cache
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ logo.svg,1702805755363,106fd0e0e25e62773089d32eafec6046eb8f0d1a196e632a72cdfd228
profile.png,1707892322036,3db19429a79553f09c0adebdb3d58cbb8699e45584f31fc73c55198c67ce3acf
signin.svg,1686127288433,f60118db2a3203e28dc8285cf5d2dafbc799618ee6b2a4d0d3a63f36ba584c8e
vite.svg,1680593882164,59ec4b6085a0cb1bf712a5e48dd5f35b08e34830d49c2026c18241be04e05d5a
index.html,1709456931479,d54f4de72169df7fbc9ac03a470d32e61f4f928fc802a1c55274e3a883625914
assets/AdminDashboard-2115034d.js,1709456931467,3e598bcabd25892c19be7e09fd3da2c692dadd8a611552488678e22bfd114ddc
assets/ajax-loader-e7b44c86.gif,1709456931463,e9699a225e244ba8bb48532313e5c56a76fe08358c6dd684fb3234f2f63e7961
assets/index-b139ad4f.css,1709456931465,2dc356270b9598957f0a0296e5c40d33d8b20a2317fcf5adf73ce509a267e241
assets/HomePage-cf332abe.css,1709456931465,5c3dd8c3364bf3887a0ffc40025675bdc7ffd43701cdd2f5755bb601b3ffff59
assets/MyProfile-408e5506.js,1709456931466,2823930fae99be3f4e3d9d9827984b6dd0428b0ebb457a395226d5058648d995
assets/index.esm-db58b76b.js,1709456931465,d431edea8ad1056b9b4badaf75d1aabedfb66da020b9314c8e43ee142640202d
assets/OnBoardingForm-003df330.css,1709456931465,660482a0aeba2c167de6e80851bf186d6939e1209dc2150a0743831e8d5d4109
assets/profile-610a26c1.js,1709456931466,bc6f4720dee2492391e413bd19b14e14498f0a856b5a325876e90bc5c3f830fc
assets/OnBoardingForm-1d45cd75.js,1709456931471,33100b3bb6ec366c02c7b92ad718cea4380f86efd195f4c1e7574b89a6d86b51
assets/ProfileList-1e34a258.css,1709456931465,94d6f076540233e531ecca64bde431e73adb69f92a320e89633a9d9618618365
assets/ProfileList-da937e87.js,1709456931467,9452a420a13876f51dad2eed11980942355112d95221d4e8173e7010bd0d3f71
assets/SignIn-deeb1b75.js,1709456931467,343f6a4e590f70e6d2d57d9294da59fd66214f415e6dcbda0dcd723678b912ea
assets/SignIn-546af57c.css,1709456931465,4bb3288d1795822ccfa709d00c582eb82d54076ff675a8131eaef78ade317c7c
assets/SignUp-2fffacea.css,1709456931465,069a282e6dad21397c728a994b3e55f7993bf3be2acf3142d4a97a04b340c071
assets/SignUp-4501ad0a.js,1709456931466,68f9ade9cb408305c50141a980c6ff801a45bfc08874dcf845f59af7025b7314
assets/Test-ff9b7af4.js,1709456931466,da10fcf96aaa611de01e4b7c7b3e8865f3a8eb8b2b70d5e0e74b30b69bc5fe6f
assets/Team-a8f36299.js,1709456931466,e83afc7f81b2b12d8e640ff1dec3eef2658abb49dc807b0cb51ae4bececa2b62
assets/slick-12459f22.svg,1709456931465,d00477d40ed40fa1dd3bdee27d9286804121b15fea83bae7d5415d902b055de0
assets/UnauthorizedError-224673df.js,1709456931466,a730927f3398dc48f500ec30a276f1cbbc88fe791e19fd4c4c8b6650c8ff8718
assets/UnderReview-1fc2efc2.js,1709456931465,21e7b39e3a48924afbaf2d62261ecd26622037419d423bc3879b2f837510ab0a
assets/HomePage-5ede1828.js,1709456931479,ebab1382e2c8f4319cac6cca2b6618473bcfac881703590ede8a23b795166f9a
assets/index-f267be31.js,1709456931480,912a5b3c8fa5dea72a40db05e9f52750234fda4a0e13dffcfe21caff91e4114f
index.html,1709482578232,cf75a692bb10c3b5365483d98bdb77ce5b0f9bfb1cc0ca68deca9cd93d835d28
assets/AdminDashboard-8221f54b.js,1709482578226,2d62adbe28cec12f5f4b5092c3477520ce62726794bbb7cb2c950c95ce1e8a54
assets/ajax-loader-e7b44c86.gif,1709482578225,e9699a225e244ba8bb48532313e5c56a76fe08358c6dd684fb3234f2f63e7961
assets/HomePage-d05ed5a4.css,1709482578225,07ad2ebc60866a5a6370a2a0580b6ee880565d517322107971a97bb3927b4333
assets/index-bc247fe3.css,1709482578225,83886c58cd522f875762604166d13c81f54874dde0db49074003cf70ef8934d5
assets/index.esm-b27368d8.js,1709482578226,475c5f17c55edc4b35cef6a76cc44ddbdf5668a5703f885e3ea147a66742b538
assets/MyProfile-dc49609e.js,1709482578226,775a396bdc12273e9268c2686a426ae4209a2e8b1fad81dfd899a334714796c8
assets/OnBoardingForm-003df330.css,1709482578225,660482a0aeba2c167de6e80851bf186d6939e1209dc2150a0743831e8d5d4109
assets/profile-84ca40f8.js,1709482578226,5c8a521802fe1f2794c636f4520bc9d00ffb4c79bd11c617a10b4bab5f560172
assets/OnBoardingForm-54428542.js,1709482578226,4f99d2bff30e5f570e0173e487d885d1975844766659d85b26c52404971e45d8
assets/ProfileList-1e34a258.css,1709482578225,94d6f076540233e531ecca64bde431e73adb69f92a320e89633a9d9618618365
assets/SignIn-0f83d84f.js,1709482578226,b4dff7882d1b343f0f90e9693d001a10107a6de0a716af40dd25d357f570b2ad
assets/ProfileList-5512821a.js,1709482578227,e51191ee92bc32b0598d1899420417ea60c49bdd2be34293ea5ba65757f63036
assets/SignIn-546af57c.css,1709482578225,4bb3288d1795822ccfa709d00c582eb82d54076ff675a8131eaef78ade317c7c
assets/SignUp-262a54aa.js,1709482578226,ed822d8903e4b3cf2cb5ac77ac7f817123866c8e902fd0f80864db56ac3e853c
assets/SignUp-2fffacea.css,1709482578225,069a282e6dad21397c728a994b3e55f7993bf3be2acf3142d4a97a04b340c071
assets/slick-12459f22.svg,1709482578223,d00477d40ed40fa1dd3bdee27d9286804121b15fea83bae7d5415d902b055de0
assets/Team-924e9a6b.js,1709482578226,fe2d33784eaa77f53c152a8ffcbade063ca591ccc4b13c72e57554e0bc8713c4
assets/Test-85b99c15.js,1709482578226,4584e19bef46697dade31832c55fbe39d40e3067636985df1699ca26624a781a
assets/UnauthorizedError-3f1548dd.js,1709482578226,f595f024a07014bbdd1a8179adae5fc91d7df20aae3474567614584d42b484a5
assets/UnderReview-26fe0c17.js,1709482578226,1237bf0884497368cc0c9cc0aa6c281c9faa7724c37c2f04325b5252c4fbb9e2
assets/HomePage-db466994.js,1709482578232,5a7ffc3af0e25282a153a6021120f2d8d8a3ddf79937f4924e363ee34f75a746
assets/index-47bfaaf6.js,1709482578234,e5cb1cb8d2bbf7c5a6a2a04c7d76971cb9075c2a6f7bae4fb0b9d0ab41f254fc
12 changes: 11 additions & 1 deletion src/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,17 @@ export const Navbar = () => {
<li signn className="nav-item">
{isSignedIn ? (
<a

className="signt nav-link bg-secondary rounded text-white px-3 py-2 mx-2 "
style={{
display: "inline-block",
padding: "0.5rem",
marginLeft: "0", // Adjust margin as needed
borderRadius: "5px",
backgroundColor: "#6c757d",
textDecoration: "none",
color: "white",
}}
href="#"
onClick={handleSignOut}
>
Expand All @@ -149,7 +159,7 @@ export const Navbar = () => {
) : (
<Link
to="/signin"
className="signn nav-link bg-primary rounded text-white px-3 py-2 mx-2 button-animated"
className={`signn nav-link bg-primary rounded text-white px-3 py-2 mx-2 button-animated d-lg-inline-block`}
onClick={() => closeNavbar()}
>
Alumni Login
Expand Down
2 changes: 1 addition & 1 deletion src/components/OnBoardingForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const OnBoardingForm = () => {
const fileSizeInMB = image.size / (1024 * 1024);
const allowedImageTypes = ["image/jpeg", "image/png", "image/gif"];

if (fileSizeInMB > 1) {
if (fileSizeInMB > 10) {
toast.error("File size should not exceed 1MB");
setLoading(false); // Set loading to false in case of an error
return;
Expand Down
121 changes: 57 additions & 64 deletions src/pages/AdminDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,14 @@ const AdminDashboard = () => {

const handleApprove = async (userId, userEmail) => {
try {
// Add logic to update user data and set isVerified to true
const userDocRef = doc(db, "alumni", userId);
await updateDoc(userDocRef, { isVerified: true });

// Fetch updated unverified users
fetchUnverifiedUsers();

// Reset password and send email
const auth = getAuth(); // Ensure auth is correctly initialized
await sendPasswordResetEmail(auth, userEmail); // Use sendPasswordResetEmail directly
const auth = getAuth();
await sendPasswordResetEmail(auth, userEmail);

// Optionally, you can sign out the admin after approving the user
handleSignOut();
} catch (error) {
console.error("Error approving user:", error);
Expand All @@ -81,11 +77,9 @@ const AdminDashboard = () => {

const handleDisapprove = async (userId) => {
try {
// Add logic to delete user data
const userDocRef = doc(db, "alumni", userId);
await deleteDoc(userDocRef);

// Fetch updated unverified users
fetchUnverifiedUsers();
} catch (error) {
console.error("Error disapproving user:", error);
Expand All @@ -96,29 +90,24 @@ const AdminDashboard = () => {
const authListener = auth.onAuthStateChanged((user) => {
setUser(user);

// Check if the user is an admin based on UID
if (user && user.uid !== adminUID) {
// Redirect to an error page or display an error message
// Automatically sign out on component mount
navigate("/error");
handleSignOut();
}
});

// Automatically sign out on component mount
handleSignOut();

fetchUnverifiedUsers();

return () => {
authListener(); // Unsubscribe from the auth listener when the component unmounts
authListener();
};
}, []); // Empty dependency array to run the effect only once when the component mounts
}, []);

if (!user) {
return (
<div className="container p-5">
<div className="card w-50 mx-auto sm-p-4 m-5">
<div className="container py-5 mt-5">
<div className="card w-50 mx-auto shadow p-4 m-5">
<h2 className="mb-4">Sign In</h2>
<div className="mb-3">
<label className="form-label">Email:</label>
Expand Down Expand Up @@ -147,54 +136,58 @@ const AdminDashboard = () => {
}

return (
<div className="container mt-4">
<h2 className="mb-4">Admin Dashboard</h2>
<table className="table table-bordered">
<thead className="thead-dark">
<tr>
<th>Name</th>
<th>Email</th>
<th>Graduation Year</th>
<th>Major</th>
<th>Current Company</th>
<th>LinkedIn ID</th>
<th>PFP</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{unverifiedUsers.map((user) => (
<tr key={user.id}>
<td>{user.name}</td>
<td>{user.email}</td>
<td>{user.graduationYear}</td>
<td>{user.major}</td>
<td>{user.currentCompany}</td>
<td>https://linkedin.com/in/{user.linkedin}</td>
<td>
<img
src={user.profileImageUrl}
style={{ height: "150px", width: "150px" }}
/>
</td>
<td className="d-flex">
<button
className="btn btn-success me-2"
onClick={() => handleApprove(user.id, user.email)}
>
Approve
</button>
<button
className="btn btn-danger"
onClick={() => handleDisapprove(user.id)}
>
Disapprove
</button>
</td>
<div className="container m-5 p-5">
<h2 className="mb-4 text-center">Admin Dashboard</h2>
<div className="table-responsive">
<table className="table table-bordered table-striped">
<thead className="thead-dark">
<tr>
<th>Name</th>
<th>Email</th>
<th>Graduation Year</th>
<th>Major</th>
<th>Current Company</th>
<th>LinkedIn ID</th>
<th>PFP</th>
<th>Actions</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{unverifiedUsers.map((user) => (
<tr key={user.id}>
<td>{user.name}</td>
<td>{user.email}</td>
<td>{user.graduationYear}</td>
<td>{user.major}</td>
<td>{user.currentCompany}</td>
<td>https://linkedin.com/in/{user.linkedin}</td>
<td>
<img
src={user.profileImageUrl}
style={{ height: "150px", width: "150px" }}
className="img-fluid rounded"
alt={user.name}
/>
</td>
<td className="d-flex">
<button
className="btn btn-success me-2"
onClick={() => handleApprove(user.id, user.email)}
>
Approve
</button>
<button
className="btn btn-danger"
onClick={() => handleDisapprove(user.id)}
>
Disapprove
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProfileList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const ProfileList = () => {
<p className="card-text ">
Current Company:{" "}
<span className="text-primary">
{profile.currentCompany?.length > 15
{profile.currentCompany?.length > 20
? profile.currentCompany.slice(0, 15) + "..."
: profile.currentCompany}
</span>
Expand Down
Loading

0 comments on commit faac81b

Please sign in to comment.