This commit is contained in:
1 parent
88edcfed63
commit
5d0fbbcf6a
30 files changed
+529
-52
No files matched your search
@@ -6,6 +6,7 @@ import type { ChatMessage as ChatMessageType } from '@/features/chat/types'
|
||||
import { renderEmphasis } from '@/features/chat/lib/emphasis'
|
||||
import { Indicator } from '@/features/chat/components/templates/Indicator'
|
||||
import { Summary } from '@/features/chat/components/templates/Summary'
|
||||
import { ExtraInfoForm } from '@/features/chat/components/templates/ExtraInfoForm'
|
||||
import { BidSummary } from '@/features/chat/components/templates/BidSummary'
|
||||
import { RejectRSP } from '@/features/chat/components/templates/RejectRSP'
|
||||
import { RejectCM } from '@/features/chat/components/templates/RejectCM'
|
||||
@@ -108,7 +109,12 @@ const BotMessage = memo(function BotMessage({ message }: { message: ChatMessageT
|
||||
{showIndicator && message.bot_chat_type === 'indicator' && message.indicator_value != null && (
|
||||
<Indicator number={message.indicator_value} />
|
||||
)}
|
||||
{message.bot_chat_type === 'summaryRSP' && message.summary && <Summary data={message.summary} />}
|
||||
{message.bot_chat_type === 'summaryRSP' && message.summary && (
|
||||
<>
|
||||
<Summary data={message.summary} />
|
||||
<ExtraInfoForm />
|
||||
</>
|
||||
)}
|
||||
{message.bot_chat_type === 'summaryCM' && message.summary && (
|
||||
<BidSummary
|
||||
itemName={message.summary.item_name}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { CheckCircle2 } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { useMeQuery, useSaveExtraInfoMutation, getApiErrorMessage } from '@/apis'
|
||||
import type { SessionField } from '@/apis/auth/auth.type'
|
||||
import { useChatStore } from '@/features/chat/stores/useChatStore'
|
||||
import { useChatInitStore } from '@/features/chat/stores/useChatInitStore'
|
||||
|
||||
// 협상 타결(Summary) 직후 부가정보 입력 폼. 필드 정의(session_fields)는 회사 설정(/me)에서 온다.
|
||||
// 저장하면 sessions.custom 에 기록되고 negodata 견적상세에 표시된다. 정의가 없으면 렌더하지 않는다.
|
||||
export function ExtraInfoForm() {
|
||||
const sessionId = useChatStore((s) => s.sessionId)
|
||||
const { data: user } = useMeQuery()
|
||||
const fields: SessionField[] = user?.sessionFields ?? []
|
||||
const save = useSaveExtraInfoMutation()
|
||||
const existing = useChatInitStore((s) => s.custom) // 기존 입력값(재진입 프리필)
|
||||
|
||||
const [values, setValues] = useState<Record<string, unknown>>({})
|
||||
const [inited, setInited] = useState(false)
|
||||
const [saved, setSaved] = useState(false)
|
||||
|
||||
// fields(회사 설정)와 기존값(sessions.custom)이 준비된 첫 시점에 프리필 — 이후 사용자 편집은 보존.
|
||||
useEffect(() => {
|
||||
if (inited || fields.length === 0) return
|
||||
const init: Record<string, unknown> = {}
|
||||
for (const f of fields) init[f.key] = existing?.[f.key] ?? (f.type === 'boolean' ? false : '')
|
||||
setValues(init)
|
||||
setInited(true)
|
||||
}, [inited, fields, existing])
|
||||
|
||||
if (fields.length === 0) return null
|
||||
|
||||
const set = (key: string, value: unknown) => setValues((v) => ({ ...v, [key]: value }))
|
||||
|
||||
const handleSave = () => {
|
||||
const custom: Record<string, unknown> = {}
|
||||
for (const f of fields) {
|
||||
const v = values[f.key]
|
||||
if (f.type === 'boolean') custom[f.key] = !!v
|
||||
else if (v !== '' && v != null) custom[f.key] = f.type === 'number' ? Number(v) : v
|
||||
}
|
||||
save.mutate(
|
||||
{ sessionId, request: { custom } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
setSaved(true)
|
||||
toast.success('부가정보가 저장되었습니다.')
|
||||
},
|
||||
onError: (error) => toast.error(getApiErrorMessage(error, '부가정보 저장에 실패했습니다.')),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full rounded-2xl border border-border bg-white p-5 shadow-sm">
|
||||
<div className="mb-3 flex items-center gap-2">
|
||||
<CheckCircle2 className="size-5 text-brand-600" />
|
||||
<h3 className="text-sm font-bold text-neutral-90">부가정보 입력</h3>
|
||||
</div>
|
||||
<p className="text-sm leading-relaxed text-neutral-70 break-keep">
|
||||
협상이 완료되었습니다. 아래 정보를 입력해 주세요. (저장 후에도 세션 목록에서 수정할 수 있습니다.)
|
||||
</p>
|
||||
|
||||
<div className="mt-4 space-y-4">
|
||||
{fields.map((f) => (
|
||||
<div key={f.key} className="space-y-1.5">
|
||||
<label className="block text-sm font-semibold text-neutral-80">{f.label}</label>
|
||||
{f.type === 'boolean' ? (
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={!!values[f.key]}
|
||||
onClick={() => set(f.key, !values[f.key])}
|
||||
disabled={saved}
|
||||
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors disabled:opacity-50 ${
|
||||
values[f.key] ? 'bg-brand-600' : 'bg-neutral-30'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`inline-block size-5 transform rounded-full bg-white shadow transition-transform ${
|
||||
values[f.key] ? 'translate-x-5' : 'translate-x-0.5'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
<input
|
||||
type={f.type === 'number' ? 'number' : 'text'}
|
||||
value={String(values[f.key] ?? '')}
|
||||
onChange={(e) => set(f.key, e.target.value)}
|
||||
disabled={saved}
|
||||
className="h-11 w-full rounded-xl border border-border bg-white px-3 text-sm outline-none focus:border-brand-600 focus:ring-1 focus:ring-brand-600 disabled:bg-neutral-10"
|
||||
placeholder={f.label}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSave}
|
||||
disabled={save.isPending || saved}
|
||||
className="mt-4 h-11 w-full rounded-xl bg-brand-600 text-sm font-bold text-white transition-colors hover:bg-brand-700 disabled:opacity-50"
|
||||
>
|
||||
{saved ? '저장 완료' : save.isPending ? '저장 중…' : '부가정보 저장'}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -29,6 +29,7 @@ const initialState: ChatInitData = {
|
||||
item_spec: '',
|
||||
quotation_memo: '',
|
||||
quotation_end_time: '',
|
||||
custom: {},
|
||||
}
|
||||
|
||||
export const useChatInitStore = create<ChatInitStore>((set) => ({
|
||||
|
||||
@@ -81,4 +81,5 @@ export type ChatInitData = {
|
||||
item_spec: string
|
||||
quotation_memo: string
|
||||
quotation_end_time: string
|
||||
custom: Record<string, unknown> // 협상완료 부가정보 기존 입력값(프리필용)
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import { useState } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
import { Modal } from '@/components'
|
||||
import { useMeQuery } from '@/apis'
|
||||
import type { SessionField } from '@/apis/auth/auth.type'
|
||||
import type { ListItem } from '../types'
|
||||
|
||||
export interface ExtraInfoPopupProps {
|
||||
target: ListItem
|
||||
onClose: () => void
|
||||
/** 부가정보 저장 (custom = {key: value}) */
|
||||
onSubmit: (custom: Record<string, unknown>) => void
|
||||
}
|
||||
|
||||
// 협상완료 부가정보 입력 팝업. 필드 정의(session_fields)는 회사 설정(/me)에서 오고, 기존 입력값(target.custom)으로 프리필.
|
||||
export function ExtraInfoPopup({ target, onClose, onSubmit }: ExtraInfoPopupProps) {
|
||||
const { data: user } = useMeQuery()
|
||||
const fields: SessionField[] = user?.sessionFields ?? []
|
||||
|
||||
const [values, setValues] = useState<Record<string, unknown>>(() => {
|
||||
const init: Record<string, unknown> = {}
|
||||
for (const f of fields) init[f.key] = target.custom?.[f.key] ?? (f.type === 'boolean' ? false : '')
|
||||
return init
|
||||
})
|
||||
|
||||
const set = (key: string, value: unknown) => setValues((v) => ({ ...v, [key]: value }))
|
||||
|
||||
const handleSubmit = () => {
|
||||
// 빈 값은 제외하고 저장(부분 입력 허용)
|
||||
const out: Record<string, unknown> = {}
|
||||
for (const f of fields) {
|
||||
const v = values[f.key]
|
||||
if (f.type === 'boolean') out[f.key] = !!v
|
||||
else if (v !== '' && v != null) out[f.key] = f.type === 'number' ? Number(v) : v
|
||||
}
|
||||
onSubmit(out)
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal onClose={onClose}>
|
||||
<div className="w-full max-w-md overflow-hidden rounded-2xl border border-border bg-white shadow-xl animate-scale-in">
|
||||
<div className="flex items-center justify-between border-b border-border p-5">
|
||||
<div>
|
||||
<h3 className="text-base font-bold text-neutral-90">협상완료 부가정보</h3>
|
||||
<p className="mt-0.5 text-xs text-neutral-60">{target.qt_number} · {target.item_name}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label="닫기"
|
||||
className="flex size-8 items-center justify-center rounded-full text-neutral-60 hover:bg-neutral-10"
|
||||
>
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4 p-5">
|
||||
{fields.length === 0 ? (
|
||||
<p className="py-6 text-center text-sm text-neutral-60">입력할 부가정보 항목이 없습니다.</p>
|
||||
) : (
|
||||
fields.map((f) => (
|
||||
<div key={f.key} className="space-y-1.5">
|
||||
<label className="block text-sm font-semibold text-neutral-80">{f.label}</label>
|
||||
{f.type === 'boolean' ? (
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={!!values[f.key]}
|
||||
onClick={() => set(f.key, !values[f.key])}
|
||||
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${
|
||||
values[f.key] ? 'bg-brand-600' : 'bg-neutral-30'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`inline-block size-5 transform rounded-full bg-white shadow transition-transform ${
|
||||
values[f.key] ? 'translate-x-5' : 'translate-x-0.5'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
<input
|
||||
type={f.type === 'number' ? 'number' : 'text'}
|
||||
value={String(values[f.key] ?? '')}
|
||||
onChange={(e) => set(f.key, e.target.value)}
|
||||
className="h-11 w-full rounded-xl border border-border bg-white px-3 text-sm outline-none focus:border-brand-600 focus:ring-1 focus:ring-brand-600"
|
||||
placeholder={f.label}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 border-t border-border p-5">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="h-11 flex-1 rounded-xl border border-border text-sm font-bold text-neutral-70 hover:bg-neutral-10"
|
||||
>
|
||||
취소
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSubmit}
|
||||
disabled={fields.length === 0}
|
||||
className="h-11 flex-1 rounded-xl bg-brand-600 text-sm font-bold text-white hover:bg-brand-700 disabled:opacity-40"
|
||||
>
|
||||
저장
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -9,10 +9,11 @@ interface WorkspaceCardsProps {
|
||||
busyId?: string | null
|
||||
onEnter: (item: ListItem) => void
|
||||
onReject: (item: ListItem) => void
|
||||
onExtraInfo: (item: ListItem) => void
|
||||
}
|
||||
|
||||
// 모바일(lg 미만) 협상 목록: 테이블 대신 카드 스택.
|
||||
export function WorkspaceCards({ items, isLoading, busyId, onEnter, onReject }: WorkspaceCardsProps) {
|
||||
export function WorkspaceCards({ items, isLoading, busyId, onEnter, onReject, onExtraInfo }: WorkspaceCardsProps) {
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-16">
|
||||
@@ -27,7 +28,7 @@ export function WorkspaceCards({ items, isLoading, busyId, onEnter, onReject }:
|
||||
return (
|
||||
<div className="divide-y divide-border">
|
||||
{items.map((item) => (
|
||||
<Card key={item.session_id} item={item} busy={busyId === item.session_id} onEnter={onEnter} onReject={onReject} />
|
||||
<Card key={item.session_id} item={item} busy={busyId === item.session_id} onEnter={onEnter} onReject={onReject} onExtraInfo={onExtraInfo} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
@@ -38,25 +39,26 @@ function Card({
|
||||
busy,
|
||||
onEnter,
|
||||
onReject,
|
||||
onExtraInfo,
|
||||
}: {
|
||||
item: ListItem
|
||||
busy: boolean
|
||||
onEnter: (item: ListItem) => void
|
||||
onReject: (item: ListItem) => void
|
||||
onExtraInfo: (item: ListItem) => void
|
||||
}) {
|
||||
const meta = statusMeta(item.session_status)
|
||||
const canEnter = !['미참여', '협상거부'].includes(item.session_status)
|
||||
const canReject = ['협상생성', '협상중'].includes(item.session_status)
|
||||
const enterLabel = item.session_status === '협상완료' ? '결과 보기' : '협상 입장'
|
||||
const isDone = item.session_status === '협상완료'
|
||||
const enterLabel = isDone ? '결과 보기' : '협상 입장'
|
||||
const hasExtra = item.custom && Object.keys(item.custom).length > 0
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="rounded-md bg-neutral-20 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-70">
|
||||
{item.qt_type || '-'}
|
||||
</span>
|
||||
<span className="truncate font-mono text-[12px] font-semibold text-neutral-70">{item.qt_number || '-'}</span>
|
||||
</div>
|
||||
<p className="mt-1.5 truncate text-sm font-bold text-neutral-90">{item.item_name || '-'}</p>
|
||||
@@ -76,8 +78,17 @@ function Card({
|
||||
<span>마감 {formatKstDateTime(item.qt_end_time)}</span>
|
||||
</div>
|
||||
|
||||
{(canEnter || canReject) && (
|
||||
{(canEnter || canReject || isDone) && (
|
||||
<div className="mt-3 flex gap-2">
|
||||
{isDone && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onExtraInfo(item)}
|
||||
className="flex-1 rounded-lg border border-brand-600/40 py-2 text-xs font-bold text-brand-700 transition-all hover:bg-brand-50 active:scale-[0.98]"
|
||||
>
|
||||
{hasExtra ? '부가정보 수정' : '부가정보 입력'}
|
||||
</button>
|
||||
)}
|
||||
{canReject && (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -10,19 +10,19 @@ interface WorkspaceTableProps {
|
||||
busyId?: string | null
|
||||
onEnter: (item: ListItem) => void
|
||||
onReject: (item: ListItem) => void
|
||||
onExtraInfo: (item: ListItem) => void
|
||||
}
|
||||
|
||||
const HEAD = 'px-5 py-3.5 text-left text-[11px] font-bold uppercase tracking-wider text-neutral-60 whitespace-nowrap'
|
||||
const CELL = 'px-5 py-4 align-middle text-sm text-neutral-80'
|
||||
|
||||
export function WorkspaceTable({ items, isLoading, busyId, onEnter, onReject }: WorkspaceTableProps) {
|
||||
export function WorkspaceTable({ items, isLoading, busyId, onEnter, onReject, onExtraInfo }: WorkspaceTableProps) {
|
||||
return (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<table className="w-full min-w-[900px] border-collapse">
|
||||
<thead>
|
||||
<tr className="border-b border-border bg-table-header">
|
||||
<th className={HEAD}>견적번호</th>
|
||||
<th className={HEAD}>구분</th>
|
||||
<th className={HEAD}>상품</th>
|
||||
<th className={HEAD}>제조사</th>
|
||||
<th className={cn(HEAD, 'text-center')}>상태</th>
|
||||
@@ -41,7 +41,7 @@ export function WorkspaceTable({ items, isLoading, busyId, onEnter, onReject }:
|
||||
</StateRow>
|
||||
) : (
|
||||
items.map((item) => (
|
||||
<Row key={item.session_id} item={item} busy={busyId === item.session_id} onEnter={onEnter} onReject={onReject} />
|
||||
<Row key={item.session_id} item={item} busy={busyId === item.session_id} onEnter={onEnter} onReject={onReject} onExtraInfo={onExtraInfo} />
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
@@ -55,27 +55,26 @@ function Row({
|
||||
busy,
|
||||
onEnter,
|
||||
onReject,
|
||||
onExtraInfo,
|
||||
}: {
|
||||
item: ListItem
|
||||
busy: boolean
|
||||
onEnter: (item: ListItem) => void
|
||||
onReject: (item: ListItem) => void
|
||||
onExtraInfo: (item: ListItem) => void
|
||||
}) {
|
||||
const meta = statusMeta(item.session_status)
|
||||
const canEnter = !['미참여', '협상거부'].includes(item.session_status)
|
||||
const canReject = ['협상생성', '협상중'].includes(item.session_status)
|
||||
const enterLabel = item.session_status === '협상완료' ? '결과 보기' : '협상 입장'
|
||||
const isDone = item.session_status === '협상완료'
|
||||
const enterLabel = isDone ? '결과 보기' : '협상 입장'
|
||||
const hasExtra = item.custom && Object.keys(item.custom).length > 0
|
||||
|
||||
return (
|
||||
<tr className="border-b border-border/60 transition-colors last:border-0 hover:bg-table-hover/70">
|
||||
<td className={cn(CELL, 'font-mono text-[13px] font-semibold text-neutral-90 whitespace-nowrap')}>
|
||||
{item.qt_number || '-'}
|
||||
</td>
|
||||
<td className={cn(CELL, 'whitespace-nowrap')}>
|
||||
<span className="rounded-md bg-neutral-20 px-2 py-0.5 text-xs font-semibold text-neutral-70">
|
||||
{item.qt_type || '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td className={CELL}>
|
||||
<p className="font-semibold text-neutral-90">{item.item_name || '-'}</p>
|
||||
<p className="mt-0.5 text-xs text-neutral-60">
|
||||
@@ -93,6 +92,15 @@ function Row({
|
||||
<td className={cn(CELL, 'whitespace-nowrap text-neutral-70')}>{formatKstDateTime(item.qt_end_time)}</td>
|
||||
<td className={CELL}>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{isDone && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onExtraInfo(item)}
|
||||
className="rounded-lg border border-brand-600/40 px-3 py-1.5 text-xs font-bold text-brand-700 transition-all hover:bg-brand-50 active:scale-[0.98]"
|
||||
>
|
||||
{hasExtra ? '부가정보 수정' : '부가정보 입력'}
|
||||
</button>
|
||||
)}
|
||||
{canReject && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -124,7 +132,7 @@ function Row({
|
||||
function StateRow({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={7} className="py-20">
|
||||
<td colSpan={6} className="py-20">
|
||||
<div className="flex items-center justify-center">{children}</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router'
|
||||
import { useShallow } from 'zustand/react/shallow'
|
||||
import { Search } from 'lucide-react'
|
||||
import { getApiErrorMessage, useMeQuery, useParticipateMutation, useRejectMutation } from '@/apis'
|
||||
import { getApiErrorMessage, useMeQuery, useParticipateMutation, useRejectMutation, useSaveExtraInfoMutation } from '@/apis'
|
||||
import { cn, toast } from '@/lib'
|
||||
import { useList } from '@/features/list/hooks/useList'
|
||||
import { useListStore } from '@/features/list/stores/useListStore'
|
||||
@@ -12,6 +12,7 @@ import { WorkspaceTable } from '@/features/list/components/WorkspaceTable'
|
||||
import { WorkspaceCards } from '@/features/list/components/WorkspaceCards'
|
||||
import { Pagination } from '@/features/list/components/Pagination'
|
||||
import { RejectPopup } from '@/features/list/components/RejectPopup'
|
||||
import { ExtraInfoPopup } from '@/features/list/components/ExtraInfoPopup'
|
||||
import type { ListItem } from '@/features/list/types'
|
||||
|
||||
// 상태별 거부 불가 안내
|
||||
@@ -21,8 +22,6 @@ const REJECT_BLOCKED: Record<string, string> = {
|
||||
협상완료: '협상완료 상태인 협상은 거부할 수 없습니다.',
|
||||
}
|
||||
|
||||
const TYPE_OPTIONS = ['재견적', '재협상', '신규견적', '신규협상']
|
||||
|
||||
export function ListWorkspace() {
|
||||
const navigate = useNavigate()
|
||||
const { data: user } = useMeQuery()
|
||||
@@ -30,19 +29,19 @@ export function ListWorkspace() {
|
||||
const { items, isLoading, totalPages, currentPage, setCurrentPage } = useList()
|
||||
const participate = useParticipateMutation()
|
||||
const reject = useRejectMutation()
|
||||
const saveExtra = useSaveExtraInfoMutation()
|
||||
|
||||
const { selectedStatus, setStatus, selectedType, setType } = useListStore(
|
||||
const { selectedStatus, setStatus } = useListStore(
|
||||
useShallow((s) => ({
|
||||
selectedStatus: s.selectedStatus,
|
||||
setStatus: s.setStatus,
|
||||
selectedType: s.selectedType,
|
||||
setType: s.setType,
|
||||
})),
|
||||
)
|
||||
|
||||
const [search, setSearch] = useState('')
|
||||
const [enteringId, setEnteringId] = useState<string | null>(null)
|
||||
const [rejectTarget, setRejectTarget] = useState<ListItem | null>(null)
|
||||
const [extraTarget, setExtraTarget] = useState<ListItem | null>(null)
|
||||
|
||||
const handleEnter = (item: ListItem) => {
|
||||
setEnteringId(item.session_id)
|
||||
@@ -75,6 +74,17 @@ export function ListWorkspace() {
|
||||
)
|
||||
}
|
||||
|
||||
const handleExtraSubmit = (custom: Record<string, unknown>) => {
|
||||
if (!extraTarget) return
|
||||
saveExtra.mutate(
|
||||
{ sessionId: extraTarget.session_id, request: { custom } },
|
||||
{
|
||||
onSuccess: () => toast.success('부가정보가 저장되었습니다.'),
|
||||
onError: (error) => toast.error(getApiErrorMessage(error, '부가정보 저장에 실패했습니다.')),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-5">
|
||||
{/* 환영 배너 */}
|
||||
@@ -97,18 +107,6 @@ export function ListWorkspace() {
|
||||
<div className="flex flex-col gap-3 border-b border-border p-4 lg:flex-row lg:items-center lg:justify-between">
|
||||
<StatusTabs selected={selectedStatus} onSelect={setStatus} />
|
||||
<div className="flex w-full items-center gap-2 lg:w-auto">
|
||||
<select
|
||||
value={selectedType ?? ''}
|
||||
onChange={(e) => setType(e.target.value || null)}
|
||||
className="h-9 shrink-0 rounded-xl border border-border bg-white px-3 text-xs font-semibold text-neutral-80 outline-none transition-all focus:border-brand-600 focus:ring-1 focus:ring-brand-600"
|
||||
>
|
||||
<option value="">구분 전체</option>
|
||||
{TYPE_OPTIONS.map((t) => (
|
||||
<option key={t} value={t}>
|
||||
{t}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="relative flex-1 lg:flex-none">
|
||||
<Search className="pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-50" />
|
||||
<input
|
||||
@@ -132,6 +130,7 @@ export function ListWorkspace() {
|
||||
busyId={participate.isPending ? enteringId : null}
|
||||
onEnter={handleEnter}
|
||||
onReject={handleReject}
|
||||
onExtraInfo={setExtraTarget}
|
||||
/>
|
||||
</div>
|
||||
<div className="lg:hidden">
|
||||
@@ -141,6 +140,7 @@ export function ListWorkspace() {
|
||||
busyId={participate.isPending ? enteringId : null}
|
||||
onEnter={handleEnter}
|
||||
onReject={handleReject}
|
||||
onExtraInfo={setExtraTarget}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -152,6 +152,10 @@ export function ListWorkspace() {
|
||||
{rejectTarget && (
|
||||
<RejectPopup onClose={() => setRejectTarget(null)} onSubmit={handleRejectSubmit} />
|
||||
)}
|
||||
|
||||
{extraTarget && (
|
||||
<ExtraInfoPopup target={extraTarget} onClose={() => setExtraTarget(null)} onSubmit={handleExtraSubmit} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useSessionListQuery } from '@/apis'
|
||||
import { useListStore } from '@/features/list/stores/useListStore'
|
||||
import { deadlineToOrder, statusLabelToCode, toListItem, typeLabelToCode } from '@/features/list/lib/adapter'
|
||||
import { deadlineToOrder, statusLabelToCode, toListItem } from '@/features/list/lib/adapter'
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
|
||||
// 필터/정렬/페이지는 서버에 위임하고, 응답(정수 코드)을 화면용 라벨로 변환한다.
|
||||
export function useList() {
|
||||
const { selectedType, selectedStatus, selectedDeadline, currentPage, setCurrentPage } = useListStore()
|
||||
const { selectedStatus, selectedDeadline, currentPage, setCurrentPage } = useListStore()
|
||||
|
||||
const query = useSessionListQuery({
|
||||
status: selectedStatus ? statusLabelToCode(selectedStatus) : undefined,
|
||||
qt_type: selectedType ? typeLabelToCode(selectedType) : undefined,
|
||||
order: selectedDeadline ? deadlineToOrder(selectedDeadline) : undefined,
|
||||
page: currentPage,
|
||||
page_size: PAGE_SIZE,
|
||||
|
||||
@@ -37,5 +37,6 @@ export function toListItem(api: SessionListItem): ListItem {
|
||||
item_name: api.item_name,
|
||||
model_name: api.model_name,
|
||||
maker_name: api.maker_name,
|
||||
custom: api.custom ?? {},
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,5 @@ export type ListItem = {
|
||||
item_name: string
|
||||
model_name: string
|
||||
maker_name: string
|
||||
custom: Record<string, unknown> // 협상완료 부가정보(입력값). 미입력이면 {}
|
||||
}
|
||||
Reference in new issue
Block a user