Add: Offboarding Detail-Seite (/lifecycle/offboarding/:id) + Öffnen-Button in Liste
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import onboardingService from '../services/onboardingService';
|
||||
import offboardingService from '../services/offboardingService';
|
||||
@@ -196,7 +197,7 @@ const STATUS_CSS = { pending: 'status-pending', in_progress: 'status-in_progre
|
||||
const formatDate = (d) => d ? new Date(d).toLocaleDateString('de-DE') : '—';
|
||||
|
||||
// ── Kleine Hilfstabelle ───────────────────────────────────────────────────────
|
||||
const ProtocolTable = ({ protocols, dateKey, dateLabel, onEdit, onAction, actionLabel, actionClass, onDelete, onDownload, canDelete = true }) => (
|
||||
const ProtocolTable = ({ protocols, dateKey, dateLabel, onEdit, onOpen, onAction, actionLabel, actionClass, onDelete, onDownload, canDelete = true }) => (
|
||||
<div className="card" style={{ overflowX: 'auto' }}>
|
||||
<table className="table">
|
||||
<thead>
|
||||
@@ -248,9 +249,14 @@ const ProtocolTable = ({ protocols, dateKey, dateLabel, onEdit, onAction, action
|
||||
<td style={{ fontSize: '0.85rem' }}>{p.created_by_username}</td>
|
||||
<td>
|
||||
<div className="table-actions">
|
||||
<button onClick={() => onEdit(p)} className="btn btn-primary btn-small">Bearbeiten</button>
|
||||
{onAction && <button onClick={() => onAction(p)} className={`btn ${actionClass} btn-small`}>{actionLabel}</button>}
|
||||
{canDelete && <button onClick={() => onDelete(p.id)} className="btn btn-danger btn-small">Löschen</button>}
|
||||
{onOpen
|
||||
? <button onClick={() => onOpen(p)} className="btn btn-primary btn-small">Öffnen →</button>
|
||||
: <>
|
||||
<button onClick={() => onEdit(p)} className="btn btn-primary btn-small">Bearbeiten</button>
|
||||
{onAction && <button onClick={() => onAction(p)} className={`btn ${actionClass} btn-small`}>{actionLabel}</button>}
|
||||
{canDelete && <button onClick={() => onDelete(p.id)} className="btn btn-danger btn-small">Löschen</button>}
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -262,6 +268,7 @@ const ProtocolTable = ({ protocols, dateKey, dateLabel, onEdit, onAction, action
|
||||
|
||||
// ── Hauptkomponente ───────────────────────────────────────────────────────────
|
||||
const OnOffboardingPage = () => {
|
||||
const navigate = useNavigate();
|
||||
const { user, isAdmin, isSuperAdmin, canViewLifecycle } = useAuth();
|
||||
const canManage = isAdmin() || isSuperAdmin();
|
||||
const canCreate = canViewLifecycle(); // hr_personal + buchhaltung dürfen anlegen
|
||||
@@ -620,9 +627,7 @@ const OnOffboardingPage = () => {
|
||||
<ProtocolTable
|
||||
protocols={offProtocols}
|
||||
dateKey="exit_date" dateLabel="Austrittsdatum"
|
||||
onEdit={openOffEdit}
|
||||
onAction={openReturnAssets} actionLabel="Assets zurück" actionClass="btn-warning"
|
||||
onDelete={deleteOff}
|
||||
onOpen={p => navigate(`/lifecycle/offboarding/${p.id}`)}
|
||||
onDownload={p => p.pdf_file_path && window.open(offboardingService.downloadPdf(p.pdf_file_path), '_blank')}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user