86 lines
2.9 KiB
TypeScript
86 lines
2.9 KiB
TypeScript
import { formatComponentName } from "@/lib/componentName";
|
|
import { Sites } from "@/_config/sites";
|
|
import { api_units } from "@/actions/rk2/api-units";
|
|
import { api_anlage_getSelected } from "@/actions/rk/api-anlage";
|
|
import Link from "next/link";
|
|
import { List, ListHeader, ListHeaderItem, ListItem, ListItemAction, ListItemContent, ListItemDescription, ListItemTitle } from "@/components/ui/list";
|
|
import { Button } from "@/components/ui/button";
|
|
import Breadcrumbs from "@/components/ui/navigation/breadcrumbs";
|
|
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
|
import { GroupPath } from "@/components/rk2/groups/groupPath";
|
|
import { api_groups } from "@/actions/rk2/api-groups";
|
|
import { AusgabeUnitInfo } from "@/components/rk2/ausgabe/ausgabeUnitInfo";
|
|
|
|
|
|
|
|
export default async function PageUnits() {
|
|
|
|
const units = await api_units();
|
|
const groups = await api_groups();
|
|
const breadcrumb = [{ label: "RK", href: "/" }, { label: "Anlage", href: "/rk2" }, { label: "Units" }]
|
|
|
|
return (
|
|
<>
|
|
{/* Main-Nav */}
|
|
<div>
|
|
<Breadcrumbs items={breadcrumb} />
|
|
</div>
|
|
|
|
<Card className="flex flex-col m-4 w-170 ">
|
|
<CardHeader>Units</CardHeader>
|
|
<Link className="m-2 underline" href="/rk2/units/templates">Unit-Vorlagen / Aus Vorlage hinzufügen</Link>
|
|
|
|
<Button size={"xs"} className="w-30 mt-2 ms-2 mb-2">
|
|
<Link href={Sites.rk2.units.new.url}>{Sites.rk2.units.new.name}</Link>
|
|
</Button>
|
|
|
|
|
|
<List variant={"transparent"} >
|
|
<ListHeader>
|
|
<ListHeaderItem className="w-50">Gruppe</ListHeaderItem>
|
|
<ListHeaderItem className="w-50">Unit</ListHeaderItem>
|
|
<ListHeaderItem>Typ</ListHeaderItem>
|
|
</ListHeader>
|
|
{units.map((unit) => (
|
|
<ListItem hover={true} key={unit.id}>
|
|
<ListItemContent >
|
|
<ListItemTitle className="flex">
|
|
<div className="w-50">
|
|
<GroupPath groups={groups} groupId={unit.groupId} />
|
|
</div>
|
|
<div className="w-50">
|
|
{unit.prefix}_{unit.bmk}_{unit.name}{unit.postfix ? "_"+unit.postfix:""}
|
|
</div>
|
|
<div className="w-20">
|
|
{unit.type}
|
|
</div>
|
|
</ListItemTitle>
|
|
<ListItemDescription className="ps-50 pt-1 flex gap-2">
|
|
{unit.components?.map((comp) => <div key={comp.id}>
|
|
{comp.prefix && comp.prefix}
|
|
{formatComponentName(comp)}
|
|
{comp.postfix && comp.postfix}
|
|
{comp.index && comp.index>0 ? comp.index:""}
|
|
</div>)}
|
|
</ListItemDescription>
|
|
</ListItemContent>
|
|
<ListItemAction>
|
|
<Button variant={"secondary"} size={"xs"} >
|
|
<Link href={`/rk2/units/edit/${unit.id}`}>Auswahl</Link>
|
|
</Button>
|
|
</ListItemAction>
|
|
</ListItem>
|
|
|
|
))}
|
|
</List>
|
|
</Card >
|
|
<Card>
|
|
<CardHeader>Ausgabe</CardHeader>
|
|
<CardContent>
|
|
<AusgabeUnitInfo units={units} groups={groups} />
|
|
</CardContent>
|
|
</Card>
|
|
</>
|
|
);
|
|
}
|