refactor(web): consume api v1 contracts

This commit is contained in:
2026-07-21 16:29:42 +08:00
parent 80bec26839
commit c56ada3708
8 changed files with 311 additions and 149 deletions

View File

@@ -42,7 +42,7 @@ function App() {
async function loadWorkspaces(nextSession: ApiSession, preferredProjectID = activeProjectID) {
const backendProjects = await fetchProjects(nextSession)
const backendWorkspaces = await Promise.all(
backendProjects.map((project, index) => fetchProjectWorkspace(nextSession, project.ID ?? project.id ?? '').then((workspace) => mapWorkspace(workspace, index))),
backendProjects.map((project, index) => fetchProjectWorkspace(nextSession, project.id).then((workspace) => mapWorkspace(workspace, index))),
)
setWorkspaces(backendWorkspaces)
const nextProjectID = backendWorkspaces.find((workspace) => workspace.project.id === preferredProjectID)?.project.id ?? backendWorkspaces[0]?.project.id ?? ''
@@ -114,7 +114,7 @@ function App() {
background: draft.background.trim(),
description: draft.description.trim(),
})
const nextProjectID = String(created.ID ?? created.id ?? '')
const nextProjectID = created.id
await refreshAfterAction(nextProjectID)
if (nextProjectID) {
setActiveProjectID(nextProjectID)
@@ -203,7 +203,7 @@ function App() {
title: update.title,
description: update.summary,
completed: update.completed,
nextProjectId: Number(update.nextProjectId),
nextProjectId: update.nextProjectId,
tag: update.tag,
})
await refreshAfterAction(update.nextProjectId)