Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/components/ui/AgentSummary/AgentSummary.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,5 @@

.action {
align-self: flex-start;
font-size: 14px;
font-weight: 500;
color: var(--brand-primary);
background: none;
border: none;
padding: 0;
cursor: pointer;
margin-top: var(--fowoco-spacing-4);
}
5 changes: 3 additions & 2 deletions src/components/ui/AgentSummary/AgentSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styles from './AgentSummary.module.css'
import { Button } from '../Button/Button'

export interface AgentSummaryProps {
headline: string
Expand All @@ -13,9 +14,9 @@ export function AgentSummary({ headline, body, actionLabel, onAction }: AgentSum
<p className={styles.kicker}>AGENT가 준비한 다음 행동</p>
<p className={styles.headline}>{headline}</p>
<p className={styles.body}>{body}</p>
<button type="button" className={styles.action} onClick={onAction}>
<Button className={styles.action} onClick={onAction}>
{actionLabel}
</button>
</Button>
</div>
)
}
4 changes: 4 additions & 0 deletions src/pages/CaseDetailPage/CaseDetailPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@
text-align: center;
}

.workflowAction {
margin-top: var(--fowoco-spacing-16);
}

.stepTitle {
margin: 0;
font-size: 14px;
Expand Down
11 changes: 11 additions & 0 deletions src/pages/CaseDetailPage/CaseDetailPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,17 @@ describe('CaseDetailPage', () => {
expect(await screen.findByText(/완료 처리 불가 · 승인 · 필수 체크리스트/)).toBeInTheDocument()
})

it('offers a visible action that opens the checklist required for progress', async () => {
const user = userEvent.setup()
mockTaskAndActivities()
renderPage()

await user.click(await screen.findByRole('button', { name: '필수 항목 확인하기' }))

expect(screen.getByRole('tab', { name: '체크리스트' })).toHaveAttribute('aria-selected', 'true')
expect(screen.getByRole('button', { name: /여권 사본 확인/ })).toBeInTheDocument()
})

it('blocks completion and offers retry when document readiness cannot be verified', async () => {
const user = userEvent.setup()
mockTaskAndActivities({}, [], errorResponse(503, 'SERVICE_UNAVAILABLE', '서류 상태 확인 지연'))
Expand Down
9 changes: 9 additions & 0 deletions src/pages/CaseDetailPage/CaseDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,15 @@ export function CaseDetailPage() {
})}
</div>
)}
{!checklistReady && (
<Button
variant="secondary"
className={styles.workflowAction}
onClick={() => setActiveTab('체크리스트')}
>
필수 항목 확인하기
</Button>
)}
{approvalReady && workerGuideReady && (
<button
type="button"
Expand Down
7 changes: 7 additions & 0 deletions src/pages/DashboardPage/DashboardPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@
color: var(--text-secondary);
}

.commandError {
margin: 5px 0 0;
font-size: 11px;
line-height: 17px;
color: var(--color-danger-700, #b42318);
}

.quickPromptPanel {
min-width: 0;
padding: 16px 18px;
Expand Down
72 changes: 65 additions & 7 deletions src/pages/DashboardPage/DashboardPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import userEvent from '@testing-library/user-event'
import { MemoryRouter, Route, Routes, useLocation, useParams } from 'react-router-dom'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { DashboardTodayResponse } from '../../api/dashboard'
import type { AiRunResponse } from '../../api/aiRuns'
import { DashboardTodayProvider } from '../../components/layout/DashboardTodayProvider'
import { DashboardPage } from './DashboardPage'
import { AI_REQUEST_PROMPT_CHIPS } from './dashboardData'
Expand Down Expand Up @@ -103,10 +104,10 @@ function WorkerDetailProbe() {
return <p>근로자 상세 {workerId}</p>
}

function WorkCreateProbe() {
function WorkReviewProbe() {
const location = useLocation()
const prefill = (location.state as { prefill?: string } | null)?.prefill
return <p>업무 생성 {prefill}</p>
const state = location.state as { draft?: { request?: string } } | null
return <p>{`업무 검토 ${state?.draft?.request ?? ''}${location.search}`}</p>
}

function WorkListProbe() {
Expand All @@ -120,7 +121,7 @@ function renderPage() {
<DashboardTodayProvider>
<Routes>
<Route path="/dashboard" element={<DashboardPage />} />
<Route path="/tasks/new" element={<WorkCreateProbe />} />
<Route path="/tasks/new/review" element={<WorkReviewProbe />} />
<Route path="/tasks" element={<WorkListProbe />} />
<Route path="/tasks/:taskId" element={<TaskDetailProbe />} />
<Route path="/workers/:workerId/detail" element={<WorkerDetailProbe />} />
Expand All @@ -130,6 +131,23 @@ function renderPage() {
)
}

const AI_RUN_RESPONSE: AiRunResponse = {
ai_run_id: 'AI-RUN-1',
request_id: 'REQUEST-1',
instruction: '응웬반A 체류기간 연장 준비',
status: 'SUCCEEDED',
analysis_outcome: 'CONTEXT_REQUIRED',
detected_intent: 'EXPIRY_RENEWAL',
evidence: null,
error_code: null,
attempt_count: 1,
version: 1,
questions: [],
candidates: [],
created_at: '2026-08-18T00:00:00Z',
updated_at: '2026-08-18T00:00:00Z',
}

beforeEach(() => {
vi.stubGlobal(
'fetch',
Expand All @@ -138,6 +156,9 @@ beforeEach(() => {
if (url.includes('/workers')) {
return Promise.resolve(jsonResponse({ items: [], page: 0, size: 100, total_elements: 0 }))
}
if (url.includes('/ai-runs')) {
return Promise.resolve(jsonResponse(AI_RUN_RESPONSE))
}
return Promise.resolve(jsonResponse(TODAY_RESPONSE))
}),
)
Expand Down Expand Up @@ -307,7 +328,7 @@ describe('DashboardPage', () => {
expect((await screen.findAllByText('응웬반A 체류연장 요청문')).length).toBeGreaterThan(0)
})

it('fills the input from a prompt chip and forwards it on submit', async () => {
it('fills the input from a prompt chip and starts analysis with one submit', async () => {
const user = userEvent.setup()
renderPage()

Expand All @@ -318,7 +339,14 @@ describe('DashboardPage', () => {

await user.click(screen.getByRole('button', { name: '업무 분석' }))

expect(await screen.findByText(`업무 생성 ${AI_REQUEST_PROMPT_CHIPS[0]}`)).toBeInTheDocument()
expect(
await screen.findByText(`업무 검토 ${AI_REQUEST_PROMPT_CHIPS[0]}?aiRunId=AI-RUN-1`),
).toBeInTheDocument()
const aiRunCall = vi
.mocked(fetch)
.mock.calls.find(([input]) => String(input).includes('/ai-runs'))
expect(aiRunCall?.[1]).toMatchObject({ method: 'POST' })
expect(aiRunCall?.[1]?.body).toBe(JSON.stringify({ instruction: AI_REQUEST_PROMPT_CHIPS[0] }))
})

it('accepts a natural-language request directly and submits it with Enter', async () => {
Expand All @@ -328,6 +356,36 @@ describe('DashboardPage', () => {
const requestInput = await screen.findByRole('textbox', { name: '업무 내용' })
await user.type(requestInput, '응웬반A 체류기간 연장 준비{Enter}')

expect(await screen.findByText('업무 생성 응웬반A 체류기간 연장 준비')).toBeInTheDocument()
expect(
await screen.findByText('업무 검토 응웬반A 체류기간 연장 준비?aiRunId=AI-RUN-1'),
).toBeInTheDocument()
})

it('shows an API error without leaving the dashboard', async () => {
vi.mocked(fetch).mockImplementation((input: RequestInfo | URL) => {
const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url
if (url.includes('/workers')) {
return Promise.resolve(jsonResponse({ items: [], page: 0, size: 100, total_elements: 0 }))
}
if (url.includes('/ai-runs')) {
return Promise.resolve(
jsonResponse(
{ code: 'AI_UNAVAILABLE', message: 'AI 분석 서비스를 사용할 수 없습니다.' },
{ status: 503 },
),
)
}
return Promise.resolve(jsonResponse(TODAY_RESPONSE))
})
const user = userEvent.setup()
renderPage()

await user.type(await screen.findByRole('textbox', { name: '업무 내용' }), '체류연장 준비')
await user.click(screen.getByRole('button', { name: '업무 분석' }))

expect(await screen.findByRole('alert')).toHaveTextContent(
'AI 분석 서비스를 사용할 수 없습니다.',
)
expect(screen.getByRole('heading', { name: '오늘의 업무를 확인하세요.' })).toBeInTheDocument()
})
})
48 changes: 42 additions & 6 deletions src/pages/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useCallback, useMemo, useRef, useState, type FormEvent, type KeyboardEvent } from 'react'
import { useNavigate } from 'react-router-dom'
import { createAiRun } from '../../api/aiRuns'
import { ApiError, getErrorMessage } from '../../api/errors'
import { fetchWorkers } from '../../api/workers'
import { useDashboardToday } from '../../components/layout/dashboardTodayContext'
import { EmptyState } from '../../components/ui/EmptyState/EmptyState'
Expand All @@ -15,10 +17,17 @@ import {
buildDashboardWorkItems,
buildUpcomingExpiries,
} from './dashboardData'
import {
saveActiveWorkRequestDraft,
saveAiRunWorkRequestDraft,
type WorkRequestDraft,
} from '../CreateWorkPage/workRequestDraft'

export function DashboardPage() {
const navigate = useNavigate()
const [agentRequest, setAgentRequest] = useState('')
const [analyzing, setAnalyzing] = useState(false)
const [analysisError, setAnalysisError] = useState<string | null>(null)
const agentRequestRef = useRef<HTMLTextAreaElement>(null)
const { status, data: today, error, refetch, lastUpdatedAt } = useDashboardToday()
// 우선 업무 카드의 근로자 이름을 표시하기 위한 조회 — today API의 priority_tasks에는
Expand Down Expand Up @@ -71,11 +80,33 @@ export function DashboardPage() {

const headline = status === 'empty' ? '현재 등록된 업무가 없습니다.' : '오늘의 업무를 확인하세요.'

function handleAgentRequestSubmit(event: FormEvent<HTMLFormElement>) {
async function handleAgentRequestSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault()
const prefill = agentRequest.trim()
if (!prefill) return
navigate('/tasks/new', { state: { prefill } })
const instruction = agentRequest.trim()
if (!instruction || analyzing) return

setAnalyzing(true)
setAnalysisError(null)
try {
const aiRun = await createAiRun(instruction, globalThis.crypto.randomUUID())
const draft: WorkRequestDraft = {
request: instruction,
mode: 'nl',
workerId: '',
attachments: [],
}
saveActiveWorkRequestDraft(draft)
saveAiRunWorkRequestDraft(aiRun.ai_run_id, draft)
navigate(`/tasks/new/review?aiRunId=${encodeURIComponent(aiRun.ai_run_id)}`, {
state: { aiRun, draft },
})
} catch (error) {
setAnalysisError(
error instanceof ApiError ? getErrorMessage(error) : '요청을 분석하지 못했습니다.',
)
} finally {
setAnalyzing(false)
}
}

function handleAgentRequestKeyDown(event: KeyboardEvent<HTMLTextAreaElement>) {
Expand Down Expand Up @@ -142,15 +173,20 @@ export function DashboardPage() {
<button
type="submit"
className={styles.commandSubmit}
disabled={agentRequest.trim() === ''}
disabled={agentRequest.trim() === '' || analyzing}
>
<img src={commandSubmitIcon} alt="" aria-hidden="true" />
<span>업무 분석</span>
<span>{analyzing ? '분석 중' : '업무 분석'}</span>
</button>
</div>
<p id="agent-request-hint" className={styles.commandHint}>
입력한 원문 그대로 분석합니다 · Enter로 분석 · Shift+Enter로 줄바꿈
</p>
{analysisError && (
<p className={styles.commandError} role="alert">
{analysisError}
</p>
)}
</form>
</div>

Expand Down
48 changes: 47 additions & 1 deletion src/pages/ReviewWorkPage/AiRunReview.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,17 @@
margin-top: 16px;
}

.fieldGridSingle {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
margin-top: 16px;
}

@media (max-width: 560px) {
.fieldGrid,
.fieldGridTwo {
.fieldGridTwo,
.fieldGridSingle {
grid-template-columns: 1fr;
}
}
Expand Down Expand Up @@ -273,6 +281,21 @@
margin-top: 16px;
}

.questionLabel {
display: block;
margin: 12px 0 4px;
font-size: 14px;
font-weight: 700;
color: var(--text-primary);
}

.questionHelp {
margin: 0 0 8px;
font-size: 12px;
line-height: 18px;
color: var(--text-secondary);
}

.questionInput {
width: 100%;
min-height: 42px;
Expand All @@ -284,6 +307,29 @@
box-sizing: border-box;
}

.dateTimeSelect {
display: grid;
grid-template-columns: repeat(3, minmax(88px, 1fr)) repeat(2, minmax(76px, 0.8fr));
gap: 8px;
}

.dateTimeSelect select {
width: 100%;
min-height: 42px;
padding: 8px 10px;
color: var(--text-primary);
background: var(--surface-default);
border: 1px solid var(--border-default);
border-radius: var(--fowoco-radius-6);
font: inherit;
}

@media (max-width: 760px) {
.dateTimeSelect {
grid-template-columns: repeat(3, minmax(72px, 1fr));
}
}

.errorCard {
padding: var(--fowoco-spacing-20) var(--fowoco-spacing-24);
background: var(--fowoco-red-50, #fff1f1);
Expand Down
Loading