diff --git a/public/images/goggle.svg b/public/images/google.svg similarity index 100% rename from public/images/goggle.svg rename to public/images/google.svg diff --git a/src/app/(auth-routes)/login/page.tsx b/src/app/(auth-routes)/login/page.tsx index 5de3c9d0b..8d1200af9 100644 --- a/src/app/(auth-routes)/login/page.tsx +++ b/src/app/(auth-routes)/login/page.tsx @@ -23,6 +23,7 @@ import { FormMessage, } from "~/components/ui/form"; import { Input } from "~/components/ui/input"; +import { useUser } from "~/hooks/user/use-user"; import { simulateDelay } from "~/lib/utils"; const loginSchema = z.object({ @@ -53,6 +54,7 @@ const LoginPage = () => { const searchP = useSearchParams(); const callback_url = searchP.get("callbackUrl"); const [isLoading, startTransition] = useTransition(); + const { updateUser } = useUser(); const form = useForm({ resolver: zodResolver(loginSchema), @@ -68,7 +70,7 @@ const LoginPage = () => { startTransition(async () => { await simulateDelay(3); await loginUser(values); - + updateUser({ email: values.email, name: values.email.split("@")[0] }); if (callback_url) { router.push(callback_url); } else { diff --git a/src/app/(auth-routes)/register/page.tsx b/src/app/(auth-routes)/register/page.tsx index ce3b5aa33..5d50ba109 100644 --- a/src/app/(auth-routes)/register/page.tsx +++ b/src/app/(auth-routes)/register/page.tsx @@ -23,6 +23,8 @@ import { InputOTPGroup, InputOTPSlot, } from "~/components/ui/input-otp"; +import Google from "../../../../public/images/google.svg"; +import Facebook from "../../../../public/images/facebook.svg"; const formSchema = z.object({ fullname: z.string().min(2, { @@ -53,14 +55,8 @@ const SignUp = () => {

- - + +
diff --git a/src/app/favicon.ico b/src/app/favicon.ico index 4570eb8d9..de1787396 100644 Binary files a/src/app/favicon.ico and b/src/app/favicon.ico differ diff --git a/src/components/card/user-card.tsx b/src/components/card/user-card.tsx new file mode 100644 index 000000000..517cb2d81 --- /dev/null +++ b/src/components/card/user-card.tsx @@ -0,0 +1,92 @@ +import { TooltipArrow, TooltipPortal } from "@radix-ui/react-tooltip"; +import { motion } from "framer-motion"; +import { usePathname } from "next/navigation"; +import { useMemo, useState } from "react"; + +import { deleteUserCookie } from "~/actions/login"; +import { useUser } from "~/hooks/user/use-user"; +import { cn } from "~/lib/utils"; +import { Button } from "../ui/button"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "../ui/tooltip"; + +const generateTailwindBGs = () => { + const colors = [ + "bg-red-500", + "bg-orange-500", + "bg-yellow-500", + "bg-green-500", + "bg-teal-500", + "bg-blue-500", + "bg-indigo-500", + "bg-purple-500", + "bg-pink-500", + ]; + const randomColor = colors[Math.floor(Math.random() * colors.length)]; + return randomColor; +}; + +const UserCard = ({ email }: { email: string }) => { + const { updateUser } = useUser(); + const [bgColor, setBgColor] = useState("bg-red-500"); + const pathname = usePathname(); + + useMemo(() => { + if (pathname === "/") { + setBgColor(generateTailwindBGs()); + } + }, [pathname]); + + return ( +
+ + + + + + + + + + + + + + + +
+ ); +}; + +export default UserCard; diff --git a/src/components/layouts/navbar/index.tsx b/src/components/layouts/navbar/index.tsx index 37337b742..027a29789 100644 --- a/src/components/layouts/navbar/index.tsx +++ b/src/components/layouts/navbar/index.tsx @@ -4,7 +4,9 @@ import { BellIcon, Menu, User } from "lucide-react"; import Link from "next/link"; import { useEffect, useState } from "react"; +import UserCard from "~/components/card/user-card"; import Logo from "~/components/common/logo"; +import { useUser } from "~/hooks/user/use-user"; const navlinks = [ { route: "Home", link: "/" }, @@ -14,8 +16,7 @@ const navlinks = [ const Navbar = ({ is_auth_path = false }: { is_auth_path?: boolean }) => { const [scrolling, setIsScrolling] = useState(false); - - // + const { user } = useUser(); const handleScrollEvent = () => { if (window.scrollY > 1) { @@ -55,7 +56,7 @@ const Navbar = ({ is_auth_path = false }: { is_auth_path?: boolean }) => { ); })}
- {!is_auth_path && ( + {!is_auth_path && !user.email && (
{
)} + {user.email && }
diff --git a/src/hooks/user/use-user.ts b/src/hooks/user/use-user.ts index cfa8f5871..57bce0982 100644 --- a/src/hooks/user/use-user.ts +++ b/src/hooks/user/use-user.ts @@ -4,7 +4,6 @@ import { persist, PersistStorage } from "zustand/middleware"; type UserProperties = { name: string | undefined; email: string | undefined; - id: string | undefined; }; type ProductsStateProperties = { @@ -25,13 +24,12 @@ const storage: PersistStorage = { removeItem: (name) => localStorage.removeItem(name), }; -export const useProductsFilters = create()( +export const useUser = create()( persist( (set) => ({ user: { name: undefined, email: undefined, - id: undefined, }, updateUser: (user) => set({ user }), }), diff --git a/src/lib/services/session.ts b/src/lib/services/session.ts index 7d731c4fb..ebefa26de 100644 --- a/src/lib/services/session.ts +++ b/src/lib/services/session.ts @@ -78,5 +78,6 @@ export async function updateSession() { } export async function deleteSession() { + deleteCookie("session"); deleteCookie("session", { cookies }); }