Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/app/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ const contributors: HoagieChef[] = [
graduationYear: '2028',
link: 'https://www.linkedin.com/in/linsey-zhong-686a72309/',
},
{
name: 'Ruoming Shen',
graduationYear: '2027',
link: 'https://www.linkedin.com/in/ruomingshen/',
}
];

const LinkedInIcon = (props: SVGProps<SVGSVGElement>) => (
Expand Down
70 changes: 70 additions & 0 deletions frontend/services/userService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import type { Profile } from '@/types';

import { fetchCsrfToken } from '@/utils/csrf';

// Fetch user profile from the backend
async function fetchCustomUser(
netId: string,
firstName: string,
lastName: string,
email: string
): Promise<Profile | null> {
try {
const csrfToken = await fetchCsrfToken();

const response = await fetch(`/api/hoagie/profile/get_user`, {
method: 'POST',
headers: {
'X-CSRFToken': csrfToken,
},
body: JSON.stringify({
netId,
firstName,
lastName,
email,
}),
});

if (!response.ok) {
if (response.status === 401) {
console.error('User not authenticated.');
return null;
}
if (response.status === 404) {
console.error('User profile not found.');
return null;
}
throw new Error(`Error fetching CustomUser: ${response.statusText}`);
}

const data = await response.json();
return data as Profile;
} catch (error) {
console.error('Error fetching CustomUser:', error);
return null;
}
}

async function updateUserProfile(
updatedProfile: Profile
): Promise<Profile | null> {
try {
const csrfToken = await fetchCsrfToken();
const response = await fetch(`/api/hoagie/profile/update`, {
method: 'POST',
headers: {
'X-CSRFToken': csrfToken,
},
body: JSON.stringify(updatedProfile),
});

if (!response.ok) {
throw new Error('Failed to update profile');
}
return null
} catch (error) {
console.error('Error updating profile:', error);
}
}