diff --git a/components/header/Drawers.tsx b/components/header/Drawers.tsx index 95fa0b2..2f783cb 100644 --- a/components/header/Drawers.tsx +++ b/components/header/Drawers.tsx @@ -65,7 +65,14 @@ const Aside = ( ); function Drawers({ menu, searchbar, children, platform }: Props) { - const { displayCart, displayMenu, displaySearchDrawer } = useUI(); + const { displayCart, displayMenu, displaySearchDrawer, user } = useUI(); + + console.log({ userDrawers: user.value }); + + //if user is not loggedin, use the public navitems in the menu + if (localStorage.getItem("AccessToken") == "") { + menu.items = menu.publicItems || []; + } return ( <> diff --git a/components/header/Header.tsx b/components/header/Header.tsx index 1a61cf8..d069bfa 100644 --- a/components/header/Header.tsx +++ b/components/header/Header.tsx @@ -34,6 +34,12 @@ export interface Props { */ navItems?: SiteNavigationElement[] | null; + /** + * @title Public Navigation items + * @description Navigation items used both on mobile and desktop menus + */ + publicNavItems?: SiteNavigationElement[] | null; + /** @title Logo */ logo?: Logo; @@ -69,6 +75,28 @@ function Header({ url: "/", }, ], + publicNavItems = [ + { + "@type": "SiteNavigationElement", + name: "Feminino", + url: "/", + }, + { + "@type": "SiteNavigationElement", + name: "Masculino", + url: "/", + }, + { + "@type": "SiteNavigationElement", + name: "Sale", + url: "/", + }, + { + "@type": "SiteNavigationElement", + name: "Linktree", + url: "/", + }, + ], logo = { src: "https://ozksgdmyrqcxcwhnbepg.supabase.co/storage/v1/object/public/assets/2291/986b61d4-3847-4867-93c8-b550cb459cc7", @@ -82,24 +110,23 @@ function Header({ device, }: SectionProps) { const platform = usePlatform(); - const items = navItems ?? []; return ( <>
diff --git a/components/header/Menu.tsx b/components/header/Menu.tsx index 089fcb8..87d19c6 100644 --- a/components/header/Menu.tsx +++ b/components/header/Menu.tsx @@ -4,6 +4,7 @@ import type { SiteNavigationElement } from "apps/commerce/types.ts"; export interface Props { items: SiteNavigationElement[]; + publicItems?: SiteNavigationElement[]; logo?: Logo; } diff --git a/components/header/Navbar.tsx b/components/header/Navbar.tsx index ac51ab8..3236d3d 100644 --- a/components/header/Navbar.tsx +++ b/components/header/Navbar.tsx @@ -1,6 +1,5 @@ import type { Props as SearchbarProps } from "../../components/search/Searchbar.tsx"; import { MenuButton, SearchButton } from "../../islands/Header/Buttons.tsx"; -import { usePlatform } from "../../sdk/usePlatform.tsx"; import type { SiteNavigationElement } from "apps/commerce/types.ts"; import Image from "apps/website/components/Image.tsx"; import NavItem from "./NavItem.tsx"; @@ -9,17 +8,10 @@ import { Buttons, Logo } from "../../components/header/Header.tsx"; // Make it sure to render it on the server only. DO NOT render it on an island function Navbar( - { items, searchbar, logo, buttons, logoPosition = "left", device }: { - items: SiteNavigationElement[]; - searchbar?: SearchbarProps; + { logo }: { logo?: Logo; - buttons?: Buttons; - logoPosition?: "left" | "center"; - device: "mobile" | "desktop" | "tablet"; }, ) { - const platform = usePlatform(); - return (
r.json()); const username = response.data.Username; + + user.value = { + id: username, + name: response.data.UserAttributes.find(( + a: { Name: string; Value: string }, + ) => a.Name === "name").Value, + email: response.dataProfile.email, + plan: response.dataProfile.plan, + }; + + console.log({ userhere: user.value }); + updatedData.value = response.dataProfile.updatedData; uploadedFile.value = response.dataProfile.uploadedFile; if (!username) { + user.value = null; + localStorage.setItem("AccessToken", ""); window.location.href = "/"; } diff --git a/sdk/useUI.ts b/sdk/useUI.ts index 1e59e50..658d266 100644 --- a/sdk/useUI.ts +++ b/sdk/useUI.ts @@ -5,6 +5,13 @@ import { signal } from "@preact/signals"; +export type UserSession = { + id: string; + name: string; + email: string; + plan: string; +}; + const displayCart = signal(false); const displayMenu = signal(false); const displaySearchPopup = signal(false); @@ -16,6 +23,7 @@ const displayConfirmCancelSubscription = signal(false); const displayPlanLimit = signal(false); const updatedData = signal(true); const uploadedFile = signal(true); +const user = signal(null); const state = { displayCart, @@ -29,6 +37,7 @@ const state = { displayNewTicketModal, displayConfirmDeleteDoc, displayConfirmCancelSubscription, + user, }; // Keyboard event listeners