- 반응형: 최소 폭 1350→1024px, max-[1350px]/max-[1180px] 2단계 축소 - 사이드바 350→310→280, 우측 메뉴 360→320→280, 채팅 거터 140/126→80/72→48/40 (헤더 패딩 동기) - 가격·할인율 입력 min-w 480→420→320, 가운데 버튼 패딩·최소폭 축소, 상품목록 버튼 1180px 미만 아이콘만 - 상품 이미지 220→200, 사이드바 정보 행 값 영역 고정 150px → flex-1 - 리드타임: formatLeadTime 헬퍼 신설 — 좌측 상품정보·협상 결과 요약 카드에 "일" 접미 표시 - 인디케이터: init 의 session_status 를 스토어에 적재, 협상중(IN_PROGRESS) 세션에서만 표시 - 사이드바 정보 영역 의미 없는 가로 스크롤 제거 (shrink 금지 컬럼 + overflow-x 자동 계산이 원인) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
116 lines
5.0 KiB
TypeScript
116 lines
5.0 KiB
TypeScript
import { useNavigate } from 'react-router'
|
|
import { List } from 'lucide-react'
|
|
import { cn } from '@/lib'
|
|
import { useChatStore } from '@/features/chat/stores/useChatStore'
|
|
import { Percent, Price } from '@/features/chat/components/userInputs'
|
|
import { GO_TO_LIST_TEXT } from '@/features/chat/lib/userButtonConfig'
|
|
import type { UserButtonConfig } from '@/features/chat/types'
|
|
|
|
// max-[1180px]: 채팅 폭이 좁아지면 버튼 패딩·최소폭 축소, 상품목록은 아이콘만 남긴다
|
|
const style = {
|
|
goToList:
|
|
'flex w-[159px] max-[1180px]:w-[48px] h-[48px] bg-neutral-40 hover:brightness-[0.97] rounded-[999px] items-center justify-center title-2 text-neutral-80 cursor-pointer gap-2 max-[1180px]:gap-0 transition-all ease-out hover:scale-[1.01]',
|
|
black:
|
|
'flex min-w-[120px] px-[32px] max-[1180px]:min-w-[100px] max-[1180px]:px-[20px] h-[48px] bg-primary hover:brightness-[0.97] rounded-[999px] items-center justify-center title-2 text-primary-foreground cursor-pointer whitespace-nowrap transition-all duration-200 ease-out hover:scale-[1.01]',
|
|
gray: 'flex min-w-[120px] px-[32px] max-[1180px]:min-w-[100px] max-[1180px]:px-[20px] h-[48px] bg-neutral-60 rounded-[999px] items-center justify-center title-2 text-neutral-00 cursor-pointer whitespace-nowrap transition-all ease-out hover:scale-[1.01]',
|
|
white:
|
|
'flex min-w-[120px] px-[32px] max-[1180px]:min-w-[100px] max-[1180px]:px-[20px] h-[48px] bg-neutral-00 rounded-[999px] items-center justify-center title-2 text-neutral-80 border border-neutral-80 cursor-pointer whitespace-nowrap transition-all ease-out hover:scale-[1.01]',
|
|
}
|
|
|
|
export function UserButton({ type, text, textList, priceErrorMessage }: UserButtonConfig) {
|
|
if (type === '') return null
|
|
|
|
return (
|
|
// pr-[16px]: 채팅 스크롤 영역(ChatMessage 바깥 pr-[16px])과 오른쪽 끝 정렬
|
|
<div className="flex w-full pb-[52px] pr-[16px]">
|
|
<div className="grid grid-cols-[1fr_auto_1fr] items-center w-full">
|
|
<div />
|
|
<div className="flex justify-center">
|
|
{type === 'one-black' && <OneBlack text={text || '확인'} />}
|
|
{type === 'one-gray' && <OneGray text={text || '확인'} />}
|
|
{type === 'black-white' && <BlackWhite textList={[textList?.[0] || '예', textList?.[1] || '아니오']} />}
|
|
{type === 'percent' && <Percent />}
|
|
{type === 'three-black' && (
|
|
<ThreeBlack textList={[textList?.[0] || '협력사배송', textList?.[1] || '지정택배배송', textList?.[2] || '픽업배송']} />
|
|
)}
|
|
{type === 'price' && <Price priceErrorMessage={priceErrorMessage} />}
|
|
{type === 'loading' && <LoadingDots />}
|
|
</div>
|
|
<div className="flex justify-end">
|
|
<GoToList />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
// agent 응답 대기 중(협상 중) 버튼 자리에 표시하는 "..." 점 애니메이션. 비활성(클릭 불가).
|
|
function LoadingDots() {
|
|
return (
|
|
<div className={cn(style.black, 'cursor-default pointer-events-none')} aria-label="협상 중" role="status">
|
|
<span className="flex gap-[6px]">
|
|
<span className="size-[8px] rounded-full bg-primary-foreground animate-bounce [animation-delay:-0.3s]" />
|
|
<span className="size-[8px] rounded-full bg-primary-foreground animate-bounce [animation-delay:-0.15s]" />
|
|
<span className="size-[8px] rounded-full bg-primary-foreground animate-bounce" />
|
|
</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function GoToList() {
|
|
const navigate = useNavigate()
|
|
return (
|
|
<button className={style.goToList} onClick={() => navigate('/list')} aria-label="상품 목록으로 이동" title="상품 목록">
|
|
<List size={24} className="shrink-0" />
|
|
<span className="max-[1180px]:hidden">상품 목록</span>
|
|
</button>
|
|
)
|
|
}
|
|
|
|
function OneBlack({ text }: { text: string }) {
|
|
const navigate = useNavigate()
|
|
const sendMessage = useChatStore((s) => s.sendMessage)
|
|
const onClick = () => (text === GO_TO_LIST_TEXT ? navigate('/list') : sendMessage(text))
|
|
return (
|
|
<button className={style.black} onClick={onClick}>
|
|
{text}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
function OneGray({ text }: { text: string }) {
|
|
const sendMessage = useChatStore((s) => s.sendMessage)
|
|
return (
|
|
<button className={style.gray} onClick={() => sendMessage(text)}>
|
|
{text}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
function ThreeBlack({ textList }: { textList: [string, string, string] }) {
|
|
const sendMessage = useChatStore((s) => s.sendMessage)
|
|
return (
|
|
<div className="flex gap-3">
|
|
{textList.map((t) => (
|
|
<button key={t} className={style.black} onClick={() => sendMessage(t)}>
|
|
{t}
|
|
</button>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function BlackWhite({ textList }: { textList: [string, string] }) {
|
|
const sendMessage = useChatStore((s) => s.sendMessage)
|
|
return (
|
|
<div className="flex gap-3">
|
|
<button className={style.black} onClick={() => sendMessage(textList[0])}>
|
|
{textList[0]}
|
|
</button>
|
|
<button className={style.white} onClick={() => sendMessage(textList[1])}>
|
|
{textList[1]}
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|