chore(capacitor): refactor codebase for capacitor entry

This commit is contained in:
shafin-r
2025-09-08 13:42:15 +06:00
parent 3b2488054c
commit 99d6c15e38
21 changed files with 123 additions and 491 deletions

View File

@ -8,68 +8,41 @@ import SlidingGallery from "@/components/SlidingGallery";
import BackgroundWrapper from "@/components/BackgroundWrapper";
import { ChevronRight } from "lucide-react";
import styles from "@/css/Home.module.css";
import { API_URL } from "@/lib/auth";
import { Avatar } from "@/components/ui/avatar";
import { getLinkedViews } from "@/lib/gallery-views";
import { getTopThree } from "@/lib/leaderboard";
import DestructibleAlert from "@/components/DestructibleAlert";
import { GalleryViews } from "@/types/gallery";
interface LeaderboardEntry {
id: string;
name: string;
points: number;
}
import { useAuthStore } from "@/stores/authStore";
import DestructibleAlert from "@/components/DestructibleAlert";
const HomePage = () => {
const router = useRouter();
const [boardData, setBoardData] = useState<LeaderboardEntry[]>([]);
const [boardError, setBoardError] = useState<string | null>(null);
const [linkedViews, setLinkedViews] = useState<GalleryViews[]>();
const { user } = useAuthStore();
useEffect(() => {
// let isMounted = true;
// const fetchBoardData = async () => {
// try {
// const response = await fetch(`${API_URL}/leaderboard`);
// if (!response.ok) {
// throw new Error("Failed to fetch leaderboard data");
// }
// const data: LeaderboardEntry[] = await response.json();
// if (isMounted) setBoardData(data);
// } catch (err) {
// if (isMounted) {
// const message =
// err instanceof Error ? err.message : "An unexpected error occurred";
// setBoardError(message);
// }
// }
// };
const fetchedLinkedViews: GalleryViews[] = getLinkedViews();
setLinkedViews(fetchedLinkedViews);
// fetchBoardData();
// return () => {
// isMounted = false;
// };
}, []);
return (
<BackgroundWrapper>
<div className={styles.container}>
<div className="flex-1 min-h-screen">
<Header displayUser />
<div className={styles.scrollContainer}>
<div className={styles.contentWrapper}>
<div className="overflow-y-auto pt-4 h-[calc(100vh-80px)]">
<div className="pb-40 mx-6">
{!user?.is_verified && (
<DestructibleAlert
text="Please verify your account. Check your email for the verification link."
variant="warning"
/>
)}
<SlidingGallery views={linkedViews} height="23vh" />
<div className={styles.mainContent}>
<div className="flex flex-col gap-9">
{/* Categories Section */}
<div>
<div className={styles.sectionHeader}>
<h2 className={styles.sectionTitle}>Categories</h2>
<div className="flex item-scenter justify-between">
<h2 className="text-2xl font-bold text-[#113768]">
Categories
</h2>
<button
onClick={() => router.push("/categories")}
className={styles.arrowButton}