// R-P9a interim UI (AD-28) — project template admin (D-P9 scope), restored // after the admin route was dropped in the seat-billing recut. // Pure/presentational: renders the server-built VM and turns every mutation // into a typed onSubmit(intent, fields) callback the route POSTs. No // useLoaderData/useFetcher, no server imports. Final Subframe optics = // tracked design-nachzug. Modeled on LostReasonAdminPage (same admin-subpage // chrome under /admin/pipelines). import { useState } from "react"; import { useTranslation } from "react-i18next"; import type { ProjectTemplatesAdminScreenVM } from "@hivegrid/view-models"; import { FeatherArrowLeft, FeatherPlus } from "@subframe/core"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { EmptyState } from "~/ui/components/EmptyState"; import { Select } from "~/ui/components/Select"; import { Table } from "~/ui/components/Table"; import { TextInput } from "~/ui/components/TextInput"; import { AppLink } from "~/components/app/AppLink"; export type ProjectTemplatesAdminSubmit = (intent: string, fields: Record) => void; export type ProjectTemplatesAdminPageProps = { vm: ProjectTemplatesAdminScreenVM; backHref: string; submitting: boolean; errorKey?: string | null; actions: { onSubmit: ProjectTemplatesAdminSubmit }; }; const mutedText = "text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary"; const NONE = "__none__"; export function ProjectTemplatesAdminPage(props: ProjectTemplatesAdminPageProps) { const { t } = useTranslation(); const submit = props.actions.onSubmit; const [name, setName] = useState(""); const [pipelineId, setPipelineId] = useState(NONE); const [stageId, setStageId] = useState(NONE); const pipelineOptions = props.vm.status === "ready" ? props.vm.data.pipelineOptions : []; const stageOptions = pipelineId === NONE ? [] : (pipelineOptions.find((pipeline) => pipeline.id === pipelineId)?.stages ?? []); return (
{t("projects.templatesAdmin.title")} {t("projects.templatesAdmin.subtitle")}
{props.errorKey ? {t(props.errorKey)} : null} {props.vm.status !== "ready" ? ( ) : ( <> {t("projects.templatesAdmin.newTemplate")}
setName(e.target.value)} data-ui-id="ui.projects.templatesAdmin.new.name" />
{props.vm.data.templates.length === 0 ? (
) : ( {t("projects.fields.templateName")} {t("projects.fields.pipeline")} {t("projects.fields.stage")} {t("projects.templatesAdmin.defaults")} {props.vm.data.templates.map((template) => (
{template.name} {template.isDemoData ? ( {t("projects.lostReasonsAdmin.demoBadge")} ) : null}
{template.pipelineName ?? t("projects.templates.noPipeline")} {template.stageName ?? t("projects.templatesAdmin.noStage")} {t("projects.templatesAdmin.defaultCounts", { members: template.memberCount, tasks: template.taskCount })}
))}
)} )}
); } export default ProjectTemplatesAdminPage;