"use client"
import { AnimatePresence, motion } from "motion/react"
import { useEffect, useState } from "react"
import { ArrowRightIcon, BedDoubleIcon, ChevronLeftIcon, ChevronRightIcon, MapPinIcon, RulerIcon, SearchIcon } from "lucide-react"
import { cn } from "@/lib/utils"
import type { TemplateProps } from "../../lib/types"
import { DemoForm } from "../shared/demo-form"
import { TField, TSelect } from "../shared/fields"
import { TImage } from "../shared/media"
import { ParallaxImage, Reveal, RevealWords, ease, useScrollNav } from "../shared/motion"
import { TemplateShell } from "../shared/shell"
import { immobilien, type ImmobilienData } from "./definition"
import { fonts } from "./fonts"
const em = "italic text-t-accent"
const container = "mx-auto w-full max-w-[1400px] px-5 md:px-10"
const heading = "font-t-display font-normal tracking-[-0.01em]"
const label = "text-[11px] uppercase tracking-[0.3em]"
const TYPES = ["Alle", "Kaufen", "Mieten"]
const ALL_PLACES = "Alle Lagen"
function Eyebrow({ children }: { children: string }) {
return (
{children}
)
}
export function ImmobilienTemplate({ content }: TemplateProps) {
const { brand, hero, slides, listings, about, projects, valuation, testimonial } = content.data
const show = (key: string) => !content.hidden.includes(key)
const [type, setType] = useState("Alle")
const [place, setPlace] = useState(ALL_PLACES)
const places = [ALL_PLACES, ...new Set(listings.items.map((item) => item.location))]
const links = [
{ href: "#objekte", label: "Objekte", visible: show("listings") },
{ href: "#ueber-uns", label: "Über uns", visible: show("about") },
{ href: "#referenzen", label: "Referenzen", visible: show("projects") },
{ href: "#bewertung", label: "Wertermittlung", visible: true },
].filter((link) => link.visible)
return (
{show("listings") && (
{TYPES.map((option) => (
))}
setPlace(event.target.value)} options={places} />
Objekte anzeigen
)}
{show("listings") && setPlace(ALL_PLACES)} />}
{show("about") && (
{about.eyebrow}
{about.text}
{about.facts.map((fact, i) => (
0 && "border-l border-t-fg/15 pl-5")}>
- {fact.value}
- {fact.label}
))}
)}
{show("projects") && }
{valuation.eyebrow}
{valuation.text}
Vielen Dank.
Wir melden uns innerhalb von 48 Stunden mit Ihrer Einschätzung.
}
>
{show("testimonial") && (
)}
)
}
function Nav({ brand, links }: { brand: ImmobilienData["brand"]; links: { href: string; label: string }[] }) {
const { scrolled, hidden } = useScrollNav()
return (
)
}
function HeroSlider({ hero, slides }: { hero: ImmobilienData["hero"]; slides: ImmobilienData["slides"]["items"] }) {
const [index, setIndex] = useState(0)
const count = Math.max(slides.length, 1)
const current = index % count
const slide = slides[current]
useEffect(() => {
if (count < 2) return
const timer = setTimeout(() => setIndex((i) => (i + 1) % count), 6500)
return () => clearTimeout(timer)
}, [index, count])
return (
{hero.eyebrow}
{hero.cta}
{slide && (
{slide.location}
{slide.title}
)}
{slides.map((_, i) => (
{i === current && }
{i < current && }
))}
)
}
function Listings({ listings, type, place, onType, onReset }: {
listings: ImmobilienData["listings"]
type: string
place: string
onType: (type: string) => void
onReset: () => void
}) {
const visible = listings.items.filter((item) => (type === "Alle" || item.type === type) && (place === ALL_PLACES || item.location === place))
return (
{listings.eyebrow}
{TYPES.map((option) => (
))}
{visible.map((item) => (
{item.title}
{item.sqm} m²
{item.rooms} Zimmer
{item.location}
))}
{visible.length === 0 && (
Aktuell keine passenden Objekte.{" "}
)}
)
}
function ProjectIndex({ projects }: { projects: ImmobilienData["projects"] }) {
const [active, setActive] = useState(0)
const current = projects.items[Math.min(active, projects.items.length - 1)]
return (
)
}