summaryrefslogtreecommitdiff
path: root/storefront/components
diff options
context:
space:
mode:
authorertopogo <erwin.t.pombett@gmail.com>2026-02-01 02:49:28 +0100
committerertopogo <erwin.t.pombett@gmail.com>2026-02-01 02:49:28 +0100
commite704383cb20e7016794ccc793eda057a609be835 (patch)
treec4a909978dadd9d6315e65e588a39fedaa4d1e47 /storefront/components
parentb034acb10960a404262602920cb07e63455f7dc3 (diff)
ajout de cart pour les commandes
Diffstat (limited to 'storefront/components')
-rw-r--r--storefront/components/Layout.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/storefront/components/Layout.js b/storefront/components/Layout.js
new file mode 100644
index 0000000..dce09eb
--- /dev/null
+++ b/storefront/components/Layout.js
@@ -0,0 +1,77 @@
+import { useEffect, useState } from "react"
+import Link from "next/link"
+import { medusaClient } from "../lib/medusa-client"
+import { clearStoredToken, getStoredToken } from "../lib/storefront"
+
+export default function Layout({ children }) {
+ const [isLoggedIn, setIsLoggedIn] = useState(false)
+
+ useEffect(() => {
+ const token = getStoredToken()
+ if (token) {
+ medusaClient.setToken(token)
+ setIsLoggedIn(true)
+ }
+ }, [])
+
+ const handleLogout = () => {
+ clearStoredToken()
+ medusaClient.setToken(null)
+ setIsLoggedIn(false)
+ }
+
+ return (
+ <div style={{ minHeight: "100vh", fontFamily: "sans-serif", background: "#f8f8f8" }}>
+ <header
+ style={{
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "space-between",
+ padding: "1rem 2rem",
+ background: "#fff",
+ borderBottom: "1px solid #e6e6e6",
+ }}
+ >
+ <Link href="/" style={{ fontWeight: 600, textDecoration: "none", color: "#222" }}>
+ Lucien-sens-bon
+ </Link>
+ <nav style={{ display: "flex", gap: "1rem", alignItems: "center" }}>
+ <Link href="/" style={{ textDecoration: "none", color: "#444" }}>
+ Boutique
+ </Link>
+ <Link href="/cart" style={{ textDecoration: "none", color: "#444" }}>
+ Panier
+ </Link>
+ <Link href="/checkout" style={{ textDecoration: "none", color: "#444" }}>
+ Commander
+ </Link>
+ {!isLoggedIn ? (
+ <>
+ <Link href="/register" style={{ textDecoration: "none", color: "#444" }}>
+ Créer un compte
+ </Link>
+ <Link href="/login" style={{ textDecoration: "none", color: "#444" }}>
+ Se connecter
+ </Link>
+ </>
+ ) : (
+ <button
+ type="button"
+ onClick={handleLogout}
+ style={{
+ border: "1px solid #ccc",
+ background: "#fff",
+ borderRadius: "6px",
+ padding: "0.4rem 0.8rem",
+ cursor: "pointer",
+ }}
+ >
+ Se déconnecter
+ </button>
+ )}
+ </nav>
+ </header>
+ <main style={{ padding: "2rem" }}>{children}</main>
+ </div>
+ )
+}