fix: better ui #45
@@ -1,6 +1,7 @@
|
|||||||
import { CartFab } from "@/components/organisms/cart";
|
import { CartFab } from "@/components/organisms/cart";
|
||||||
import Footer from "@/layouts/footer";
|
import Footer from "@/layouts/footer";
|
||||||
import Header from "@/layouts/header";
|
import Header from "@/layouts/header";
|
||||||
|
import { ManagerProvider } from "@/lib/manager-context";
|
||||||
|
|
||||||
import type { MainLayoutProps } from "./MainLayout.types";
|
import type { MainLayoutProps } from "./MainLayout.types";
|
||||||
|
|
||||||
@@ -12,7 +13,9 @@ export default function MainLayout({ children }: MainLayoutProps) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Sticky top header */}
|
{/* Sticky top header */}
|
||||||
<Header />
|
<ManagerProvider>
|
||||||
|
<Header />
|
||||||
|
</ManagerProvider>
|
||||||
|
|
||||||
{/* Page content (grows to fill remaining height) */}
|
{/* Page content (grows to fill remaining height) */}
|
||||||
<div className="flex-1">{children}</div>
|
<div className="flex-1">{children}</div>
|
||||||
|
|||||||
+4
-2
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useAuth } from "@/lib/auth-context";
|
import { useAuth } from "@/lib/auth-context";
|
||||||
import { SHOP_INFO } from "@/lib/constants";
|
import { SHOP_INFO } from "@/lib/constants";
|
||||||
|
import { useManager } from "@/lib/manager-context";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
@@ -25,6 +26,7 @@ import { useRouter } from "next/navigation";
|
|||||||
*/
|
*/
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { eatery } = useManager();
|
||||||
const { user, logout } = useAuth();
|
const { user, logout } = useAuth();
|
||||||
|
|
||||||
const handleAuthClick = () => {
|
const handleAuthClick = () => {
|
||||||
@@ -47,7 +49,7 @@ export default function Header() {
|
|||||||
<div className="relative h-10 w-10 shrink-0 md:h-11 md:w-11">
|
<div className="relative h-10 w-10 shrink-0 md:h-11 md:w-11">
|
||||||
<Image
|
<Image
|
||||||
src={SHOP_INFO.logo}
|
src={SHOP_INFO.logo}
|
||||||
alt={`${SHOP_INFO.name} logo`}
|
alt={`${eatery?.name} logo`}
|
||||||
fill
|
fill
|
||||||
className="object-contain transition-transform duration-200 group-hover:scale-105"
|
className="object-contain transition-transform duration-200 group-hover:scale-105"
|
||||||
sizes="44px"
|
sizes="44px"
|
||||||
@@ -58,7 +60,7 @@ export default function Header() {
|
|||||||
{/* Name + tagline */}
|
{/* Name + tagline */}
|
||||||
<div className="flex flex-col leading-tight">
|
<div className="flex flex-col leading-tight">
|
||||||
<span className="text-base font-bold text-(--color-primary-dark) transition-colors duration-150 group-hover:text-(--color-primary) md:text-lg">
|
<span className="text-base font-bold text-(--color-primary-dark) transition-colors duration-150 group-hover:text-(--color-primary) md:text-lg">
|
||||||
{SHOP_INFO.name}
|
{eatery?.name}
|
||||||
</span>
|
</span>
|
||||||
<span className="hidden text-xs text-(--color-text-muted) md:block">
|
<span className="hidden text-xs text-(--color-text-muted) md:block">
|
||||||
{SHOP_INFO.tagline}
|
{SHOP_INFO.tagline}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
|
|
||||||
import { eateryClient } from "./apollo-clients";
|
import { eateryClient } from "./apollo-clients";
|
||||||
import {
|
import {
|
||||||
|
EateryEntity,
|
||||||
type MenuItemEntity,
|
type MenuItemEntity,
|
||||||
type addMenuItemMutation,
|
type addMenuItemMutation,
|
||||||
type allEateriesQuery,
|
type allEateriesQuery,
|
||||||
@@ -27,6 +28,7 @@ interface ManagerContextType {
|
|||||||
// Data
|
// Data
|
||||||
products: MenuItemEntity[];
|
products: MenuItemEntity[];
|
||||||
eateryId: string | null;
|
eateryId: string | null;
|
||||||
|
eatery: EateryEntity;
|
||||||
|
|
||||||
// Active tab
|
// Active tab
|
||||||
activeTab: ManagerTab;
|
activeTab: ManagerTab;
|
||||||
@@ -49,6 +51,7 @@ const GET_EATERY_MENU = gql`
|
|||||||
query GetEateryMenu {
|
query GetEateryMenu {
|
||||||
allEateries {
|
allEateries {
|
||||||
id
|
id
|
||||||
|
name
|
||||||
menuItems {
|
menuItems {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@@ -97,6 +100,7 @@ const DELETE_MENU_ITEM = gql`
|
|||||||
|
|
||||||
export function ManagerProvider({ children }: { children: ReactNode }) {
|
export function ManagerProvider({ children }: { children: ReactNode }) {
|
||||||
const [products, setProducts] = useState<MenuItemEntity[]>([]);
|
const [products, setProducts] = useState<MenuItemEntity[]>([]);
|
||||||
|
const [eatery, setEatery] = useState<EateryEntity>();
|
||||||
const [activeTab, setActiveTab] = useState<ManagerTab>("products");
|
const [activeTab, setActiveTab] = useState<ManagerTab>("products");
|
||||||
|
|
||||||
const { data } = useQuery<allEateriesQuery>(GET_EATERY_MENU, {
|
const { data } = useQuery<allEateriesQuery>(GET_EATERY_MENU, {
|
||||||
@@ -123,6 +127,7 @@ export function ManagerProvider({ children }: { children: ReactNode }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data?.allEateries?.[0]) {
|
if (data?.allEateries?.[0]) {
|
||||||
setProducts(data.allEateries[0].menuItems);
|
setProducts(data.allEateries[0].menuItems);
|
||||||
|
setEatery(data.allEateries[0]);
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
@@ -193,6 +198,7 @@ export function ManagerProvider({ children }: { children: ReactNode }) {
|
|||||||
return (
|
return (
|
||||||
<ManagerContext.Provider
|
<ManagerContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
eatery,
|
||||||
products,
|
products,
|
||||||
eateryId,
|
eateryId,
|
||||||
activeTab,
|
activeTab,
|
||||||
|
|||||||
Reference in New Issue
Block a user