Wenn Sie die Löschung bereits veröffentlichter BeitrĂ€ge wĂŒnschen, kontaktieren Sie uns nach dem Widerruf.
`
- });
-
- if (!result.isConfirmed) return;
- }
-
- try {
- const payload = consentType === 'workshop'
- ? { consentType: 'workshop', action: 'revoke' }
- : { consentType: 'social_media', action: 'revoke', platformId };
-
- const res = await fetch(`/api/manage/${token}/consents`, {
- method: 'PUT',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(payload)
- });
-
- if (!res.ok) {
- const body = await res.json().catch(() => ({}));
- throw new Error(body.error || 'Fehler beim Widerrufen');
- }
-
- // Erfolg - zeige BestĂ€tigung mit Kontaktinfo fĂŒr Social Media
- if (consentType === 'social-media') {
- const mailtoLink = `mailto:it@hobbyhimmel.de?subject=${encodeURIComponent(`Löschung Social Media Post - Gruppe ${group.groupId}`)}&body=${encodeURIComponent(`Hallo,\n\nBitte löschen Sie die bereits veröffentlichten BeitrÀge meiner Gruppe ${group.groupId} von ${consentName}.\n\nVielen Dank`)}`;
-
- await Swal.fire({
- icon: 'success',
- title: 'Einwilligung widerrufen',
- html: `Ihre Einwilligung fĂŒr ${consentName} wurde widerrufen.
-
Bereits veröffentlichte BeitrÀge löschen?
-
Kontaktieren Sie uns mit Ihrer Gruppen-ID:
-
- Gruppen-ID: ${group.groupId}
- E-Mail: it@hobbyhimmel.de
-
-
`,
- confirmButtonText: 'Verstanden'
- });
- } else {
- await Swal.fire({
- icon: 'success',
- title: 'Einwilligung widerrufen',
- text: `Ihre Einwilligung fĂŒr ${consentName} wurde widerrufen.`,
- timer: 2000,
- showConfirmButton: false
- });
- }
-
- // Reload group to get updated consent status
- await loadGroup();
-
- } catch (error) {
- console.error('Error revoking consent:', error);
- Swal.fire({
- icon: 'error',
- title: 'Fehler',
- text: error.message || 'Einwilligung konnte nicht widerrufen werden'
+ // Handle consent changes from ConsentCheckboxes component
+ const handleConsentChange = (newConsents) => {
+ setCurrentConsents(newConsents);
+
+ if (!group) return;
+
+ const changes = [];
+
+ // Check workshop consent change
+ const originalWorkshop = group.consents?.workshopConsent || false;
+ if (newConsents.workshopConsent !== originalWorkshop) {
+ changes.push({
+ consentType: 'workshop',
+ action: newConsents.workshopConsent ? 'restore' : 'revoke',
+ platformId: null
});
}
+
+ // Check social media consent changes
+ allPlatforms.forEach(platform => {
+ const consent = group.consents?.socialMediaConsents?.find(c => c.platformId === platform.id);
+ const originalStatus = consent ? (consent.consented && !consent.revoked) : false;
+ const newStatus = newConsents.socialMediaConsents?.some(c => c.platformId === platform.id) || false;
+
+ if (newStatus !== originalStatus) {
+ changes.push({
+ consentType: 'social_media',
+ action: newStatus ? 'restore' : 'revoke',
+ platformId: platform.id
+ });
+ }
+ });
+
+ setPendingConsentChanges(changes);
};
- // Handle consent restoration
- const handleRestoreConsent = async (consentType, platformId = null) => {
- const consentName = consentType === 'workshop'
- ? 'Werkstatt-Anzeige'
- : group.consents.socialMediaConsents.find(c => c.platformId === platformId)?.platformDisplayName || 'Social Media';
-
- const result = await Swal.fire({
- title: `Einwilligung wiederherstellen?`,
- html: `Möchten Sie Ihre Einwilligung fĂŒr