feat: milestone/task status UI + propose pages + action buttons #8

Merged
hzhang merged 11 commits from feat/milestone-propose-state-machine into main 2026-03-19 11:12:03 +00:00
Showing only changes of commit d6a45c3e17 - Show all commits

View File

@@ -49,14 +49,13 @@ export default function TaskDetailPage() {
setComments(data)
}
const doAction = async (actionName: string, newStatus: string, extra?: () => Promise<void>) => {
const doAction = async (actionName: string, newStatus: string, body?: Record<string, any>) => {
setActionLoading(actionName)
setActionError(null)
try {
if (extra) await extra()
await api.post(`/tasks/${id}/transition?new_status=${newStatus}`)
await api.post(`/tasks/${id}/transition?new_status=${newStatus}`, body || {})
await refreshTask()
// refresh comments too (finish adds one)
// refresh comments too (finish adds one via backend)
const { data } = await api.get<Comment[]>(`/tasks/${id}/comments`)
setComments(data)
} catch (err: any) {
@@ -70,17 +69,16 @@ export default function TaskDetailPage() {
const handleStart = () => doAction('start', 'undergoing')
const handleFinishConfirm = async () => {
if (!finishComment.trim()) return
await doAction('finish', 'completed', async () => {
await api.post('/comments', { content: finishComment, task_id: task!.id, author_id: user?.id || 1 })
})
await doAction('finish', 'completed', { comment: finishComment })
setShowFinishModal(false)
setFinishComment('')
}
const handleCloseConfirm = async () => {
const body: Record<string, any> = {}
if (closeReason.trim()) {
await api.post('/comments', { content: `[Close reason] ${closeReason}`, task_id: task!.id, author_id: user?.id || 1 }).catch(() => {})
body.comment = `[Close reason] ${closeReason}`
}
await doAction('close', 'closed')
await doAction('close', 'closed', body)
setShowCloseModal(false)
setCloseReason('')
}