From 21508a3514500f8f38ddaa8bef7a9cd420d76628 Mon Sep 17 00:00:00 2001
From: HombreLaser <sebastian-440@live.com>
Date: Mon, 22 May 2023 21:18:20 -0600
Subject: Añade carrito
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/components/navbar.tsx | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

(limited to 'src/components/navbar.tsx')

diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx
index d136e31..4078405 100644
--- a/src/components/navbar.tsx
+++ b/src/components/navbar.tsx
@@ -2,8 +2,26 @@ import { CartFill } from "react-bootstrap-icons";
 import "./stylesheets/navbar.css";
 import "./stylesheets/shared.css";
 import MainPageDropdownMenu from "./main_page_dropdown_menu";
+import Token from "../lib/token";
 
 export default function Navbar() {
+  const session = new Token();
+  let cart;
+
+  if (session.present()) {
+    cart = (
+      <a className="mr-4 text-neutral-500 hover:text-neutral-700 focus:text-neutral-700 disabled:text-black/30 dark:text-neutral-200 dark:hover:text-neutral-300 dark:focus:text-neutral-300 [&.active]:text-black/90 dark:[&.active]:text-neutral-400"
+          href="/account/cart">
+        <span className="[&>svg]:w-5">
+          <CartFill color="#394490" size={32}/>
+        </span>
+      </a>
+    );  
+  }
+  else {
+    cart = null;
+  }
+
   return(
     <>
       <header>
@@ -33,12 +51,8 @@ export default function Navbar() {
 
               { /* Lado derecho */}
               <div className="flex items-center">
-                <a className="mr-4 text-neutral-500 hover:text-neutral-700 focus:text-neutral-700 disabled:text-black/30 dark:text-neutral-200 dark:hover:text-neutral-300 dark:focus:text-neutral-300 [&.active]:text-black/90 dark:[&.active]:text-neutral-400"
-                   href="#">
-                  <span className="[&>svg]:w-5">
-                    <CartFill color="#394490" size={32}/>
-                  </span>
-                </a>
+
+                {cart}
 
                 <MainPageDropdownMenu/>
               </div>
-- 
cgit v1.2.3

