[feat] 공급사 포털: 협상완료 부가정보(select·종료 동의폼)·상태 라벨 통일·예아니오 Enter=예·목록 결과열·재협상 요청/철회 API·테스트
This commit is contained in:
1 parent
cfee6e89d0
commit
d7c4e86f30
46 files changed
+1715
-270
No files matched your search
@@ -1,35 +1,63 @@
|
||||
import { useQueries } from '@tanstack/react-query'
|
||||
import { negotiationApi, negotiationKeys, SessionStatus } from '@/apis'
|
||||
import { negotiationApi, negotiationKeys, SessionStatus, SessionResult } from '@/apis'
|
||||
|
||||
// KPI 콕핏에 노출할 상태별 집계. 각 상태를 page_size=1 로 조회해 total 만 읽는다(목록과 캐시 공유).
|
||||
// KPI 콕핏 집계. 진행(상태축)·결과(결과축) 두 묶음. 각 항목을 page_size=1 로 조회해 total 만 읽는다(목록과 캐시 공유).
|
||||
// 클릭 시 걸 필터가 상태냐 결과냐가 다르므로 kind 로 구분해 컨테이너가 올바른 setter 로 보낸다.
|
||||
export interface KpiCount {
|
||||
key: string
|
||||
label: string
|
||||
status: string // 클릭 시 필터에 넣을 원본 상태 라벨
|
||||
code: number
|
||||
kind: 'status' | 'result'
|
||||
statusLabel?: string // kind=status: 필터에 넣을 원본 상태 라벨
|
||||
resultCode?: number // kind=result: 필터에 넣을 SessionResult 코드
|
||||
count: number
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
const KPI = [
|
||||
{ key: 'created', label: '협상 대기', status: '협상생성', code: SessionStatus.CREATED },
|
||||
{ key: 'progress', label: '조율 진행중', status: '협상중', code: SessionStatus.IN_PROGRESS },
|
||||
{ key: 'done', label: '타결 완료', status: '협상완료', code: SessionStatus.DONE },
|
||||
{ key: 'rejected', label: '거부/반려', status: '협상거부', code: SessionStatus.REJECTED },
|
||||
// 진행 묶음(내가 할 일) — 세션 상태축.
|
||||
const PROGRESS = [
|
||||
{ key: 'created', label: '협상 대기', statusLabel: '협상생성', code: SessionStatus.CREATED },
|
||||
{ key: 'progress', label: '협상 중', statusLabel: '협상중', code: SessionStatus.IN_PROGRESS },
|
||||
] as const
|
||||
|
||||
export function useSessionCounts(): KpiCount[] {
|
||||
const results = useQueries({
|
||||
queries: KPI.map((k) => ({
|
||||
// 결과 묶음(마감 후) — 결과축. 낙찰=주강조, 결렬=재협상 가능(액션).
|
||||
const RESULT = [
|
||||
{ key: 'won', label: '낙찰', code: SessionResult.WON },
|
||||
{ key: 'open', label: '결렬', code: SessionResult.OPEN },
|
||||
{ key: 'lost', label: '미낙찰', code: SessionResult.LOST },
|
||||
] as const
|
||||
|
||||
export function useSessionCounts(): { progress: KpiCount[]; result: KpiCount[] } {
|
||||
const statusQ = useQueries({
|
||||
queries: PROGRESS.map((k) => ({
|
||||
queryKey: negotiationKeys.sessionList({ status: k.code, page: 1, page_size: 1 }),
|
||||
queryFn: () => negotiationApi.getSessions({ status: k.code, page: 1, page_size: 1 }),
|
||||
staleTime: 60 * 1000,
|
||||
})),
|
||||
})
|
||||
const resultQ = useQueries({
|
||||
queries: RESULT.map((k) => ({
|
||||
queryKey: negotiationKeys.sessionList({ result: k.code, page: 1, page_size: 1 }),
|
||||
queryFn: () => negotiationApi.getSessions({ result: k.code, page: 1, page_size: 1 }),
|
||||
staleTime: 60 * 1000,
|
||||
})),
|
||||
})
|
||||
|
||||
return KPI.map((k, i) => ({
|
||||
...k,
|
||||
count: results[i].data?.total ?? 0,
|
||||
isLoading: results[i].isLoading,
|
||||
}))
|
||||
return {
|
||||
progress: PROGRESS.map((k, i) => ({
|
||||
key: k.key,
|
||||
label: k.label,
|
||||
kind: 'status',
|
||||
statusLabel: k.statusLabel,
|
||||
count: statusQ[i].data?.total ?? 0,
|
||||
isLoading: statusQ[i].isLoading,
|
||||
})),
|
||||
result: RESULT.map((k, i) => ({
|
||||
key: k.key,
|
||||
label: k.label,
|
||||
kind: 'result',
|
||||
resultCode: k.code,
|
||||
count: resultQ[i].data?.total ?? 0,
|
||||
isLoading: resultQ[i].isLoading,
|
||||
})),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user