Add facilities, contracts, orders, value lists, audit log, and desktop app modules

Extends omsorgCore with full CRUD for Facility/Contract/Order plus
configurable value lists and an audit trail, and wires the omsorgapp
frontend up to the new facilities, settings, and audit-log modules;
includes a sidebar active-nav-item highlight.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Felix Kemmler
2026-08-08 23:29:16 +02:00
co-authored by Claude Sonnet 5
parent ee74ed65f5
commit e9e96a57dc
528 changed files with 96814 additions and 456 deletions
@@ -0,0 +1,169 @@
import OmsorgButton from "../../components/ui/OmsorgButton";
import { useValueListItems } from "../../app/useValueListItems";
export const emptyFacilityForm = {
name: "",
crmStatus: "Lead",
facilityType: "",
website: "",
street: "",
postalCode: "",
city: "",
country: "",
billingStreet: "",
billingPostalCode: "",
billingCity: "",
billingCountry: "",
};
export function facilityToFormValues(facility) {
return {
name: facility.name ?? "",
crmStatus: facility.crmStatus ?? "Lead",
facilityType: facility.facilityType ?? "",
website: facility.website ?? "",
street: facility.street ?? "",
postalCode: facility.postalCode ?? "",
city: facility.city ?? "",
country: facility.country ?? "",
billingStreet: facility.billingStreet ?? "",
billingPostalCode: facility.billingPostalCode ?? "",
billingCity: facility.billingCity ?? "",
billingCountry: facility.billingCountry ?? "",
};
}
export function facilityFormToPayload(form, { includeCrmStatus = false } = {}) {
const payload = {
name: form.name.trim(),
facilityType: form.facilityType || null,
website: form.website.trim() || null,
street: form.street.trim() || null,
postalCode: form.postalCode.trim() || null,
city: form.city.trim() || null,
country: form.country.trim() || null,
billingStreet: form.billingStreet.trim() || null,
billingPostalCode: form.billingPostalCode.trim() || null,
billingCity: form.billingCity.trim() || null,
billingCountry: form.billingCountry.trim() || null,
};
if (includeCrmStatus) {
payload.crmStatus = form.crmStatus;
}
return payload;
}
export default function FacilityForm({ form, onChange, includeCrmStatus = false }) {
const { items: crmStatusOptions } = useValueListItems("CrmStatus");
const { items: facilityTypes } = useValueListItems("FacilityType");
function updateField(field) {
return (event) => onChange({ ...form, [field]: event.target.value });
}
return (
<div className="form-grid">
<label className="form-field">
<span>Name *</span>
<input value={form.name} onChange={updateField("name")} required />
</label>
{includeCrmStatus && (
<label className="form-field">
<span>CRM-Status</span>
<select value={form.crmStatus} onChange={updateField("crmStatus")}>
{crmStatusOptions.map((option) => (
<option key={option.id} value={option.value}>
{option.value}
</option>
))}
</select>
</label>
)}
<label className="form-field">
<span>Art der Einrichtung</span>
<select value={form.facilityType} onChange={updateField("facilityType")}>
<option value=""> nicht angegeben </option>
{facilityTypes.map((option) => (
<option key={option.id} value={option.value}>
{option.value}
</option>
))}
</select>
</label>
<label className="form-field">
<span>Website</span>
<input type="url" value={form.website} onChange={updateField("website")} placeholder="https://…" />
</label>
<fieldset className="form-field form-field--fieldset">
<legend>Adresse</legend>
<label className="form-field">
<span>Straße und Hausnummer</span>
<input value={form.street} onChange={updateField("street")} />
</label>
<div className="form-row">
<label className="form-field">
<span>PLZ</span>
<input value={form.postalCode} onChange={updateField("postalCode")} />
</label>
<label className="form-field">
<span>Ort</span>
<input value={form.city} onChange={updateField("city")} />
</label>
</div>
<label className="form-field">
<span>Land</span>
<input value={form.country} onChange={updateField("country")} />
</label>
</fieldset>
<fieldset className="form-field form-field--fieldset">
<legend>Rechnungsadresse</legend>
<label className="form-field">
<span>Straße und Hausnummer</span>
<input value={form.billingStreet} onChange={updateField("billingStreet")} />
</label>
<div className="form-row">
<label className="form-field">
<span>PLZ</span>
<input value={form.billingPostalCode} onChange={updateField("billingPostalCode")} />
</label>
<label className="form-field">
<span>Ort</span>
<input value={form.billingCity} onChange={updateField("billingCity")} />
</label>
</div>
<label className="form-field">
<span>Land</span>
<input value={form.billingCountry} onChange={updateField("billingCountry")} />
</label>
</fieldset>
</div>
);
}
export function FormActions({ onCancel, isSaving, submitLabel }) {
return (
<div className="form-actions">
<OmsorgButton variant="secondary" type="button" onClick={onCancel} disabled={isSaving}>
Abbrechen
</OmsorgButton>
<OmsorgButton type="submit" disabled={isSaving}>
{isSaving ? "Speichert..." : submitLabel}
</OmsorgButton>
</div>
);
}