From e441f59bffcef9d3bde4ba1822c322fd8d612f35 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 16 May 2026 07:45:53 +0200 Subject: [PATCH] Add delete functionality for training plan templates --- .../planning/TrainingPlanningPageRoot.jsx | 24 +++++++ .../TrainingPlanningUnitFormModal.jsx | 65 +++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/frontend/src/components/planning/TrainingPlanningPageRoot.jsx b/frontend/src/components/planning/TrainingPlanningPageRoot.jsx index 266e4f7..5a2680e 100644 --- a/frontend/src/components/planning/TrainingPlanningPageRoot.jsx +++ b/frontend/src/components/planning/TrainingPlanningPageRoot.jsx @@ -658,6 +658,29 @@ function TrainingPlanningPageRoot() { } } + const handleDeletePlanTemplate = useCallback( + async (tpl) => { + if (!tpl?.id) return + const label = (tpl.name || '').trim() || `Vorlage #${tpl.id}` + if ( + !window.confirm( + `Trainingsvorlage „${label}“ wirklich löschen? Die Aktion kann nicht rückgängig gemacht werden.` + ) + ) { + return + } + try { + await api.deleteTrainingPlanTemplate(tpl.id) + setDraftPlanTemplateId((prev) => (String(prev) === String(tpl.id) ? '' : prev)) + await loadPlanTemplates() + toast.success('Vorlage gelöscht.') + } catch (err) { + toast.error(err.message || 'Löschen fehlgeschlagen') + } + }, + [loadPlanTemplates, toast] + ) + const openModuleApplyModal = useCallback(async (placement) => { setModuleApplyErr('') setModuleApplySearchQuery('') @@ -1924,6 +1947,7 @@ function TrainingPlanningPageRoot() { draftPlanTemplateId={draftPlanTemplateId} onDraftTemplateSelect={applyTemplateFromSelect} planTemplates={planTemplates} + onDeletePlanTemplate={handleDeletePlanTemplate} clubDirectory={clubDirectory} clubDirectoryForCo={clubDirectoryForCo} planningModalClubId={planningModalClubId} diff --git a/frontend/src/components/planning/TrainingPlanningUnitFormModal.jsx b/frontend/src/components/planning/TrainingPlanningUnitFormModal.jsx index eaec781..f119029 100644 --- a/frontend/src/components/planning/TrainingPlanningUnitFormModal.jsx +++ b/frontend/src/components/planning/TrainingPlanningUnitFormModal.jsx @@ -18,6 +18,7 @@ export default function TrainingPlanningUnitFormModal({ draftPlanTemplateId, onDraftTemplateSelect, planTemplates, + onDeletePlanTemplate, clubDirectory, clubDirectoryForCo, planningModalClubId, @@ -129,6 +130,70 @@ export default function TrainingPlanningUnitFormModal({ )} + {planTemplates.length > 0 && typeof onDeletePlanTemplate === 'function' ? ( +
+ + Gespeicherte Vorlagen löschen + +

+ Du kannst eigene Vorlagen entfernen. Plattform-Admins dürfen auch fremde Vorlagen löschen. Einheiten, die + noch auf eine Vorlage verweisen, behalten ihren Ablauf; die Verknüpfung zur Vorlage wird vom Server + entfernt. +

+ +
+ ) : null} +

Planung