Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the UI for the My Profile section #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"express": "^4.18.3",
"html-to-text": "^9.0.5",
"jodit-react": "^4.0.15",
"lucide-react": "^0.453.0",
"react": "^18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
Expand Down
196 changes: 112 additions & 84 deletions client/src/components/Dashboard/MyProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { ACCOUNT_TYPE } from "../../utils/constant";
import { formattedDate } from "../../utils/formattedDate";
import { fetchUserDetails } from "../../services/operations/settingsAPI";
import { setLoading, setUserDetails } from "../../slices/profileSlice";
import { MapPin, Clock, Award, Briefcase, Plus } from 'lucide-react';
import AboutCard from "../../components/UI/AboutCard"
import React from "react";
export default function MyProfile() {
// const { user, userDetails, loading, error } = useSelector((state) => ({
Expand Down Expand Up @@ -78,104 +80,130 @@ export default function MyProfile() {
console.log("userDetails", userDetails);

return (
<div className="">
<h1 className="mb-10 text-3xl font-medium text-black py-5 px-5">
My Profile
</h1>
<div className="flex items-center justify-between rounded-md border-[1px] p-8 px-12">
<div className="flex items-center gap-x-4">
<div className="max-w-4xl mx-auto p-6">
{/* Header Section */}
<div className="bg-white rounded-lg shadow-sm mb-6">
<div className="p-6">
<div className="flex justify-between items-center mb-4">
<h1 className="text-3xl font-medium text-black">My Profile</h1>
<IconBtn
text="Edit Profile"
onclick={() => navigate("/dashboard/settings")}
>
<RiEditBoxLine />
</IconBtn>
</div>

<div className="flex items-start gap-6">
<img
src={user?.additionalDetails?.profileImg}
alt={`profile-${user?.firstName}`}
className="aspect-square w-[78px] rounded-full object-cover"
className="w-24 h-24 rounded-full object-cover"
/>
<div className="space-y-1">
<p className="text-lg font-semibold text-slate-800">
{user?.firstName + " " + user?.lastName}
</p>
<p className="text-sm text-slate-800">{user?.email}</p>

<div className="flex-1">
<div className="space-y-2">
<p className="text-lg font-semibold text-slate-800">
{user?.firstName + " " + user?.lastName}
</p>
<p className="text-sm text-slate-800">{user?.email}</p>
</div>

<div className="flex gap-6 mt-4">
<div className="flex items-center gap-2">
<h2 className="font-medium">Follower</h2>
<p>{user?.followers?.length || 0}</p>
</div>
<div className="flex items-center gap-2">
<h2 className="font-medium">Following</h2>
<p>{user?.following?.length || 0}</p>
</div>
<div className="flex items-center gap-2">
<p>{user?.blogs?.length || 0}</p>
<h2 className="font-medium">Blogs</h2>
</div>
</div>
</div>
<div className="flex flex-row gap-1 p-1">
<h2>Follower</h2>
<p>{user?.followers?.length}</p>
</div>
</div>

{/* Stats Section */}
<div className="flex justify-around border-t border-gray-200 p-4">
<div className="flex items-center gap-2">
<Clock className="w-5 h-5 text-gray-400" />
<div>
<div className="font-medium">3+ Years</div>
<div className="text-sm text-gray-500">Experience</div>
</div>
<div className="flex flex-row gap-1 p-1">
{" "}
<h2> Following</h2>
<p>{user?.following?.length}</p>
</div>

<div className="flex items-center gap-2">
<Award className="w-5 h-5 text-gray-400" />
<div>
<div className="font-medium">5 Certificates</div>
<div className="text-sm text-gray-500">Achieved</div>
</div>
<div className="flex flex-row gap-1 p-1">
<p>{user?.blogs?.length}</p>
<h2>Blogs</h2>
</div>

<div className="flex items-center gap-2">
<Briefcase className="w-5 h-5 text-gray-400" />
<div>
<div className="font-medium">2 Internship</div>
<div className="text-sm text-gray-500">Completed</div>
</div>
</div>
</div>
<div className="my-10 flex flex-col gap-y-10 rounded-md border-[1px] border-black-200 p-8 px-12">
<div className="flex w-full items-center justify-between">
<p className="text-lg font-semibold text-black">About</p>
</div>

<IconBtn
text="Edit"
onclick={() => {
navigate("/dashboard/settings");
}}
>
<RiEditBoxLine />
</IconBtn>
</div>
<p
className={`${
userDetails?.about ? "text-slate-600" : "text-slate-500"
} text-sm font-medium`}
{/* About Section */}
<AboutCard className="p-6 mb-6">
<div className="flex w-full items-center justify-between mb-4">
<p className="text-lg font-semibold text-black">About</p>
<IconBtn
text="Edit"
onclick={() => navigate("/dashboard/settings")}
>
{userDetails?.about ?? "Write Something About Yourself"}
</p>
<div className="flex max-w-[500px] justify-between">
<div className="flex flex-col gap-y-5">
<div>
<p className="mb-2 text-sm text-slate-800">First Name</p>
<p className="text-sm font-medium text-slate-600">
{user?.firstName}
</p>
</div>
<div>
<p className="mb-2 text-sm text-slate-800">Email</p>
<p className="text-sm font-medium text-slate-600">
{user?.username}
</p>
</div>
<div>
<p className="mb-2 text-sm text-slate-800">Gender</p>
<p className="text-sm font-medium text-slate-600">
{userDetails?.gender ?? "Add Gender"}
</p>
</div>
</div>
<div className="flex flex-col gap-y-5">
<div>
<p className="mb-2 text-sm text-slate-800">Last Name</p>
<p className="text-sm font-medium text-slate-600">
{user?.lastName}
</p>
</div>
<div>
<p className="mb-2 text-sm text-slate-800">Phone Number</p>
<p className="text-sm font-medium text-slate-600">
{userDetails?.contactNo ?? "Add Contact Number"}
</p>
</div>
<RiEditBoxLine />
</IconBtn>
</div>

<p className={`${userDetails?.about ? "text-slate-600" : "text-slate-500"} text-sm font-medium mb-6`}>
{userDetails?.about ?? "Write Something About Yourself"}
</p>

<div>
<p className="mb-2 text-sm font-semibold text-slate-800">
Date Of Birth
</p>
<p className="text-sm font-medium text-slate-600">
{formattedDate(userDetails?.DOB) ?? "Add Date Of Birth"}
</p>
</div>
</div>
<div className="grid grid-cols-2 gap-x-8 gap-y-4 max-w-[500px]">
<div>
<p className="mb-2 text-sm text-slate-800">First Name</p>
<p className="text-sm font-medium text-slate-600">{user?.firstName}</p>
</div>
<div>
<p className="mb-2 text-sm text-slate-800">Last Name</p>
<p className="text-sm font-medium text-slate-600">{user?.lastName}</p>
</div>
<div>
<p className="mb-2 text-sm text-slate-800">Email</p>
<p className="text-sm font-medium text-slate-600">{user?.username}</p>
</div>
<div>
<p className="mb-2 text-sm text-slate-800">Phone Number</p>
<p className="text-sm font-medium text-slate-600">
{userDetails?.contactNo ?? "Add Contact Number"}
</p>
</div>
<div>
<p className="mb-2 text-sm text-slate-800">Gender</p>
<p className="text-sm font-medium text-slate-600">
{userDetails?.gender ?? "Add Gender"}
</p>
</div>
<div>
<p className="mb-2 text-sm font-semibold text-slate-800">Date Of Birth</p>
<p className="text-sm font-medium text-slate-600">
{formattedDate(userDetails?.DOB) ?? "Add Date Of Birth"}
</p>
</div>
</div>
</div>
</AboutCard>
</div>
);
}
111 changes: 111 additions & 0 deletions client/src/components/UI/AboutCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React from 'react';

const Card = ({
children,
className = "",
title,
subtitle,
icon,
rightElement,
dateRange,
location
}) => {
return (
<div className={`bg-white rounded-lg border border-gray-200 shadow-sm ${className}`}>
{/* Card Header - Only rendered if title exists */}
{(title || rightElement) && (
<div className="flex justify-between items-center p-6 border-b border-gray-100">
<div className="flex items-center gap-4">
{/* Icon/Image Container */}
{icon && (
<div className="w-12 h-12 rounded-lg bg-pink-500 flex items-center justify-center">
{icon}
</div>
)}

{/* Title Section */}
<div>
{title && <h3 className="text-lg font-semibold text-gray-900">{title}</h3>}
{subtitle && <p className="text-sm text-gray-500">{subtitle}</p>}
</div>
</div>

{/* Right Element (e.g., date, buttons) */}
{rightElement && (
<div className="text-right">
{dateRange && (
<div className="flex items-center gap-2 text-gray-500 text-sm">
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M12 8v4l3 3" strokeLinecap="round" strokeLinejoin="round"/>
<circle cx="12" cy="12" r="9"/>
</svg>
{dateRange}
</div>
)}
{location && (
<div className="flex items-center gap-2 text-gray-500 text-sm mt-1">
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M12 21s-8-4.5-8-11.8A8 8 0 0 1 12 2a8 8 0 0 1 8 7.2c0 7.3-8 11.8-8 11.8z" strokeLinecap="round" strokeLinejoin="round"/>
<circle cx="12" cy="10" r="3"/>
</svg>
{location}
</div>
)}
{rightElement}
</div>
)}
</div>
)}

{/* Card Content */}
<div className="p-6">
{children}
</div>
</div>
);
};

// Usage Examples
const ExampleUsage = () => {
return (
<div className="space-y-6">
{/* Basic Card */}
<Card>
<p>Simple card with just content</p>
</Card>

{/* Job Experience Card */}
<Card
title="Graphic Designer"
subtitle="Dribbble Inc"
icon={<div className="w-6 h-6 bg-white rounded-full" />}
dateRange="Feb 2016 - Dec 2017"
location="New York, USA"
>
<p className="text-gray-600">
There are many variations of passages of Lorem Ipsum available...
</p>
</Card>

{/* Profile Info Card */}
<Card
title="About"
rightElement={
<button className="flex items-center gap-2 text-blue-500">
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
Edit
</button>
}
>
<p className="text-gray-600">
Profile content goes here...
</p>
</Card>
</div>
);
};

export default Card;
Loading