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
43 changes: 43 additions & 0 deletions src/api/dashboard.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { fetchDashboardToday } from './dashboard'

beforeEach(() => {
vi.stubGlobal(
'fetch',
vi.fn().mockResolvedValue(
new Response(
JSON.stringify({
summary_counts: {
pending_approval: 1,
due_today: 2,
needs_info: 3,
worker_response: 4,
},
priority_tasks: [],
upcoming_7_days: [],
recommendations: {
connected_count: 0,
prepared: [],
review: [],
after_approval: [],
},
approval_count: 1,
worker_response_count: 4,
}),
{ status: 200, headers: { 'Content-Type': 'application/json' } },
),
),
)
})

afterEach(() => vi.unstubAllGlobals())

describe('fetchDashboardToday', () => {
it('requests the Today projection with the selected timezone', async () => {
await fetchDashboardToday('Asia/Seoul')

const [url, init] = vi.mocked(fetch).mock.calls[0]
expect(String(url)).toContain('/dashboard/today?timezone=Asia%2FSeoul')
expect(init?.method).toBeUndefined()
})
})
60 changes: 60 additions & 0 deletions src/api/dashboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import type { DocumentType } from './documents'
import { apiFetch } from './client'
import type { TaskStatus } from './tasks'

export interface DashboardSummaryCountsResponse {
pending_approval: number
due_today: number
needs_info: number
worker_response: number
}

export interface DashboardTaskSummaryResponse {
task_id: string
worker_id: string
title: string
status: TaskStatus
due_date: string | null
}

export type UpcomingExpiryCategory =
| 'STAY_EXPIRY'
| 'CONTRACT_END'
| 'EMPLOYMENT_PERMIT_END'
| 'EMPLOYMENT_ACTIVITY_END'
| 'DOCUMENT_EXPIRY'

export interface UpcomingExpiryItemResponse {
worker_id: string
display_name: string
category: UpcomingExpiryCategory
expiry_date: string
document_type: DocumentType | null
}

export interface DashboardRecommendationItemResponse {
task_id: string
title: string
status: TaskStatus
}

export interface DashboardRecommendationsResponse {
connected_count: number
prepared: DashboardRecommendationItemResponse[]
review: DashboardRecommendationItemResponse[]
after_approval: DashboardRecommendationItemResponse[]
}

export interface DashboardTodayResponse {
summary_counts: DashboardSummaryCountsResponse
priority_tasks: DashboardTaskSummaryResponse[]
upcoming_7_days: UpcomingExpiryItemResponse[]
recommendations: DashboardRecommendationsResponse
approval_count: number
worker_response_count: number
}

export function fetchDashboardToday(timezone = 'Asia/Seoul'): Promise<DashboardTodayResponse> {
const query = new URLSearchParams({ timezone })
return apiFetch<DashboardTodayResponse>(`/dashboard/today?${query.toString()}`)
}
120 changes: 113 additions & 7 deletions src/pages/DashboardPage/DashboardPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,92 @@
scrollbar-width: thin;
}

.capNotice {
margin: -2px 0 0;
.sectionEmpty {
margin: 0;
padding: 16px;
background: var(--surface-default);
border: 1px solid var(--border-default);
border-radius: var(--fowoco-radius-8);
font-size: 12px;
color: var(--text-secondary);
}

.upcomingExpiry {
display: flex;
flex-direction: column;
gap: 10px;
min-width: 0;
}

.expiryList {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
margin: 0;
padding: 0;
list-style: none;
}

.expiryItem {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
width: 100%;
min-height: 58px;
padding: 10px 12px;
background: var(--surface-default);
border: 1px solid var(--border-default);
border-left: 3px solid var(--border-strong);
border-radius: var(--fowoco-radius-8);
color: var(--text-primary);
font: inherit;
text-align: left;
cursor: pointer;
}

.expiryItem:hover {
border-color: var(--border-strong);
box-shadow: var(--shadow-sm);
}

.expiryItem > span {
display: flex;
min-width: 0;
flex-direction: column;
gap: 3px;
}

.expiryItem strong {
overflow: hidden;
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}

.expiryItem small,
.expiryItem em {
font-size: 11px;
font-style: normal;
color: var(--text-secondary);
}

.expiryItem em {
flex: 0 0 auto;
}

.expiryItem_critical {
border-left-color: var(--status-critical);
}

.expiryItem_warning {
border-left-color: var(--status-warning);
}

.expiryItem_info {
border-left-color: var(--status-info);
}

.agentPrepared {
grid-area: aside;
display: flex;
Expand Down Expand Up @@ -531,17 +611,39 @@
}

.preparedSection li {
display: grid;
grid-template-columns: 16px minmax(0, 1fr);
column-gap: 8px;
align-items: center;
display: block;
min-height: 20px;
font-size: 13px;
line-height: 20px;
color: var(--text-primary);
}

.preparedSection li strong {
.preparedItemButton {
display: grid;
grid-template-columns: 16px minmax(0, 1fr);
column-gap: 8px;
align-items: center;
width: 100%;
padding: 0;
background: transparent;
border: 0;
color: inherit;
font: inherit;
text-align: left;
cursor: pointer;
}

.preparedItemButton:hover strong {
color: var(--brand-primary);
}

.preparedItemButton:focus-visible,
.expiryItem:focus-visible {
outline: 2px solid var(--brand-primary);
outline-offset: 2px;
}

.preparedItemButton strong {
font-weight: 500;
}

Expand Down Expand Up @@ -600,6 +702,10 @@
gap: 12px;
}

.expiryList {
grid-template-columns: 1fr;
}

.priorityBody {
gap: 12px;
}
Expand Down
Loading