design upgrade

This commit is contained in:
Nermin Karic
2026-11-23 00:59:47 +01:00
parent 9e84140474
commit ada6fd857c
198 changed files with 6626 additions and 2539 deletions

View File

@@ -1,121 +1,59 @@
"use client"
import { LogOut, User, MapPin, Package, ChevronRight } from "lucide-react"
import { useParams, usePathname } from "next/navigation"
import { signout } from "@lib/data/customer"
import { HttpTypes } from "@medusajs/types"
import LocalizedClientLink from "@modules/common/components/localized-client-link"
import { cn } from "@/lib/utils"
const AccountNav = ({
customer,
}: {
customer: HttpTypes.StoreCustomer | null
}) => {
const NAV_LINKS = [
{ href: "/account", label: "Pregled" },
{ href: "/account/profile", label: "Profil" },
{ href: "/account/addresses", label: "Adrese" },
{ href: "/account/orders", label: "Narudžbe" },
]
/** Account tabs, same pill style as the catalog category tabs */
const AccountNav = ({ customer: _customer }: { customer: HttpTypes.StoreCustomer | null }) => {
const route = usePathname()
const { countryCode } = useParams() as { countryCode: string }
const handleLogout = async () => {
await signout(countryCode)
const isActive = (href: string) => {
const full = `/${countryCode}${href}`
// Order details live under /account/orders/details/...
return href === "/account" ? route === full : route.startsWith(full)
}
const navLinks = [
{ href: "/account", label: "Pregled Naloga", icon: User },
{ href: "/account/profile", label: "Profil i Podaci", icon: User },
{ href: "/account/addresses", label: "Adrese za Isporuku", icon: MapPin },
{ href: "/account/orders", label: "Moje Narudžbe", icon: Package },
]
return (
<div className="w-full">
{/* Mobile nav */}
<div className="sm:hidden" data-testid="mobile-account-nav">
{route !== `/${countryCode}/account` ? (
<LocalizedClientLink
href="/account"
className="flex items-center gap-2 text-sm font-medium py-3 border-b border-border"
data-testid="account-main-link"
>
<ChevronRight className="h-4 w-4 rotate-180 text-muted-foreground" />
<span>Nazad na nalog</span>
</LocalizedClientLink>
) : (
<div className="flex flex-col gap-3 py-4">
<h2 className="text-xl font-bold tracking-tight text-foreground">
Pozdrav, {customer?.first_name || "Korisnik"}
</h2>
<div className="flex flex-col divide-y divide-border rounded-xl border border-border bg-card">
{navLinks.map((link) => {
const Icon = link.icon
return (
<LocalizedClientLink
key={link.href}
href={link.href}
className="flex items-center justify-between p-4 text-sm font-medium text-foreground hover:bg-accent"
>
<div className="flex items-center gap-3">
<Icon className="h-4 w-4 text-muted-foreground" />
<span>{link.label}</span>
</div>
<ChevronRight className="h-4 w-4 text-muted-foreground" />
</LocalizedClientLink>
)
})}
<button
type="button"
className="flex items-center justify-between p-4 text-sm font-medium text-destructive hover:bg-destructive/10 text-left"
onClick={handleLogout}
data-testid="logout-button"
>
<div className="flex items-center gap-3">
<LogOut className="h-4 w-4" />
<span>Odjavi se</span>
</div>
</button>
</div>
</div>
)}
</div>
{/* Desktop nav */}
<div className="hidden sm:block" data-testid="account-nav">
<div className="flex flex-col gap-4 rounded-xl border border-border bg-card p-5">
<h3 className="text-sm font-semibold uppercase tracking-wider text-muted-foreground px-3">
Moj Nalog
</h3>
<nav className="flex flex-col gap-1">
{navLinks.map((link) => {
const Icon = link.icon
const active = route.endsWith(link.href)
return (
<LocalizedClientLink
key={link.href}
href={link.href}
className={cn(
"flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors",
active
? "bg-primary text-primary-foreground shadow-sm"
: "text-muted-foreground hover:text-foreground hover:bg-muted"
)}
>
<Icon className="h-4 w-4" />
<span>{link.label}</span>
</LocalizedClientLink>
)
})}
<button
type="button"
onClick={handleLogout}
className="flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium text-destructive hover:bg-destructive/10 transition-colors text-left mt-2 pt-2 border-t border-border"
data-testid="logout-button"
<nav aria-label="Moj račun" className="flex justify-center" data-testid="account-nav">
<div className="inline-flex max-w-full items-center gap-1 overflow-x-auto rounded-lg bg-muted p-1 text-sm">
{NAV_LINKS.map((link) => {
const active = isActive(link.href)
return (
<LocalizedClientLink
key={link.href}
href={link.href}
aria-current={active ? "page" : undefined}
className={cn(
"whitespace-nowrap rounded-md px-4 py-2 transition-colors",
active ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
)}
data-testid={link.href === "/account" ? "account-main-link" : undefined}
>
<LogOut className="h-4 w-4" />
<span>Odjava</span>
</button>
</nav>
</div>
{link.label}
</LocalizedClientLink>
)
})}
<button
type="button"
onClick={() => signout(countryCode)}
className="whitespace-nowrap rounded-md px-4 py-2 text-muted-foreground transition-colors hover:text-destructive"
data-testid="logout-button"
>
Odjava
</button>
</div>
</div>
</nav>
)
}