feat: Allow event owners to delete their own events and admins to delete any event with UI action buttons and confirmation dialog
This commit is contained in:
+31
-4
@@ -264,6 +264,29 @@ export default function App() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteEvent = async (eventObj) => {
|
||||
if (!eventObj || !eventObj.id) return;
|
||||
if (!window.confirm(`Möchtest du die Veranstaltung "${eventObj.title}" und alle zugehörigen Schichten wirklich unwiderruflich löschen?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await apiFetch(`/events/${eventObj.id}/`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
showNotification(`Veranstaltung "${eventObj.title}" wurde erfolgreich gelöscht.`);
|
||||
if (selectedEventId === eventObj.id) {
|
||||
setSelectedEventId(null);
|
||||
}
|
||||
if (activeTab === 'event-editor') {
|
||||
setActiveTab('home');
|
||||
}
|
||||
refreshEvents();
|
||||
} catch (err) {
|
||||
showNotification(`Fehler beim Löschen: ${err.message}`);
|
||||
}
|
||||
};
|
||||
|
||||
const [eventToEdit, setEventToEdit] = useState(null);
|
||||
|
||||
const handleSaveEventSubmit = async (eventPayload) => {
|
||||
@@ -444,6 +467,7 @@ export default function App() {
|
||||
setEventToEdit(evt);
|
||||
setActiveTab('event-editor');
|
||||
}}
|
||||
onDeleteEvent={handleDeleteEvent}
|
||||
branding={branding}
|
||||
/>
|
||||
) : activeTab === 'calendar' ? (
|
||||
@@ -467,8 +491,10 @@ export default function App() {
|
||||
<EventEditorPage
|
||||
eventToEdit={eventToEdit}
|
||||
skills={skills}
|
||||
user={user}
|
||||
onBack={() => setActiveTab('schedule')}
|
||||
onSubmit={handleSaveEventSubmit}
|
||||
onDeleteEvent={handleDeleteEvent}
|
||||
/>
|
||||
) : activeTab === 'templates' ? (
|
||||
<TemplatesPage
|
||||
@@ -522,6 +548,11 @@ export default function App() {
|
||||
user={user}
|
||||
onSignupClick={handleShiftSignupClick}
|
||||
onCancelClick={handleCancelSignup}
|
||||
onEditEvent={(evt) => {
|
||||
setEventToEdit(evt);
|
||||
setActiveTab('event-editor');
|
||||
}}
|
||||
onDeleteEvent={handleDeleteEvent}
|
||||
onRemoveUserFromShift={async (shift, signupId) => {
|
||||
try {
|
||||
const res = await apiFetch(`/shifts/${shift.id}/signup/${signupId}/`, {
|
||||
@@ -539,10 +570,6 @@ export default function App() {
|
||||
onGenerateClaimLink={handleGenerateClaimLink}
|
||||
onExportPdf={handleExportPdf}
|
||||
onPrintView={handlePrintView}
|
||||
onEditEvent={(evt) => {
|
||||
setEventToEdit(evt);
|
||||
setActiveTab('event-editor');
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user