- 프로젝트 표 「종류」 열(임도설계 · 예정노선 · 안정성평가 · 사방설계 · 칸 없음 = 임도) - 단계 막대 = 종류별(ROAD B03~B09 그대로 · PLAN D02~D04 · STABILITY E02~E05) · 누름 = 그 단계 화면 - 받은 예정노선(회사관리자 · 사용자 · 받은 것 있을 때만) = 예정노선 · 연도 · 연결 상태 · 업데이트 배지 · [보기] = D02 · [연결] 자리만(531-3) - E01 [등록] 고르기 칸 setError 없음 오류 걷음(목록 비면 단추 꺼짐) - tsconfig D0* · E0* → 폴더 안까지(D0*/**/*) — 앞 판은 폴더 안 파일을 안 잡아 타입 검사가 빠졌음 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.7 KiB
TypeScript
71 lines
2.7 KiB
TypeScript
/* =============================================================================
|
|
* B01_Dashboard_UI_AssignedPlans.ts
|
|
* 대시보드 「받은 예정노선」 구역(요구서 345 2-2 · PLAN 528-2) — 우리 회사에 지정된 예정노선 연도.
|
|
* 열 = 예정노선 · 연도 · 연결 상태(연결됨 · 미연결 · 업데이트 있음 배지) · [보기] [연결]
|
|
* [보기] = 그 예정노선 첫 단계(D02 · 공유 회사 = GET 만) · [연결] = 자리만(동작은 531-3)
|
|
* ========================================================================== */
|
|
|
|
import { API_BASE_URL, ROUTES } from "@config/config_frontend";
|
|
import { createButton, createTag } from "@ui/ui_template_elements";
|
|
import { table, text } from "@ui/ui_template_general_blocks";
|
|
import { goToWorkflowStage } from "../A00_Common/b_workflow_nav";
|
|
import { DASHBOARD_VISIBLE_ROWS, L } from "./B01_Dashboard_UI_Common";
|
|
|
|
export interface AssignedPlan {
|
|
project_id: string;
|
|
project_name: string;
|
|
year: number;
|
|
linked_project_id: string | null;
|
|
update_available: boolean;
|
|
}
|
|
|
|
/** 받은 예정노선 — 실패 · 없음 = 빈 목록(구역을 안 그림) */
|
|
export async function fetchAssignedPlans(): Promise<AssignedPlan[]> {
|
|
const response = await fetch(`${API_BASE_URL}/dashboard/plan-routes/assigned`, {
|
|
credentials: "include",
|
|
});
|
|
if (!response.ok) return [];
|
|
return ((await response.json()) as { routes?: AssignedPlan[] }).routes ?? [];
|
|
}
|
|
|
|
function linkState(plan: AssignedPlan): HTMLElement {
|
|
const cell = document.createElement("div");
|
|
cell.className = "b01-dashboard__actions";
|
|
cell.append(
|
|
createTag(
|
|
L(plan.linked_project_id ? "DE_Assigned_Linked" : "DE_Assigned_Unlinked"),
|
|
plan.linked_project_id ? "success" : "neutral",
|
|
),
|
|
);
|
|
if (plan.update_available) cell.append(createTag(L("DE_Assigned_Update"), "warning"));
|
|
return cell;
|
|
}
|
|
|
|
export function assignedPlanTable(plans: AssignedPlan[]): HTMLElement {
|
|
return table(
|
|
[
|
|
L("DE_New_Plan"),
|
|
L("DE_Assigned_Year"),
|
|
L("DE_Assigned_State"),
|
|
L("B01_Dashboard_Table_Action"),
|
|
],
|
|
plans.map((plan) => {
|
|
const actions = document.createElement("div");
|
|
actions.className = "b01-dashboard__actions";
|
|
const link = createButton({ label: L("DE_Assigned_Link"), variant: "ghost" });
|
|
link.disabled = true;
|
|
link.title = L("DE_New_Soon");
|
|
actions.append(
|
|
createButton({
|
|
label: L("DE_Assigned_View"),
|
|
variant: "ghost",
|
|
onClick: () => void goToWorkflowStage(plan.project_id, ROUTES.D02_PLAN_BASE),
|
|
}),
|
|
link,
|
|
);
|
|
return [text(plan.project_name), text(plan.year), linkState(plan), actions];
|
|
}),
|
|
DASHBOARD_VISIBLE_ROWS,
|
|
);
|
|
}
|