Skip to content

Commit

Permalink
added team.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
RyamL1221 committed Dec 9, 2024
1 parent d38c81d commit 72f5eac
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/lib/api/team.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use server';

import { ENDPOINTS } from './endpoints';

export async function UploadTeamSubmission(leaderEmail: string, data: any) {
const postBody = {
team_leader: leaderEmail,
team_members: data.team_members.filter(Boolean),
};

const resp = await fetch(ENDPOINTS.makeTeam, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(postBody),
});

if (resp.status !== 200) return { error: 'Non 200 response', response: '' };

const json = await resp.json();
if (json.error) {
return { error: json.error, response: '' };
}

return { error: '', response: 'Successfully submitted team!' };
}

0 comments on commit 72f5eac

Please sign in to comment.