Skip to content

Commit

Permalink
clicking doesn't break the website
Browse files Browse the repository at this point in the history
  • Loading branch information
avsomers25 committed Jun 26, 2024
1 parent c0d6a48 commit dfadeb2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 deletions.
2 changes: 2 additions & 0 deletions app/(pre-dashboard)/(entry)/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button } from '@/app/ui/button';


import { SignUp } from '../../../lib/actions';
import { redirect } from 'next/navigation';

import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
Expand Down Expand Up @@ -40,6 +41,7 @@ export default function SignupPage() {
const router = useRouter();

const onSubmit = async (data: SignUp) => {
router.push("/dashboard")
const resp = await SignUp(data.first_name, data.last_name, data.email, data.password, data.confirm_password);
if (resp) {
setErrors(resp.error);
Expand Down
64 changes: 48 additions & 16 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const UserUpdateSchema = z.object({
major: z.string().min(1, "Field cannot be empty"),
short_answer: z.string().min(1, "Field cannot be empty"),
shirt_size: z.string().min(1, "Field cannot be empty"),
hackathon_count: z.number(),
hackathon_count: z.string(),
dietary_restrictions: z.string().min(1, "Field cannot be empty"),
special_needs: z.string().min(1, "Field cannot be empty"),
age: z.string().min(1, "Field cannot be empty"),
Expand Down Expand Up @@ -143,18 +143,13 @@ export default function Dashboard() {

const resumeData = new FormData();
resumeData.set('file', pdf as File);
const resp = await UploadResume(resumeData);
//const resp = await UploadResume(resumeData);


if (resp.error.length > 0) {
alert("There was an error uploading your resume. Please try again. If the problem persists, please email rnd@hackru.org");
}
}

const resp = await UpdateSelf(otherData);
//const resp = await UpdateSelf(otherData);
setSavingUserProfile(false);
if (resp.length > 0) {
setUserProfileSubmitText("Failed!");
}

setUserProfileSubmitText("Saved!");
}
Expand All @@ -165,7 +160,7 @@ export default function Dashboard() {
try {
const data = new FormData();
data.set('file', waiverFile);
await UploadWaiver(data);
//await UploadWaiver(data);

trigger('phone_number', { shouldFocus: true });
if (Object.keys(errors).length === 0) {
Expand Down Expand Up @@ -226,14 +221,51 @@ export default function Dashboard() {
async function fetchUser() {
try {
const data = await getSelf();
setUserData(data.response);
const resumeInfo = await GetResume();
if (resumeInfo.exists) {
setResumeExists(true);
//setUserData(data.response);
setUserData( {
email:"test@test.org",
role: {
hacker: true,
volunteer: false,
judge: false,
sponsor: false,
mentor: false,
organizer: false,
director: false,
},
votes: 0,
github: 'testgithub',
major: 'Computer Science',
short_answer: 'Things',
shirt_size: 'Unisex M',
first_name: 'Test',
last_name: 'User',
dietary_restrictions: '',
special_needs: 'No',
date_of_birth: '2000-01-01',
school: 'Rutgers, The State University of New Jersey',
grad_year: '2026',
gender: 'Prefer not to say',
registration_status: 'unregistered',
level_of_study: 'University (Undergraduate)',
day_of: {
checkIn: false,
},
token: ['faketoken'],
country_of_residence: 'US',
ethnicity: 'Prefer not to say',
hackathon_count: '1',
phone_number: '1234567890',
how_you_heard_about_hackru: 'Mailing List',
reasons: 'Learn new skills',
}
)


setResumeExists(false);


const haswaiver = await GetWaiverInfo();
setWaiverState(haswaiver.exists);
setWaiverState(false);
// setLoading(false);
} catch (error) {
console.log(error);
Expand Down
1 change: 1 addition & 0 deletions app/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export async function UpdateSelf(data: any): Promise<string> {
export async function RegisterSelf() {
const session = await auth();
console.log('Register Self');
return;
if (session?.user && session?.user?.email) {
const resp = await SetUser(
{ registration_status: 'registered' },
Expand Down
1 change: 1 addition & 0 deletions auth.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const authConfig = {
},
callbacks: {
authorized({ auth, request: { nextUrl } }) {
return true;
const isLoggedIn = !!auth?.user;
const isOnDashboard = nextUrl.pathname.startsWith('/dashboard');
if (isOnDashboard) {
Expand Down

0 comments on commit dfadeb2

Please sign in to comment.