jaecoo-kelapagading/components/landing-page/navbar.tsx

680 lines
25 KiB
TypeScript
Raw Normal View History

2025-07-14 07:31:51 +00:00
"use client";
import Image from "next/image";
import Link from "next/link";
import { Button } from "@/components/ui/button";
import { ChevronDown, Lock, Menu, X } from "lucide-react";
import { useEffect, useState } from "react";
import { usePathname } from "next/navigation";
import { AnimatePresence, motion } from "framer-motion";
2025-07-14 11:55:57 +00:00
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "../ui/dialog";
import { Input } from "../ui/input";
import { Textarea } from "../ui/textarea";
2025-07-14 07:31:51 +00:00
export default function Navbar() {
const pathname = usePathname();
2025-07-14 11:55:57 +00:00
const [open, setOpen] = useState(false);
2025-07-14 07:31:51 +00:00
const [showProdukMenu, setShowProdukMenu] = useState(false);
2025-07-14 11:55:57 +00:00
const [showPriceMenu, setShowPriceMenu] = useState(false);
const [showServiceMenu, setShowServiceMenu] = useState(false);
const [showAboutMenu, setShowAboutMenu] = useState(false);
const [showConsumerMenu, setShowConsumerMenu] = useState(false);
2025-07-14 07:31:51 +00:00
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
2025-07-14 11:55:57 +00:00
const [showProdukMenuMobile, setShowProdukMenuMobile] = useState(false); // fix here
const [openMobile, setOpenMobile] = useState(false);
const [showPriceMenuMobile, setShowPriceMenuMobile] = useState(false);
const [showServiceMenuMobile, setShowServiceMenuMobile] = useState(false);
const [showAboutMenuMobile, setShowAboutMenuMobile] = useState(false);
const [showConsumerMenuMobile, setShowConsumerMenuMobile] = useState(false);
2025-07-14 07:31:51 +00:00
const isActive = (path: string) =>
pathname === path || pathname.startsWith(path + "/");
useEffect(() => {
const handleClickOutside = () => {
setShowProdukMenu(false);
};
window.addEventListener("click", handleClickOutside);
return () => window.removeEventListener("click", handleClickOutside);
}, []);
const produkList = [
{
2026-01-18 17:01:09 +00:00
name: "JAECOO J7 SHS-P",
2025-07-14 07:31:51 +00:00
img: "/j7awd.png",
2026-01-18 17:01:09 +00:00
link: "/product/j7-shs-p",
2025-07-14 07:31:51 +00:00
},
{
2026-01-18 17:01:09 +00:00
name: "JAECOO J5 EV",
2025-07-14 07:31:51 +00:00
img: "/j7shs.png",
2026-01-18 17:01:09 +00:00
link: "/product/j5-ev",
2025-07-14 07:31:51 +00:00
},
{
2026-01-18 17:01:09 +00:00
name: "JAECOO J8 SHS-P ARDIS",
2025-07-14 07:31:51 +00:00
img: "/j8awd.png",
2026-01-18 17:01:09 +00:00
link: "/product/j8-shs-ardis",
2025-07-14 11:55:57 +00:00
},
];
const priceList = [
{
name: "INFORMASI HARGA",
link: "/price/price-information",
},
{
name: "PROMO",
link: "/price/promo",
},
];
const serviceList = [
{
name: "PROGRAM SERVICE",
link: "/service/program-service",
},
{
name: "AFTER SALES",
link: "/service/after-sales",
},
];
const aboutList = [
{
name: "PROFILE",
link: "/about/profile",
},
{
name: "SOCIAL MEDIA",
link: "/about/sosmed",
},
{
name: "GALERY",
link: "/about/galery",
},
];
const consumerList = [
{
name: "AFTER SALES",
link: "/customer-service/after-sales",
},
{
name: "SALES",
link: "/customer-service/sales",
2025-07-14 07:31:51 +00:00
},
];
return (
<nav className="relative w-full flex items-center justify-between py-4 px-6 sm:px-10 bg-white z-50">
<div className="flex items-center gap-4">
<Link href="/" className="flex items-center space-x-2">
<Image
2026-02-02 08:08:56 +00:00
src="/jaecoonew.png"
2025-07-14 07:31:51 +00:00
alt="MAS JAECOO Logo"
width={300}
height={30}
className=" object-fill"
/>
</Link>
</div>
<button
className="sm:hidden absolute right-6 text-[#1F3D4A]"
onClick={() => setIsMobileMenuOpen((prev) => !prev)}
>
{isMobileMenuOpen ? (
<X className="w-6 h-6" />
) : (
<Menu className="w-6 h-6" />
)}
</button>
<ul className="hidden sm:flex mx-auto items-center gap-4 sm:gap-6 text-sm font-medium">
<li>
<Link href="/">
<Button
variant="ghost"
2025-07-14 11:55:57 +00:00
className={`hover:cursor-pointer rounded-full font-bold px-5 ${
2025-07-14 07:31:51 +00:00
isActive("/") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
2025-07-14 11:55:57 +00:00
HOMEPAGE
2025-07-14 07:31:51 +00:00
</Button>
</Link>
</li>
<li className="">
<Button
variant="ghost"
onClick={(e) => {
e.stopPropagation();
setShowProdukMenu((prev) => !prev);
}}
className={`flex items-center gap-1 font-bold text-sm focus:outline-none hover:cursor-pointer rounded-full px-5 py-2 ${
isActive("/product") || isActive("/produk")
? "bg-[#C2D8E2] text-[#1F3D4A]"
: ""
}`}
>
2025-07-14 11:55:57 +00:00
PRODUCTS <ChevronDown className="w-4 h-4" />
2025-07-14 07:31:51 +00:00
</Button>
<AnimatePresence>
{showProdukMenu && (
<motion.div
key="produk-dropdown"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 20 }}
transition={{ duration: 0.3 }}
className="absolute left-0 right-0 top-[calc(100%+1rem)] z-50 bg-white shadow-xl px-6 sm:px-10 py-6 rounded-xl w-full"
onClick={(e) => e.stopPropagation()}
>
<div className="max-w-screen-xl mx-auto w-full flex flex-col sm:flex-row items-center sm:items-start justify-between gap-y-10 sm:gap-y-0 sm:gap-x-6 text-center sm:text-left">
{produkList.map((car, i) => (
<motion.div
key={i}
initial={{ opacity: 0, y: 30 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 30 }}
transition={{ delay: 0.2 + i * 0.2, duration: 0.5 }}
className="flex flex-col items-center text-center w-full sm:w-auto"
>
<Image
src={car.img}
alt={car.name}
width={250}
height={150}
className="object-contain"
/>
<p className="font-bold mt-4 text-center">{car.name}</p>
<div className="flex flex-col sm:flex-row gap-2 mt-2 items-center">
2026-02-02 13:43:48 +00:00
<Link
href={`mailto:jaecookelapagading@gmail.com?subject=Test Drive ${car?.name} &body=Halo Jaecoo,%0D%0A%0D%0ASaya tertarik untuk melakukan test drive kendaraan ${car?.name}.%0D%0A%0D%0ANama:%0D%0ANomor HP:%0D%0ALokasi:%0D%0A%0D%0ATerima kasih.`}
>
<Button className="bg-[#1F6779] text-white h-[30px] md:h-[40px] rounded-full hover:cursor-pointer">
TEST DRIVE
</Button>
</Link>
2025-07-14 11:55:57 +00:00
<Link href={car.link} className="w-[200px]">
2025-07-14 07:31:51 +00:00
<Button
variant="outline"
className="rounded-full px-4 w-full hover:cursor-pointer hover:bg-amber-50"
>
2025-07-14 11:55:57 +00:00
EXPLORE
2025-07-14 07:31:51 +00:00
</Button>
</Link>
</div>
</motion.div>
))}
</div>
</motion.div>
)}
</AnimatePresence>
</li>
2025-07-14 11:55:57 +00:00
<li className="relative">
<Button
variant="ghost"
onClick={(e) => {
e.stopPropagation();
setShowPriceMenu((prev) => !prev);
}}
className={`flex items-center gap-1 font-bold text-sm focus:outline-none hover:cursor-pointer rounded-full px-5 py-2 ${
isActive("/price") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
HARGA <ChevronDown className="w-4 h-4" />
</Button>
2025-07-14 07:31:51 +00:00
2025-07-14 11:55:57 +00:00
<AnimatePresence>
{showPriceMenu && (
<motion.div
key="harga-dropdown"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 20 }}
transition={{ duration: 0.3 }}
className="absolute top-full mt-2 left-0 z-50 border-t-4 border-[#1F6779] bg-white shadow-xl py-4 w-[200px]"
onClick={(e) => e.stopPropagation()}
>
<div className="flex flex-col gap-2 px-4">
{priceList.map((item, i) => (
<motion.div
key={i}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 10 }}
transition={{ delay: 0.1 * i }}
>
<Link
href={item.link}
className="block w-full text-sm text-left px-3 py-2 rounded-md hover:bg-gray-100 hover:text-[#1F6779] font-medium"
>
{item.name}
</Link>
</motion.div>
))}
</div>
</motion.div>
)}
</AnimatePresence>
2025-07-14 07:31:51 +00:00
</li>
2025-07-14 11:55:57 +00:00
<li className="relative">
<Button
variant="ghost"
onClick={(e) => {
e.stopPropagation();
setShowServiceMenu((prev) => !prev);
}}
className={`flex items-center gap-1 font-bold text-sm focus:outline-none hover:cursor-pointer rounded-full px-5 py-2 ${
isActive("/service") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
SERVICES <ChevronDown className="w-4 h-4" />
</Button>
2025-07-14 07:31:51 +00:00
2025-07-14 11:55:57 +00:00
<AnimatePresence>
{showServiceMenu && (
<motion.div
key="harga-dropdown"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 20 }}
transition={{ duration: 0.3 }}
className="absolute top-full mt-2 left-0 z-50 border-t-4 border-[#1F6779] bg-white shadow-xl py-4 w-[200px]"
onClick={(e) => e.stopPropagation()}
>
<div className="flex flex-col gap-2 px-4">
{serviceList.map((item, i) => (
<motion.div
key={i}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 10 }}
transition={{ delay: 0.1 * i }}
>
<Link
href={item.link}
className="block w-full text-sm text-left px-3 py-2 rounded-md hover:bg-gray-100 hover:text-[#1F6779] font-medium"
>
{item.name}
</Link>
</motion.div>
))}
</div>
</motion.div>
)}
</AnimatePresence>
</li>
<li className="relative">
<Button
variant="ghost"
onClick={(e) => {
e.stopPropagation();
setShowAboutMenu((prev) => !prev);
}}
className={`flex items-center gap-1 font-bold text-sm focus:outline-none hover:cursor-pointer rounded-full px-5 py-2 ${
isActive("/about") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
TENTANG DEALER <ChevronDown className="w-4 h-4" />
</Button>
<AnimatePresence>
{showAboutMenu && (
<motion.div
key="harga-dropdown"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 20 }}
transition={{ duration: 0.3 }}
className="absolute top-full mt-2 left-0 z-50 border-t-4 border-[#1F6779] bg-white shadow-xl py-4 w-[200px]"
onClick={(e) => e.stopPropagation()}
>
<div className="flex flex-col gap-2 px-4">
{aboutList.map((item, i) => (
<motion.div
key={i}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 10 }}
transition={{ delay: 0.1 * i }}
>
<Link
href={item.link}
className="block w-full text-sm text-left px-3 py-2 rounded-md hover:bg-gray-100 hover:text-[#1F6779] font-medium"
>
{item.name}
</Link>
</motion.div>
))}
</div>
</motion.div>
)}
</AnimatePresence>
</li>
<li className="relative">
<Button
variant="ghost"
onClick={(e) => {
e.stopPropagation();
setShowConsumerMenu((prev) => !prev);
}}
className={`flex items-center gap-1 font-bold text-sm focus:outline-none hover:cursor-pointer rounded-full px-5 py-2 ${
isActive("/customer-service") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
LAYANAN KONSUMEN <ChevronDown className="w-4 h-4" />
</Button>
<AnimatePresence>
{showConsumerMenu && (
<motion.div
key="harga-dropdown"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 20 }}
transition={{ duration: 0.3 }}
className="absolute top-full mt-2 left-0 z-50 border-t-4 border-[#1F6779] bg-white shadow-xl py-4 w-[200px]"
onClick={(e) => e.stopPropagation()}
>
<div className="flex flex-col gap-2 px-4">
{consumerList.map((item, i) => (
<motion.div
key={i}
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 10 }}
transition={{ delay: 0.1 * i }}
>
<Link
href={item.link}
className="block w-full text-sm text-left px-3 py-2 rounded-md hover:bg-gray-100 hover:text-[#1F6779] font-medium"
>
{item.name}
</Link>
</motion.div>
))}
</div>
</motion.div>
)}
</AnimatePresence>
2025-07-14 07:31:51 +00:00
</li>
</ul>
<div className="hidden sm:block">
<Link href="/auth">
<Button className="bg-[#1F6779]">
<Lock className="w-3 h-3 mr-1" />
Login
</Button>
</Link>
</div>
{isMobileMenuOpen && (
2025-07-14 11:55:57 +00:00
<div className="absolute top-full left-0 right-0 bg-white px-6 py-4 shadow-md flex flex-col gap-4 text-sm font-bold sm:hidden z-40">
2025-07-14 07:31:51 +00:00
<Link href="/" onClick={() => setIsMobileMenuOpen(false)}>
<Button
variant="ghost"
className={`w-full justify-start ${
isActive("/") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
2025-07-14 11:55:57 +00:00
HOMEPAGE
2025-07-14 07:31:51 +00:00
</Button>
</Link>
2025-07-14 11:55:57 +00:00
<div className="block lg:hidden w-full">
2025-07-14 07:31:51 +00:00
<Button
variant="ghost"
2025-07-14 11:55:57 +00:00
onClick={() => setShowProdukMenuMobile((prev) => !prev)} // ← FIX
className={`w-full text-left flex items-center justify-start gap-1 font-bold text-sm focus:outline-none rounded-full px-5 py-2 ${
2025-07-14 07:31:51 +00:00
isActive("/product") || isActive("/produk")
? "bg-[#C2D8E2] text-[#1F3D4A]"
: ""
}`}
>
2025-07-14 11:55:57 +00:00
PRODUCTS <ChevronDown className="w-4 h-4" />
2025-07-14 07:31:51 +00:00
</Button>
2025-07-14 11:55:57 +00:00
{showProdukMenuMobile && (
<div className="w-full mt-2 bg-white shadow px-4 py-4 rounded-xl">
<div className="flex flex-col gap-6">
{produkList.map((car, i) => (
<div
key={i}
className="flex flex-col items-center text-center"
>
<Image
src={car.img}
alt={car.name}
width={250}
height={150}
className="object-contain"
/>
<p className="font-bold mt-4">{car.name}</p>
<div className="flex flex-col gap-2 mt-2 w-full items-center">
<Dialog open={openMobile} onOpenChange={setOpenMobile}>
<DialogTrigger asChild>
<Button className="bg-[#1F6779] text-white h-[40px] w-full rounded-full hover:cursor-pointer">
TEST DRIVE
</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[1400px] h-[600px]">
<div className="flex items-center gap-4">
<Image
src="/masjaecoonav.png"
alt="MAS JAECOO Logo"
width={300}
height={30}
className=" object-fill"
/>
</div>
<DialogHeader>
<DialogTitle className="text-2xl text-center mb-4 font-bold">
FORM TEST DRIVE
</DialogTitle>
</DialogHeader>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4 ">
<Input placeholder="Nama" />
<Input placeholder="Email" />
<Input placeholder="Mobile Number" />
<Input placeholder="Location" />
</div>
<div className="mt-3 ">
<Textarea placeholder="Full Message" rows={4} />
</div>
<div className="mt-6 text-left">
<Button
onClick={() => setOpen(false)}
className="bg-[#1F6779] text-white rounded-full"
>
SEND INQUIRY
</Button>
</div>
</DialogContent>
</Dialog>
<Link href={car.link} className="w-full">
<Button
variant="outline"
className="rounded-full px-4 w-full hover:cursor-pointer hover:bg-amber-50"
>
EXPLORE
</Button>
</Link>
</div>
</div>
))}
</div>
</div>
)}
</div>
<div className="block lg:hidden w-full">
2025-07-14 07:31:51 +00:00
<Button
variant="ghost"
2025-07-14 11:55:57 +00:00
onClick={() => setShowPriceMenuMobile((prev) => !prev)}
className={`w-full text-left flex items-center justify-start gap-1 font-bold text-sm focus:outline-none rounded-full px-5 py-2 ${
isActive("/price") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
HARGA <ChevronDown className="w-4 h-4" />
</Button>
{showPriceMenuMobile && (
<div className="w-full mt-2 bg-white shadow px-4 py-4 rounded-xl">
<div className="flex flex-col gap-4">
{priceList.map((item, i) => (
<Link
key={i}
href={item.link}
onClick={() => {
setIsMobileMenuOpen(false);
setShowPriceMenuMobile(false);
}}
className="block w-full"
>
<Button
variant="ghost"
className="w-full justify-start text-left text-sm font-medium hover:bg-gray-100 hover:text-[#1F6779]"
>
{item.name}
</Button>
</Link>
))}
</div>
</div>
)}
</div>
<div className="block lg:hidden w-full">
<Button
variant="ghost"
onClick={() => setShowServiceMenuMobile((prev) => !prev)}
className={`w-full text-left flex items-center justify-start gap-1 font-bold text-sm focus:outline-none rounded-full px-5 py-2 ${
2025-07-14 07:31:51 +00:00
isActive("/service") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
2025-07-14 11:55:57 +00:00
SERVICES <ChevronDown className="w-4 h-4" />
2025-07-14 07:31:51 +00:00
</Button>
2025-07-14 11:55:57 +00:00
{showServiceMenuMobile && (
<div className="w-full mt-2 bg-white shadow px-4 py-4 rounded-xl">
<div className="flex flex-col gap-4">
{serviceList.map((item, i) => (
<Link
key={i}
href={item.link}
onClick={() => {
setIsMobileMenuOpen(false);
setShowServiceMenuMobile(false);
}}
className="block w-full"
>
<Button
variant="ghost"
className="w-full justify-start text-left text-sm font-medium hover:bg-gray-100 hover:text-[#1F6779]"
>
{item.name}
</Button>
</Link>
))}
</div>
</div>
)}
</div>
<div className="block lg:hidden w-full">
2025-07-14 07:31:51 +00:00
<Button
variant="ghost"
2025-07-14 11:55:57 +00:00
onClick={() => setShowAboutMenuMobile((prev) => !prev)}
className={`w-full text-left flex items-center justify-start gap-1 font-bold text-sm focus:outline-none rounded-full px-5 py-2 ${
2025-07-14 07:31:51 +00:00
isActive("/about") ? "bg-[#C2D8E2] text-[#1F3D4A]" : ""
}`}
>
2025-07-14 11:55:57 +00:00
TENTANG DEALER JAECOO <ChevronDown className="w-4 h-4" />
2025-07-14 07:31:51 +00:00
</Button>
2025-07-14 11:55:57 +00:00
{showAboutMenuMobile && (
<div className="w-full mt-2 bg-white shadow px-4 py-4 rounded-xl">
<div className="flex flex-col gap-4">
{aboutList.map((item, i) => (
<Link
key={i}
href={item.link}
onClick={() => {
setIsMobileMenuOpen(false);
setShowAboutMenuMobile(false);
}}
className="block w-full"
>
<Button
variant="ghost"
className="w-full justify-start text-left text-sm font-medium hover:bg-gray-100 hover:text-[#1F6779]"
>
{item.name}
</Button>
</Link>
))}
</div>
</div>
)}
</div>
<div className="block lg:hidden w-full">
<Button
variant="ghost"
onClick={() => setShowConsumerMenuMobile((prev) => !prev)}
className={`w-full text-left flex items-center justify-start gap-1 font-bold text-sm focus:outline-none rounded-full px-5 py-2 ${
isActive("/customer-service")
? "bg-[#C2D8E2] text-[#1F3D4A]"
: ""
}`}
>
LAYANAN KONSUMEN <ChevronDown className="w-4 h-4" />
</Button>
{showConsumerMenuMobile && (
<div className="w-full mt-2 bg-white shadow px-4 py-4 rounded-xl">
<div className="flex flex-col gap-4">
{consumerList.map((item, i) => (
<Link
key={i}
href={item.link}
onClick={() => {
setIsMobileMenuOpen(false);
setShowConsumerMenuMobile(false);
}}
className="block w-full"
>
<Button
variant="ghost"
className="w-full justify-start text-left text-sm font-medium hover:bg-gray-100 hover:text-[#1F6779]"
>
{item.name}
</Button>
</Link>
))}
</div>
</div>
)}
</div>
2025-07-14 07:31:51 +00:00
<Link href="/auth" onClick={() => setIsMobileMenuOpen(false)}>
<Button className="bg-[#1F6779] w-full justify-start">
<Lock className="w-3 h-3 mr-1" />
Login
</Button>
</Link>
</div>
)}
</nav>
);
}