feat: Quickstart, Benutzerverwaltung und Orion-Ergebnisbox
This commit is contained in:
parent
4f669a3426
commit
e9e46f2cb4
404 changed files with 1032 additions and 600 deletions
88
validation-suite/frontend/atlas/lib/validation-result.tsx
Normal file
88
validation-suite/frontend/atlas/lib/validation-result.tsx
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import { AlertCircle, CheckCircle2, CircleDashed, ShieldAlert } from "lucide-react";
|
||||
|
||||
export const validationResultValues = [
|
||||
"OFFEN",
|
||||
"BESTANDEN",
|
||||
"BESTANDEN_MIT_AUFLAGEN",
|
||||
"NICHT_BESTANDEN"
|
||||
] as const;
|
||||
|
||||
export type ValidationResultValue = (typeof validationResultValues)[number];
|
||||
|
||||
export type ValidationResultPresentation = {
|
||||
value: ValidationResultValue;
|
||||
label: string;
|
||||
badgeClass: string;
|
||||
previewClass: string;
|
||||
color: string;
|
||||
icon: typeof CircleDashed;
|
||||
};
|
||||
|
||||
const presentations: Record<ValidationResultValue, ValidationResultPresentation> = {
|
||||
OFFEN: {
|
||||
value: "OFFEN",
|
||||
label: "Noch nicht bewertet",
|
||||
badgeClass: "border-slate-300 bg-slate-100 text-slate-700",
|
||||
previewClass: "border-slate-300 bg-slate-50 text-slate-700",
|
||||
color: "#2E3B40",
|
||||
icon: CircleDashed
|
||||
},
|
||||
BESTANDEN: {
|
||||
value: "BESTANDEN",
|
||||
label: "Bestanden",
|
||||
badgeClass: "border-success/35 bg-success/15 text-success",
|
||||
previewClass: "border-success/40 bg-success/10 text-success",
|
||||
color: "#245C36",
|
||||
icon: CheckCircle2
|
||||
},
|
||||
BESTANDEN_MIT_AUFLAGEN: {
|
||||
value: "BESTANDEN_MIT_AUFLAGEN",
|
||||
label: "Bestanden mit Auflagen",
|
||||
badgeClass: "border-warning/40 bg-warning/15 text-[#7A5A00]",
|
||||
previewClass: "border-warning/45 bg-warning/10 text-[#7A5A00]",
|
||||
color: "#7A5A00",
|
||||
icon: ShieldAlert
|
||||
},
|
||||
NICHT_BESTANDEN: {
|
||||
value: "NICHT_BESTANDEN",
|
||||
label: "Nicht bestanden",
|
||||
badgeClass: "border-danger/35 bg-danger/15 text-danger",
|
||||
previewClass: "border-danger/40 bg-danger/10 text-danger",
|
||||
color: "#7A1F26",
|
||||
icon: AlertCircle
|
||||
}
|
||||
};
|
||||
|
||||
const aliases: Record<string, ValidationResultValue> = {
|
||||
"": "OFFEN",
|
||||
offen: "OFFEN",
|
||||
OFFEN: "OFFEN",
|
||||
bestanden: "BESTANDEN",
|
||||
BESTANDEN: "BESTANDEN",
|
||||
mit_auflagen: "BESTANDEN_MIT_AUFLAGEN",
|
||||
bestanden_mit_auflagen: "BESTANDEN_MIT_AUFLAGEN",
|
||||
"bestanden mit auflagen": "BESTANDEN_MIT_AUFLAGEN",
|
||||
BESTANDEN_MIT_AUFLAGEN: "BESTANDEN_MIT_AUFLAGEN",
|
||||
nicht_bestanden: "NICHT_BESTANDEN",
|
||||
"nicht bestanden": "NICHT_BESTANDEN",
|
||||
NICHT_BESTANDEN: "NICHT_BESTANDEN"
|
||||
};
|
||||
|
||||
export function normalizeValidationResult(value?: string | null): ValidationResultValue {
|
||||
return aliases[String(value ?? "").trim()] ?? "OFFEN";
|
||||
}
|
||||
|
||||
export function getValidationResultPresentation(value?: string | null) {
|
||||
return presentations[normalizeValidationResult(value)];
|
||||
}
|
||||
|
||||
export function ValidationResultBadge({ value, className = "" }: { value?: string | null; className?: string }) {
|
||||
const presentation = getValidationResultPresentation(value);
|
||||
const Icon = presentation.icon;
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-semibold ${presentation.badgeClass} ${className}`}>
|
||||
<Icon className="h-3.5 w-3.5" />
|
||||
{presentation.label}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue