first commit

This commit is contained in:
Nermin Karic
2026-11-22 21:49:17 +01:00
commit f5e2fcbf98
693 changed files with 82975 additions and 0 deletions

View File

@@ -0,0 +1,122 @@
"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 route = usePathname()
const { countryCode } = useParams() as { countryCode: string }
const handleLogout = async () => {
await signout(countryCode)
}
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"
>
<LogOut className="h-4 w-4" />
<span>Odjava</span>
</button>
</nav>
</div>
</div>
</div>
)
}
export default AccountNav