diff --git a/src/components/dashboard/SettingsSection.astro b/src/components/dashboard/SettingsSection.astro index 63f0a68..c85a37b 100644 --- a/src/components/dashboard/SettingsSection.astro +++ b/src/components/dashboard/SettingsSection.astro @@ -5,6 +5,7 @@ import AccountSecuritySettings from "./SettingsSection/AccountSecuritySettings"; import NotificationSettings from "./SettingsSection/NotificationSettings"; import DisplaySettings from "./SettingsSection/DisplaySettings"; import ResumeSettings from "./SettingsSection/ResumeSettings"; +import EmailRequestSettings from "./SettingsSection/EmailRequestSettings"; // Import environment variables const logtoAppId = import.meta.env.LOGTO_APP_ID; @@ -119,6 +120,25 @@ const safeLogtoApiEndpoint = logtoApiEndpoint || ""; + +
+
+

+
+ +
+ IEEE Email Address +

+

+ Request an official IEEE UCSD email address (officers only) +

+
+ +
+
+
(null); + const [loading, setLoading] = useState(true); + const [requesting, setRequesting] = useState(false); + const [isOfficer, setIsOfficer] = useState(false); + + useEffect(() => { + const loadUserData = async () => { + try { + setLoading(true); + const currentUser = auth.getCurrentUser(); + if (!currentUser) { + toast.error('You must be logged in to access this page'); + return; + } + + setUser(currentUser); + + // Check if user is an officer + const pb = auth.getPocketBase(); + try { + const officerRecord = await pb.collection('officers').getFirstListItem(`user="${currentUser.id}"`); + if (officerRecord) { + setIsOfficer(true); + } + } catch (error) { + // Not an officer, which is fine + console.log('User is not an officer'); + } + } catch (error) { + console.error('Error loading user data:', error); + toast.error('Failed to load user data. Please try again later.'); + } finally { + setLoading(false); + } + }; + + loadUserData(); + }, []); + + const handleRequestEmail = async () => { + if (!user) return; + + try { + setRequesting(true); + + // Update the user record to mark email as requested + const pb = auth.getPocketBase(); + await pb.collection(Collections.USERS).update(user.id, { + requested_email: true + }); + + // Refresh user data + const updatedUser = auth.getCurrentUser(); + setUser(updatedUser); + + toast.success('Email request submitted successfully! Our team will process your request soon.'); + } catch (error) { + console.error('Error requesting email:', error); + toast.error('Failed to submit email request. Please try again later.'); + } finally { + setRequesting(false); + } + }; + + if (loading) { + return ( +
+ +
+ ); + } + + if (!isOfficer) { + return ( +
+ + IEEE email addresses are only available to officers. If you are an officer and don't see the option to request an email, please contact the webmaster. +
+ ); + } + + if (user?.requested_email) { + return ( +
+
+ + You have requested an IEEE email address. Our team is processing your request. +
+ +
+

What happens next?

+
    +
  1. Our webmaster will create your email address (typically firstname.lastname@ieeeucsd.org)
  2. +
  3. You'll receive an email with your credentials and setup instructions
  4. +
  5. You can use this email for IEEE-related communications
  6. +
+
+ +
+ + If you have any questions or need help with your IEEE email, please contact webmaster@ieeeucsd.org +
+
+ ); + } + + return ( +
+

+ As an IEEE officer, you're eligible for an official IEEE UCSD email address. This email can be used for all IEEE-related communications and provides a professional identity when representing the organization. +

+ +
+

Benefits of an IEEE email:

+
    +
  • Professional communication with sponsors and partners
  • +
  • Consistent branding for IEEE UCSD
  • +
  • Separation between personal and IEEE communications
  • +
  • Access to IEEE UCSD shared resources
  • +
+
+ + + +
+

By requesting an email, you agree to use it responsibly and in accordance with IEEE UCSD policies.

+

Email addresses are typically in the format firstname.lastname@ieeeucsd.org

+
+
+ ); +} \ No newline at end of file diff --git a/src/schemas/pocketbase/schema.ts b/src/schemas/pocketbase/schema.ts index de69a26..57aa85c 100644 --- a/src/schemas/pocketbase/schema.ts +++ b/src/schemas/pocketbase/schema.ts @@ -37,6 +37,7 @@ export interface User extends BaseRecord { display_preferences?: string; // JSON string of display settings (theme, font size, etc.) accessibility_settings?: string; // JSON string of accessibility settings (color blind mode, reduced motion) resume?: string; + requested_email?: boolean; // Whether the user has requested an IEEE email address } /**