175 lines
6.4 KiB
TypeScript
175 lines
6.4 KiB
TypeScript
import { useEffect, useRef, useState } from "react"
|
|
import { AnimatePresence, motion } from "motion/react"
|
|
import { Bot, Clock, Database, Handshake, Scale, TrendingUp, UserRound, type LucideIcon } from "lucide-react"
|
|
|
|
import { Section } from "@/components/ui/section"
|
|
import { SectionHeading } from "@/components/ui/section-heading"
|
|
import { Typography } from "@/components/ui/typography"
|
|
import { useFadeUp } from "@/lib/motion"
|
|
|
|
/** 기존 방식 ↔ 도입 후 토글 비교 — 화면 진입 시 자동으로 오가고, 누르면 잠시 수동(8초 후 자동 재개). */
|
|
export function Comparison() {
|
|
const fadeUp = useFadeUp()
|
|
const toggleFadeUp = useFadeUp(0.1)
|
|
const [mode, setMode] = useState<Mode>("before")
|
|
// 사용자가 토글을 누르면 잠시 자동 전환 중단, 8초 무조작 시 재개
|
|
const [locked, setLocked] = useState(false)
|
|
const [inView, setInView] = useState(false)
|
|
const sectionRef = useRef<HTMLDivElement>(null)
|
|
const lockTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
|
|
const selectMode = (key: Mode) => {
|
|
setMode(key)
|
|
setLocked(true)
|
|
if (lockTimerRef.current) clearTimeout(lockTimerRef.current)
|
|
lockTimerRef.current = setTimeout(() => setLocked(false), 8000)
|
|
}
|
|
|
|
useEffect(() => {
|
|
const el = sectionRef.current
|
|
if (!el) return
|
|
const observer = new IntersectionObserver(([entry]) => setInView(entry.isIntersecting), { threshold: 0.35 })
|
|
observer.observe(el)
|
|
return () => {
|
|
observer.disconnect()
|
|
if (lockTimerRef.current) clearTimeout(lockTimerRef.current)
|
|
}
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
if (!inView || locked) return
|
|
const timer = setInterval(() => setMode((m) => (m === "before" ? "after" : "before")), 3000)
|
|
return () => clearInterval(timer)
|
|
}, [inView, locked])
|
|
|
|
return (
|
|
<Section id="comparison">
|
|
<motion.div {...fadeUp} className="mb-12">
|
|
<SectionHeading
|
|
align="center"
|
|
eyebrow="WHY NEGOTIUM"
|
|
title="협상 방식을 바꾸면, 무엇이 달라질까요"
|
|
description="기존 가격 협상의 문제는 사람이 아니라 구조입니다."
|
|
descriptionClassName="mt-4 text-[17px] max-w-2xl"
|
|
/>
|
|
</motion.div>
|
|
|
|
{/* 모드 토글 — 이용 가이드 탭과 같은 세그먼트 문법 */}
|
|
<motion.div {...toggleFadeUp} className="flex justify-center mb-14">
|
|
<div className="p-1 bg-fill rounded-[14px] inline-flex gap-1">
|
|
{MODES.map((m) => (
|
|
<button
|
|
key={m.key}
|
|
onClick={() => selectMode(m.key)}
|
|
className={`px-5 py-2.5 rounded-[10px] text-xs sm:text-sm font-bold transition-all flex items-center gap-2 cursor-pointer ${
|
|
mode === m.key ? "bg-white text-primary shadow-sm" : "text-ink-soft hover:text-ink"
|
|
}`}
|
|
>
|
|
{m.key === "after" && <Bot className="w-4 h-4" />}
|
|
<span>{m.label}</span>
|
|
</button>
|
|
))}
|
|
</div>
|
|
</motion.div>
|
|
|
|
<div ref={sectionRef} className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
{ITEMS.map((item, idx) => (
|
|
<CompareCard key={item.label} item={item} mode={mode} index={idx} />
|
|
))}
|
|
</div>
|
|
</Section>
|
|
)
|
|
}
|
|
|
|
type Mode = "before" | "after"
|
|
|
|
const MODES: { key: Mode; label: string }[] = [
|
|
{ key: "before", label: "기존 방식" },
|
|
{ key: "after", label: "negotium 도입 후" },
|
|
]
|
|
|
|
type CompareItem = { label: string; icon: LucideIcon; before: string; after: string }
|
|
|
|
function CompareCard({ item, mode, index }: { item: CompareItem; mode: Mode; index: number }) {
|
|
const fadeUp = useFadeUp(0.06 * (index + 1))
|
|
const active = mode === "after"
|
|
|
|
return (
|
|
<motion.div
|
|
{...fadeUp}
|
|
className={`p-7 rounded-[28px] flex flex-col gap-5 transition-colors duration-500 ${
|
|
active ? "bg-primary-soft/60" : "bg-surface"
|
|
}`}
|
|
>
|
|
<div className="flex items-center justify-between">
|
|
<div
|
|
className={`w-11 h-11 rounded-2xl flex items-center justify-center transition-colors duration-500 ${
|
|
active ? "bg-primary/10 text-primary" : "bg-ink-muted/10 text-ink-muted"
|
|
}`}
|
|
>
|
|
<item.icon className="w-5 h-5" />
|
|
</div>
|
|
<Typography variant="micro" className={active ? "text-primary" : ""}>
|
|
{item.label}
|
|
</Typography>
|
|
</div>
|
|
|
|
{/* 전환 시 레이아웃 점프 방지용 최소 높이 */}
|
|
<div className="min-h-[72px]">
|
|
<AnimatePresence mode="wait">
|
|
<motion.div
|
|
key={mode}
|
|
initial={{ opacity: 0, y: 10 }}
|
|
animate={{ opacity: 1, y: 0 }}
|
|
exit={{ opacity: 0, y: -8 }}
|
|
transition={{ duration: 0.28, delay: 0.05 * index }}
|
|
>
|
|
<Typography variant="small" className={active ? "text-ink font-semibold" : "text-ink-muted"}>
|
|
{active ? item.after : item.before}
|
|
</Typography>
|
|
</motion.div>
|
|
</AnimatePresence>
|
|
</div>
|
|
</motion.div>
|
|
)
|
|
}
|
|
|
|
const ITEMS: CompareItem[] = [
|
|
{
|
|
label: "거래 시간",
|
|
icon: Clock,
|
|
before: "일일 거래의 한계 — 사람의 인력과 시간만큼만 협상합니다.",
|
|
after: "24시간 연중무휴, 전 품목·전 공급사와 동시에 협상합니다.",
|
|
},
|
|
{
|
|
label: "협상 성과",
|
|
icon: TrendingUp,
|
|
before: "담당자의 역량·감정·컨디션에 따라 성과가 흔들립니다.",
|
|
after: "전략 강화 학습으로 기준선이 상승하고, 점진적으로 개선됩니다.",
|
|
},
|
|
{
|
|
label: "노하우",
|
|
icon: Database,
|
|
before: "잘 깎는 노하우가 개인의 머릿속에만 남습니다.",
|
|
after: "모든 협상이 데이터로 축적되어 다음 전략에 재활용됩니다.",
|
|
},
|
|
{
|
|
label: "사람",
|
|
icon: UserRound,
|
|
before: "반복 흥정과 감정 노동에 지쳐 고급 인력이 이탈합니다.",
|
|
after: "감정 소모는 봇이 맡고, 사람은 전략 업무와 대형 거래에 집중합니다.",
|
|
},
|
|
{
|
|
label: "파트너 관계",
|
|
icon: Handshake,
|
|
before: "감정 과열과 실랑이로 장기 파트너십이 흔들립니다.",
|
|
after: "악역은 봇이 — 압박 없는 상시 협상으로 관계가 개선됩니다.",
|
|
},
|
|
{
|
|
label: "의사 결정",
|
|
icon: Scale,
|
|
before: "개인 편향과 컴플라이언스 리스크에 노출됩니다.",
|
|
after: "객관적·데이터 기반의 투명한 프로세스로 기록됩니다.",
|
|
},
|
|
]
|