Alpenwerk HR 0.1.0 Betrieb auf Windows Server - Die Anwendung läuft im IIS (HttpPlatformHandler) unter dem Konto des Anwendungspools, ohne Administratorrechte und ohne eigenen Windows-Dienst - Das Zertifikat kommt aus dem Zertifikatsspeicher; die Bindung folgt jeder Erneuerung automatisch - Neue Versionen mit aktualisieren.ps1 -Paket <zip>, mit Sicherung vorab; Rückstieg mit zuruecksetzen.ps1 - HR-Zugang für ganze Domains mit freischalten.ps1 -Domain; Einzelsperren haben Vorrang - Anmeldung ausschließlich über Microsoft Entra ID - Das Windows-Paket hängt an jedem Release Fachliche Erweiterungen - Änderungen per Austauschdatei importieren, mit Vorschau, Prüfung und Fehlerdatei - Einstellung: eigene Maske für externe Personen, Übernahme von Leiharbeitskräften, Planstellen zum Eintrittstag - Organisationsstruktur: Einheiten und Kostenstellen anlegen, umbenennen und abschließen; Suche nach Planstelle, Einheit und Kostenstelle - Historie: Austritt, Versetzung und Eintritt berichtigen oder zurücknehmen; Planstelle mit Bezeichnung - Abwesenheiten ohne Ende, geplante Abwesenheiten mit Art, Checklisten mit Anlass, auch zur Rückkehr - Berichte mit Mehrfachauswahl in allen Kriterien; Kostenstelle als Filter und Gruppierung - Stammdaten: mehrere Notfallkontakte, Lehrzeit, Ferialkraft, Altersteilzeit, erweiterte Beschäftigtengruppen und Geschlechtsangaben
79 lines
3.1 KiB
TypeScript
79 lines
3.1 KiB
TypeScript
"use client";
|
|
|
|
import { CheckCircle2, Info, TriangleAlert, type LucideIcon } from "lucide-react";
|
|
import { createContext, useCallback, useContext, useMemo, useState, type ReactNode } from "react";
|
|
|
|
type ToastVariant = "success" | "error" | "info";
|
|
type ToastItem = { id: number; message: string; variant: ToastVariant };
|
|
type ToastContextValue = { showToast: (message: string, variant?: ToastVariant) => void };
|
|
|
|
const ToastContext = createContext<ToastContextValue | null>(null);
|
|
|
|
const VARIANT_STYLES: Record<ToastVariant, string> = {
|
|
success: "bg-success-text",
|
|
error: "bg-danger-solid",
|
|
info: "bg-info-text",
|
|
};
|
|
|
|
const VARIANT_ICONS: Record<ToastVariant, LucideIcon> = {
|
|
success: CheckCircle2,
|
|
error: TriangleAlert,
|
|
info: Info,
|
|
};
|
|
|
|
// ── Warum die Meldung so gross ist ──────────────────────────────────────
|
|
//
|
|
// Sie ist die einzige Rückmeldung darüber, ob ein Vorgang stattgefunden hat —
|
|
// etwa eine Einstellung, deren Eingabe eine halbe Stunde gekostet hat. Wird
|
|
// sie übersehen, bleibt nur die Vermutung, und die nächste Handlung ist, es
|
|
// noch einmal zu versuchen. Deshalb gross, mit Zeichen, und mittig statt in
|
|
// einer Ecke.
|
|
//
|
|
// Sechs Sekunden: die Meldungen sind ganze Sätze („… wurde eingestellt"),
|
|
// und kürzer reicht nicht, um einen Satz zu finden und zu lesen.
|
|
const ANZEIGEDAUER_MS = 6000;
|
|
|
|
export function ToastProvider({ children }: { children: ReactNode }) {
|
|
const [toasts, setToasts] = useState<ToastItem[]>([]);
|
|
|
|
const showToast = useCallback((message: string, variant: ToastVariant = "success") => {
|
|
const id = Date.now() + Math.random();
|
|
setToasts((prev) => [...prev, { id, message, variant }]);
|
|
setTimeout(() => setToasts((prev) => prev.filter((t) => t.id !== id)), ANZEIGEDAUER_MS);
|
|
}, []);
|
|
|
|
// This provider wraps the whole app, so an inline object literal here would
|
|
// hand every consumer a new context value on each toast and re-render the
|
|
// entire tree for a short-lived banner.
|
|
const value = useMemo(() => ({ showToast }), [showToast]);
|
|
|
|
return (
|
|
<ToastContext.Provider value={value}>
|
|
{children}
|
|
{/* Die Breite ist begrenzt, damit ein langer Satz nicht quer über den
|
|
Bildschirm läuft. */}
|
|
<div className="pointer-events-none fixed inset-x-0 bottom-6 z-[100] flex flex-col items-center gap-2 px-4">
|
|
{toasts.map((t) => {
|
|
const Icon = VARIANT_ICONS[t.variant];
|
|
return (
|
|
<div
|
|
key={t.id}
|
|
role="status"
|
|
className={`pointer-events-auto flex max-w-xl items-center gap-3 rounded-lg px-5 py-4 text-base font-semibold text-white shadow-xl ring-1 ring-black/10 ${VARIANT_STYLES[t.variant]}`}
|
|
>
|
|
<Icon className="h-6 w-6 shrink-0" aria-hidden />
|
|
<span>{t.message}</span>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
</ToastContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function useToast(): ToastContextValue {
|
|
const ctx = useContext(ToastContext);
|
|
if (!ctx) throw new Error("useToast must be used within a ToastProvider");
|
|
return ctx;
|
|
}
|