From 735a74cb312f526e2f36b8ba2f02d6a5284ddb6f Mon Sep 17 00:00:00 2001 From: darshan totagi Date: Thu, 20 Nov 2025 14:41:53 +0530 Subject: [PATCH] card animations --- client/src/pages/find-donors.tsx | 2 +- client/src/pages/home.tsx | 487 ++++++++++++++++++++----------- 2 files changed, 322 insertions(+), 167 deletions(-) diff --git a/client/src/pages/find-donors.tsx b/client/src/pages/find-donors.tsx index df5aad2..0eee0ef 100644 --- a/client/src/pages/find-donors.tsx +++ b/client/src/pages/find-donors.tsx @@ -365,4 +365,4 @@ export default function FindDonors() { ); -} do enhancement \ No newline at end of file +} \ No newline at end of file diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx index c23674b..10810d6 100644 --- a/client/src/pages/home.tsx +++ b/client/src/pages/home.tsx @@ -16,28 +16,63 @@ import { Plus, Search, Sparkles, - Shield + Shield, } from "lucide-react"; import { motion } from "framer-motion"; import type { Donor, Donation } from "@shared/schema"; +/* -------------------------------------------------------------------------- */ +/* ANIMATIONS */ +/* -------------------------------------------------------------------------- */ + +const fadeInUp = { + hidden: { opacity: 0, y: 12 }, + visible: { opacity: 1, y: 0 }, +}; + +const staggerContainer = { + hidden: {}, + visible: { + transition: { + staggerChildren: 0.12, + }, + }, +}; + +const subtleFade = { + hidden: { opacity: 0 }, + visible: { opacity: 1 }, +}; + export default function Home() { const { toast } = useToast(); const { isAuthenticated, isLoading } = useAuth(); - // Redirect on logout + // Time-based greeting (purely visual, no logic change) + const hours = new Date().getHours(); + const greeting = + hours < 12 ? "Good morning" : hours < 17 ? "Good afternoon" : "Good evening"; + + /* -------------------------------------------------------------------------- */ + /* AUTH REDIRECT UX */ + /* -------------------------------------------------------------------------- */ + useEffect(() => { if (!isLoading && !isAuthenticated) { toast({ title: "Unauthorized", - description: "You are logged out. Redirecting...", + description: "You are logged out. Redirecting you to login…", variant: "destructive", }); setTimeout(() => (window.location.href = "/api/login"), 800); } }, [isAuthenticated, isLoading, toast]); + /* -------------------------------------------------------------------------- */ + /* QUERIES */ + /* -------------------------------------------------------------------------- */ + const { data: donor, isLoading: donorLoading } = useQuery({ queryKey: ["/api/donors/me"], retry: false, @@ -61,11 +96,20 @@ export default function Home() { if (isLoading || donorLoading) { return ( -
+
-
-
- Loading… +
+
+
+
+ +
+

+ Preparing your dashboard… +

+

+ Fetching your donor profile and activity +

@@ -77,236 +121,347 @@ export default function Home() { /* -------------------------------------------------------------------------- */ return ( -
-
+
+ {/* Soft background accent blur */} +
+
+
+
-
+
- {/* Resume Donor Registration */} + + {/* Resume Donor Registration Banner */} {!donor && ( -
+

Complete Your Donor Profile

- Unlock credits, increase visibility & help your community. + Unlock credits, boost your visibility, and help your local community.

- )} - {/* Welcome */} - -

+

+ + {greeting}, {donor?.name ?? "donor"} +

+ +

Welcome to PulseConnect

-

- Your dashboard for donations & community impact. + +

+ Track your donations, manage your credits, and see the impact you're + making in your community.

-
+ {/* Quick Actions */} - {[ { title: "Become a Donor", - desc: "Register to help save lives", + desc: "Register now and be the reason someone gets a second chance.", icon: , link: "/register-donor", variant: "secondary", - iconColor: "bg-secondary/10", + iconColor: "bg-secondary/15", + chip: "Start giving", }, { title: "Find Donors", - desc: "Search for blood donors nearby", + desc: "Search verified donors nearby whenever there is an emergency.", icon: , link: "/find-donors", variant: "outline", iconColor: "bg-accent/10", + chip: "Emergency ready", }, ].map((item, idx) => ( - - -
{item.icon}
-
-

{item.title}

-

{item.desc}

+ +
+ +
+ {item.icon} +
+
+
+ + {item.chip} + +
+

{item.title}

+

+ {item.desc} +

-
))} - + - {/* Donor Profile Section */} + {/* Donor Profile / Empty State */} {donor ? ( - {/* Donor Info */} - - - - Donor Profile - - - -
- Blood Group: - {donor.bloodGroup} -
-
- Total Donations: - {donor.totalDonations} -
-
- Credits: - {donor.credits} -
-
- Status: - - {eligibilityLoading - ? "Checking..." - : eligibility?.canDonate - ? "Eligible" - : "Not Eligible"} - -
-
-
+ + + + + + + Donor Profile + + + + + Verified + + + + + +
+ Blood Group + + {donor.bloodGroup} + +
+
+ Total Donations + {donor.totalDonations} +
+
+ Credits + + {donor.credits} + +
+
+ Status + + {eligibilityLoading + ? "Checking..." + : eligibility?.canDonate + ? "Eligible to donate" + : "Not eligible yet"} + +
+
+
+
{/* Recent Activity */} - - - - Recent Activity - - - - {donationsLoading ? ( -

Loading...

- ) : donations.length ? ( -
- {donations.slice(0, 3).map((d) => ( -
-
-

Blood Donation

-

- {new Date(d.donationDate).toLocaleDateString()} -

+ + + + + Recent Activity + + + + {donationsLoading ? ( +

Loading your activity…

+ ) : donations.length ? ( +
+ {donations.slice(0, 3).map((d) => ( +
+
+

Blood Donation

+

+ {new Date(d.donationDate).toLocaleDateString()} +

+
+ + +{d.creditsEarned} credits +
- +{d.creditsEarned} credits -
- ))} + ))} +
+ ) : ( +

+ No donations recorded yet. Your first donation could save a life. +

+ )} + + + + + {/* Community Impact */} + + + + + Community Impact + + + +
+

+ Lives touched +

+

+ {donor.totalDonations || 0} +

+

+ Every donation counts towards someone's story. +

- ) : ( -

No donations yet

- )} +
+

+ Credits earned +

+

+ {donor.credits || 0} +

+

+ Use credits for blood requests when you or your family need help. +

+
+
+
+
+ + ) : ( + + +
+ +
+

Become a PulseConnect Donor

+

+ Create your donor profile, start donating, and earn credits you can use + for future blood requests for yourself or your loved ones. +

+ +
+
+ )} + + {/* Tips & Credit Info */} + + + + + + + Donation Tips + + + +

• Eat a healthy, balanced meal before donating.

+

• Stay hydrated before and after your donation.

+

• Get a good night's rest the day before.

+

• Avoid alcohol 24 hours prior to donating.

+

• Carry a valid ID and prefer iron-rich foods regularly.

+
- {/* Community Impact */} - - - - Community Impact + + + + + + Credit System - -
-

{donor.totalDonations}

-

Lives Impacted

+ +
+ + Earn 5 credits for each successful donation.
-
-

{donor.credits}

-

Credits Earned

+
+ + Redeem credits towards verified blood requests. +
+
+ + We recommend waiting at least 6 months between donations. +
+
+ + PulseConnect follows a safe, verified donation cycle.
- ) : ( - - -

Complete Your Donor Profile

-

- Register as a donor to start saving lives and earning credits -

- -
- )} - - {/* Tips & Credit Info */} -
- - - Donation Tips - - -

• Eat a healthy meal before donating

-

• Stay hydrated before and after donation

-

• Rest the night before

-

• Avoid alcohol 24 hours before

-

• Bring a valid ID & eat iron-rich foods

-
-
- - - - Credit System - - -
- Earn 5 credits per donation -
-
- Redeem credits for blood requests -
-
- Donate every 6 months -
-
- Verified safe donation cycle -
-
-
-
-
+ +
); }