diff --git a/frontend/src/i18n/locales/de.json b/frontend/src/i18n/locales/de.json index 53a8641a..e87e9eef 100644 --- a/frontend/src/i18n/locales/de.json +++ b/frontend/src/i18n/locales/de.json @@ -1017,6 +1017,8 @@ "welcomeMessagePlaceholder": "Willkommen zu unserem besonderen Tag! Laden Sie diese Erinnerungen gerne herunter und teilen Sie sie...", "hostEmailPlaceholder": "kunde@beispiel.de", "adminEmailPlaceholder": "admin@beispiel.de", + "adminEmailPickFromAdmins": "Aus Admins wählen:", + "adminEmailCustom": "Eigene E-Mail", "securityAndAccess": "Sicherheit & Zugriff", "accessAndSecurity": "Zugriff & Sicherheit", "enterPassword": "Passwort eingeben", diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 59da8cfb..8dc871e6 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -356,6 +356,8 @@ "welcomeMessagePlaceholder": "Welcome to our special day! Feel free to download and share these memories...", "hostEmailPlaceholder": "customer@example.com", "adminEmailPlaceholder": "admin@example.com", + "adminEmailPickFromAdmins": "Pick from admins:", + "adminEmailCustom": "Custom email", "securityAndAccess": "Security & Access", "accessAndSecurity": "Access & Security", "enterPassword": "Enter password", diff --git a/frontend/src/pages/admin/CreateEventPage.tsx b/frontend/src/pages/admin/CreateEventPage.tsx index bde500f9..d0d36ebc 100644 --- a/frontend/src/pages/admin/CreateEventPage.tsx +++ b/frontend/src/pages/admin/CreateEventPage.tsx @@ -25,6 +25,8 @@ import { settingsService } from '../../services/settings.service'; import { usePublicSettings } from '../../hooks/usePublicSettings'; import { cssTemplatesService } from '../../services/cssTemplates.service'; import { eventTypesService } from '../../services/eventTypes.service'; +import { userManagementService } from '../../services/userManagement.service'; +import { useAdminAuth } from '../../contexts/AdminAuthContext'; import { useTranslation } from 'react-i18next'; import { ThemeConfig, GALLERY_THEME_PRESETS } from '../../types/theme.types'; import { Code } from 'lucide-react'; @@ -172,6 +174,41 @@ export const CreateEventPage: React.FC = () => { const { data: publicSettings } = usePublicSettings(); + // Current logged-in admin (used to prefill the admin email field) + const { user: currentAdmin } = useAdminAuth(); + + // Optional: list of admin users — used to populate the email picker when + // there are multiple admins. Falls back to an empty list silently if the + // current user lacks `users.view` permission, so basic admins still get + // the auto-prefill from `currentAdmin` without errors surfacing. + const { data: adminUsers } = useQuery({ + queryKey: ['admin-users-list'], + queryFn: async () => { + try { + return await userManagementService.getUsers(); + } catch { + return []; + } + }, + staleTime: 5 * 60 * 1000, + retry: false + }); + + const activeAdmins = useMemo( + () => (adminUsers || []).filter(u => u.isActive !== false && !!u.email), + [adminUsers] + ); + + // Auto-prefill admin email with the current user's email exactly once, + // and only if the field is still empty (don't clobber typed input). + const didPrefillAdminEmailRef = useRef(false); + useEffect(() => { + if (didPrefillAdminEmailRef.current) return; + if (!currentAdmin?.email) return; + didPrefillAdminEmailRef.current = true; + setFormData(prev => (prev.admin_email ? prev : { ...prev, admin_email: currentAdmin.email })); + }, [currentAdmin?.email]); + // Get field requirements (default to true if not set) const requireCustomerName = publicSettings?.event_require_customer_name !== false; const requireCustomerEmail = publicSettings?.event_require_customer_email !== false; @@ -673,6 +710,31 @@ export const CreateEventPage: React.FC = () => { error={errors.admin_email} leftIcon={} /> + {activeAdmins.length > 1 && ( +
+ + +
+ )}