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:
co-authored by
Claude Sonnet 5
parent
ee74ed65f5
commit
e9e96a57dc
@@ -0,0 +1,105 @@
|
||||
import { useState } from "react";
|
||||
import { Pencil } from "lucide-react";
|
||||
|
||||
import OmsorgCard from "../../components/OmsorgCard";
|
||||
import OmsorgButton from "../../components/ui/OmsorgButton";
|
||||
import { useAuth } from "../../app/AuthContext";
|
||||
import EditFacilityDialog from "./EditFacilityDialog";
|
||||
import FacilityContactsList from "./FacilityContactsList";
|
||||
|
||||
function formatAddress(street, postalCode, city, country) {
|
||||
const line = [postalCode, city].filter(Boolean).join(" ");
|
||||
const parts = [street, line].filter(Boolean);
|
||||
|
||||
if (country && country !== "Deutschland") {
|
||||
parts.push(country);
|
||||
}
|
||||
|
||||
return parts.length > 0 ? parts.join(", ") : "—";
|
||||
}
|
||||
|
||||
export default function FacilityDetailPanel({ facility, onUpdated }) {
|
||||
const { hasPermission } = useAuth();
|
||||
const canEdit = hasPermission("Facilities", "Edit");
|
||||
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false);
|
||||
|
||||
if (!facility) {
|
||||
return (
|
||||
<OmsorgCard>
|
||||
<div className="employee-detail-empty">
|
||||
<h2>Keine Einrichtung ausgewählt</h2>
|
||||
<p>Wähle links eine Einrichtung aus.</p>
|
||||
</div>
|
||||
</OmsorgCard>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<OmsorgCard>
|
||||
<div className="employee-detail">
|
||||
<div className="employee-detail-header">
|
||||
<div>
|
||||
<h2>{facility.name}</h2>
|
||||
<span className="omsorg-badge omsorg-badge--neutral">{facility.crmStatus}</span>
|
||||
</div>
|
||||
|
||||
{canEdit && (
|
||||
<OmsorgButton variant="secondary" icon={Pencil} onClick={() => setIsEditDialogOpen(true)}>
|
||||
Bearbeiten
|
||||
</OmsorgButton>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="employee-detail-grid">
|
||||
<div>
|
||||
<strong>Art der Einrichtung</strong>
|
||||
<p>{facility.facilityType ?? "—"}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Website</strong>
|
||||
<p>
|
||||
{facility.website ? (
|
||||
<a href={facility.website} target="_blank" rel="noreferrer">
|
||||
{facility.website}
|
||||
</a>
|
||||
) : (
|
||||
"—"
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Adresse</strong>
|
||||
<p>{formatAddress(facility.street, facility.postalCode, facility.city, facility.country)}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Rechnungsadresse</strong>
|
||||
<p>
|
||||
{formatAddress(
|
||||
facility.billingStreet,
|
||||
facility.billingPostalCode,
|
||||
facility.billingCity,
|
||||
facility.billingCountry
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FacilityContactsList facilityId={facility.id} />
|
||||
</div>
|
||||
|
||||
{isEditDialogOpen && (
|
||||
<EditFacilityDialog
|
||||
facility={facility}
|
||||
onClose={() => setIsEditDialogOpen(false)}
|
||||
onUpdated={(updatedFacility) => {
|
||||
setIsEditDialogOpen(false);
|
||||
onUpdated?.(updatedFacility);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</OmsorgCard>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user