Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Raj100 committed Apr 14, 2024
1 parent 27e7b52 commit 031cf11
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 62 deletions.
12 changes: 6 additions & 6 deletions src/app/Profile/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Main = () => {
</div>

<div className="grid cols-span-2 border rounded-lg p-2">
<h1 className="text-center">Leaderboards</h1>
<h1 className="text-center">Leaderboard</h1>
{/* Render leaderboards data here */}
<div>
<div className="grid grid-cols-2">
Expand All @@ -129,7 +129,7 @@ const Main = () => {
</div>
</div>
<div className="grid cols-span-2 border rounded-lg p-2">
<h1 className="center">Educational Leaderboards</h1>
<h1 className="text-center">Educational Leaderboard</h1>
<div className="grid grid-cols-2">
<p>Name</p>
<p>XP</p>
Expand All @@ -143,12 +143,12 @@ const Main = () => {
</div>
</div>

<div className="w-90 h-72 border-2 bg-red-400 mx-10 my-10 justify-center items-center">
<div className="flex flex-col border-2 bg-red-400 mx-10 my-10 justify-center items-center p-10">
<div>
<h3 className="text-center">batches</h3>
<h3 className="text-center text-lg">Batches</h3>
</div>
<div className="flex justify-center mt-5 px-5">
<div className="flex items-center">
<div className="h-52 w-full mt-5 lg:px-5 overflow-hidden overflow-x-scroll">
<div className="flex h-full lg:justify-center items-center gap-10 overflow-scroll">
<div className="w-32 h-32 mx-2">
<Image
src={batch_1}
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export default function Home() {
<p className="text-center px-4 lg:px-32"> Welcome to the ultimate virtual trading experience! Immerse yourself in our interactive platform where learning and earning go hand-in-hand. Dive into our comprehensive tutorials, master the art of trading, and collect badges to showcase your achievements. Connect with a vibrant community of enthusiasts, engage in exhilarating challenges, and transform your skills into success. Our integrated store offers exclusive rewards, making your journey not just educational, but also rewarding. Join us and turn your trading aspirations into reality, all while having a blast! Let the adventure begin!</p>

<div className="spacer bg"></div>
<div className={`pt-10 flex flex-col items-center justify-center w-full p-4 lg:p-10 bg-[#0066FF]`}>
<TradingViewWidget className=""></TradingViewWidget>
<div className={`pt-10 hidden md:flex flex-col items-center justify-center w-full p-4 lg:p-10 bg-[#0066FF]`}>
<TradingViewWidget></TradingViewWidget>
</div>
<div className="bg2"></div>

Expand Down
146 changes: 92 additions & 54 deletions src/components/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import CustomizedSwitches from "../modeswitch/modeswitch";
import { AppContext } from "../AppContext/AppContext";
import { useContext } from "react";
import Logo from "../../assets/logo.png";
import Swal from 'sweetalert2'
import Swal from "sweetalert2";

import Image from "next/image";
const Navbar = () => {
const [userEmail, setUserEmail] = useState(null);
const [meuopen, setmenuopen] = useState(false);
const { theme, settheme } = useContext(AppContext);
const [zeta, setzeta] = useState(0);
const [menu2,setmenu2]=useState(0);
const [loading,setLoading]=useState(true);
const [menu2, setmenu2] = useState(0);
const [loading, setLoading] = useState(true);

useEffect(() => {
const fetchUser = async () => {
Expand Down Expand Up @@ -51,44 +51,43 @@ const [loading,setLoading]=useState(true);
}
};




useEffect(() => {
const fetchData = async () => {
// Fetch user data
const { data: { user } } = await supabase.auth.getUser();
const {
data: { user },
} = await supabase.auth.getUser();
if (user) {
setUserEmail(user.email);
// Fetch balance only if user email is available
const { data: UserData, error } = await supabase
.from('UserData')
.select('balance')
.eq('email', user.email);
.from("UserData")
.select("balance")
.eq("email", user.email);
if (error) {
console.error('Error fetching balance:', error.message);
console.error("Error fetching balance:", error.message);
return;
}
// If data is fetched successfully, log and alert the balance
if (UserData.length > 0) {
const balance = UserData[0].balance;
console.log('Balance:', balance);
console.log("Balance:", balance);
setzeta(balance);
} else {
console.log('No balance found for user:', user.email);
console.log("No balance found for user:", user.email);
}
} else {
setUserEmail(null);
}
};

fetchData();
}, []);

return (
<>
<header
className={`fixed flex w-full justify-between items-center px-10 lg:px-24 py-4 lg:py-8 dark:bg-slate-800 text-${theme}txt ${
className={`fixed flex w-full justify-between items-center px-4 lg:px-24 py-4 lg:py-8 dark:bg-slate-800 text-${theme}txt ${
theme === "dark"
? "bg-gradient-to-r from-40% from-slate-800 via-slate-700 to-60% to-slate-800 "
: " bg-gradient-to-r from-[#baecee] via-yellow-100 to-[#baecee] shadow-lg"
Expand All @@ -98,8 +97,8 @@ const [loading,setLoading]=useState(true);
Tradein
</Link>
<ul className="hidden lg:flex space-x-5 ">
<li className="hover:text-emerald-300 p-2">
<Link href="/Education">Education</Link>
<li className="hover:text-emerald-300 p-2">
<Link href="/Education">Education</Link>
</li>
<li className="hover:text-emerald-300 p-2">
{" "}
Expand All @@ -110,30 +109,43 @@ const [loading,setLoading]=useState(true);
<Link href="/chat">Community chat</Link>
</li>
</ul>
<div className="hidden lg:flex items-center space-x-2 ">
{userEmail && (
<>
<div className={`flex items-center`}>
<Image className="w-4" src={Logo} alt="Logo" />
{zeta}
</div>
<div className="hidden lg:flex items-center space-x-2 ">
{userEmail && (
<>
<div className={`flex items-center`}>
<Image className="w-4" src={Logo} alt="Logo" />
{zeta}
</div>
<div className="">
<Link href="/Store"><i class="fa-solid fa-store text-xl"></i> Store </Link>
<Link href="/Store">
<i class="fa-solid fa-store text-xl"></i> Store{" "}
</Link>
</div>
</>
)}
</>
)}
{userEmail ? (
<>
<div

className={`p-2 hover:text-emerald-500 cursor-pointer relative`}
onMouseOver={()=>{setmenu2(1);}}
onMouseLeave={()=>{setmenu2(0);}}
onMouseOver={() => {
setmenu2(1);
}}
onMouseLeave={() => {
setmenu2(0);
}}
>
{userEmail}
<ul className={` ${menu2?"absolute":"hidden"} bg-white text-black rounded-md pt-2 `}>
<Link href="/Profile" className="border-b p-4 ">Profile <i class="fa-solid fa-user"></i></Link>
<li onClick={logout} className="p-4 cursor-pointer">Logout <i class="fa-solid fa-arrow-right-from-bracket"></i></li>
<ul
className={` ${
menu2 ? "absolute" : "hidden"
} bg-white text-black rounded-md pt-2 `}
>
<Link href="/Profile" className="border-b p-4 ">
Profile <i class="fa-solid fa-user"></i>
</Link>
<li onClick={logout} className="p-4 cursor-pointer">
Logout <i class="fa-solid fa-arrow-right-from-bracket"></i>
</li>
</ul>
</div>
</>
Expand All @@ -144,26 +156,42 @@ const [loading,setLoading]=useState(true);
</div>
</div>
)}
<div>
<CustomizedSwitches
onChange={() => {
if (theme === "dark") {
settheme("light");
} else {
settheme("dark");
}
}}
checked={theme === "dark" ? true : false}
/>
</div>
<div>
<CustomizedSwitches
onChange={() => {
if (theme === "dark") {
settheme("light");
} else {
settheme("dark");
}
}}
checked={theme === "dark" ? true : false}
/>
</div>
</div>

<div onClick={handlemenu} className="lg:hidden text-2xl p-2">
<i className={`fa-solid ${meuopen ? "fa-xmark" : "fa-bars"}`}></i>
<div className="lg:hidden flex gap-4 items-center">
{userEmail ? (
<div className=" flex items-center gap-1">
<div className="text-2xl">
<i class="fa-regular fa-circle-user"></i>
</div>
<div className="text-[10px]">
<p>{userEmail}</p>
<p>{zeta}</p>
</div>
</div>
) : (
<Link href="/Login">Login</Link>
)}
<div onClick={handlemenu} className="lg:hidden text-2xl">
<i className={`fa-solid ${meuopen ? "fa-xmark" : "fa-bars"}`}></i>
</div>
</div>
</header>

<div
className={`absolute w-full bg-${theme}bg z-[10] transition duration-300 lg:hidden ${
className={`fixed w-full text-${theme}txt bg-${theme}bg z-[10] transition duration-300 lg:hidden ${
meuopen ? "" : "-translate-y-full"
}`}
>
Expand All @@ -181,35 +209,45 @@ const [loading,setLoading]=useState(true);
}`}
>
{" "}
<Link href="/Eduction"><i class="fa-solid fa-graduation-cap"></i> Eduction</Link>
<Link href="/Eduction">
<i class="fa-solid fa-graduation-cap"></i> Eduction
</Link>
</li>
<li
className={`hover:text-yellow-300 p-2 transition duration-[600ms] ${
meuopen ? "" : "-translate-x-full"
}`}
>
<Link href="/VirtualTrading"><i class="fa-solid fa-arrow-trend-up"></i> VirtualTrading</Link>
<Link href="/VirtualTrading">
<i class="fa-solid fa-arrow-trend-up"></i> VirtualTrading
</Link>
</li>
<li
className={`hover:text-yellow-300 p-2 transition duration-[750ms] ${
meuopen ? "" : "-translate-x-full"
}`}
>
<Link href="/Store"><i class="fa-solid fa-store"></i> Store</Link>
<Link href="/Store">
<i class="fa-solid fa-store"></i> Store
</Link>
</li>
<li
className={`hover:text-yellow-300 p-2 transition duration-[900ms] ${
meuopen ? "" : "-translate-x-full"
}`}
>
<Link href="/chat"><i class="fa-solid fa-users"></i> Community</Link>
<Link href="/chat">
<i class="fa-solid fa-users"></i> Community
</Link>
</li>
<li
className={`hover:text-red-300 p-2 transition duration-[1050ms] ${
meuopen ? "" : "-translate-x-full"
}`}
>
<Link href="/Profile"><i class="fa-solid fa-user"></i> Profile</Link>
<Link href="/Profile">
<i class="fa-solid fa-user"></i> Profile
</Link>
</li>
<div className="hidden lg:block">
{userEmail ? (
Expand Down

0 comments on commit 031cf11

Please sign in to comment.