diff options
| author | ertopogo <erwin.t.pombett@gmail.com> | 2026-02-01 02:53:13 +0100 |
|---|---|---|
| committer | ertopogo <erwin.t.pombett@gmail.com> | 2026-02-01 02:53:13 +0100 |
| commit | bc6f65dc9afa29fbb94038b1cfd5cbee2d87719c (patch) | |
| tree | 745095c67dc674567d4e0823388252b104a2e17e /storefront/components | |
| parent | e704383cb20e7016794ccc793eda057a609be835 (diff) | |
feat: mise à jour storefront + checkout
Diffstat (limited to 'storefront/components')
| -rw-r--r-- | storefront/components/Layout.js | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/storefront/components/Layout.js b/storefront/components/Layout.js index dce09eb..bb3070f 100644 --- a/storefront/components/Layout.js +++ b/storefront/components/Layout.js @@ -1,77 +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> - ) -} +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>
+ )
+}
|
