Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt in #230

Merged
merged 3 commits into from
Oct 25, 2024
Merged
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
6 changes: 2 additions & 4 deletions app/(pre-dashboard)/(landing)/sections/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ const schedule = {
{ time: '12:00 PM', event: 'Team Building', location: 'tbd' },
{ time: '12:00 PM', event: 'Hacking Starts', location: 'Hacking Area' },
{ time: '1:00 PM', event: 'Lunch', location: 'In Front of MPR' },
{ time: 'TBD', event: 'Coming Soon!', location: 'TBD' },
{ time: 'TBD', event: 'Coming Soon!', location: 'TBD' },
{ time: 'TBD', event: 'Coming Soon!', location: 'TBD' },
{ time: 'TBD', event: 'Coming Soon!', location: 'TBD' },
{ time: '1:00 PM - 7:00PM', event: 'Partner Workshops! NTICE, iCIMS, MLH (Github, Figma)', location: '108' },
{ time: '4:00 PM', event: 'Aracde Suprise', location: 'tbd' },
// {
// time: '2:00 PM',
// event: 'Wakefern Tech Talk',
Expand Down
35 changes: 35 additions & 0 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import { majors as majorConstants } from '@/app/lib/constants';

import { useSearchParams } from 'next/navigation';

import { OptInSelf } from '@/app/lib/data';

let whenTeamCreationBegins = new Date('March 23, 2024 12:00:00');
const numOfMinsUntilTeamCreation =
(whenTeamCreationBegins.getTime() - Date.now()) / 60000;
Expand Down Expand Up @@ -469,6 +471,39 @@ export default function Dashboard() {
</CardHeader>
</Card>
)}
{userData?.opt_in == null && (
<Card className="w-full max-w-2xl">
<CardHeader>
<CardTitle>Would you like to opt-in to Major League Hacking emails</CardTitle>
<CardDescription>
<Button
onClick={async () => {
const resp = await OptInSelf(true)
if (resp == "GOOD"){
setUserData({ ...userData, opt_in: true })
}
}}
type="button"
className="mt-10"
>
OPT IN
</Button>
<Button
onClick={async () => {
const resp = await OptInSelf(false)
if (resp == "GOOD"){
setUserData({ ...userData, opt_in: false })
}
}}
type="button"
className="mx-10"
>
OPT OUT
</Button>
</CardDescription>
</CardHeader>
</Card>
)}
{userData?.registration_status === 'checked_in' && false && (
<Card className="w-full max-w-2xl">
<CardHeader>
Expand Down
18 changes: 18 additions & 0 deletions app/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,24 @@ export async function RegisterSelf() {
return 'Something went wrong';
}

export async function OptInSelf(stat:boolean) {
const session = await auth();
console.log('Register Self');
if (session?.user && session?.user?.email) {
const resp = await SetUser(
{ opt_in: stat},
session.user.email,
);

if (resp.error === '') {
return "GOOD";
}
return resp.error;
}

return 'Something went wrong';
}

export async function ConfirmComingOrNot(isComing: boolean): Promise<{
error: string | undefined;
response: Record<string, any>;
Expand Down
Loading