Skip to content

Commit

Permalink
pr changes: removed comments, added auth guard for carp, automatic dr…
Browse files Browse the repository at this point in the history
…opdown
  • Loading branch information
Saloni Vaishnav committed Sep 11, 2023
1 parent a098afe commit 1ad6b40
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 46 deletions.
47 changes: 6 additions & 41 deletions src/routes/carp/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import Icon from '@iconify/svelte';
import { API_URL } from '../../constants';
import { onMount } from 'svelte';
const major_dict = new Map([
['cs', 'Computer Science'],
Expand All @@ -16,7 +17,6 @@
]);
// DROP DOWNS
// TODO add functionality to fetch majors, grad years, and job interests
let majors = ['Computer Science', 'CS + X', 'Electrical & Computer Engineering', 'Other'];
$: major_filters = new Set<string>();
Expand Down Expand Up @@ -83,7 +83,6 @@
const fetchFilteredAttendees = async (page_to_fetch: number) => {
let response;
try {
// TODO: change url to actual api endpoint
let majors = [...major_filters].join(',').replace('&', 'and');
let years = [...grad_year_filters].join(',')
let jobs = [...job_interest_filters].join(',')
Expand All @@ -99,7 +98,6 @@
cache: 'no-cache'
}
);
// response = await fetch(`${$API_URL}/attendee`);
try {
const jsonResponse = await response.json();
Expand All @@ -121,43 +119,11 @@
const fetchAttendees = async () => {
let response;
// // dummy data for now
// attendees = [
// {
// name: 'Atharva Naik',
// studentInfo : {
// major: 'CS + X',
// graduation: 'Spring 2024',
// },
// job_interest: 'Full-Time',
// email: '[email protected]'
// },
// {
// name: 'Saloni Vaishnav',
// studentInfo : {
// major: 'Computer Science',
// graduation: 'Spring 2025',
// },
// job_interest: 'Internship',
// email: '[email protected]'
// },
// {
// name: 'Bob Jones',
// studentInfo : {
// major: 'Computer Science',
// graduation: 'Spring 2024',
// },
// job_interest: 'Full-Time',
// email: '[email protected]'
// }]
try {
// TODO: change url to actual api endpoint
response = await fetch(`${$API_URL}/carp/filter?majors=&years=&jobs=&page=${1}`, {
credentials: "include",
cache: 'no-cache'
});
// response = await fetch(`${$API_URL}/attendee`);
try {
const jsonResponse = await response.json();
Expand All @@ -176,7 +142,7 @@
}
};
fetchAttendees();
onMount(fetchAttendees);
const fetchURl = async (attendeeId: string) => {
console.log('trying to fetch url for: ' + attendeeId);
Expand All @@ -193,7 +159,6 @@
if (response.ok) {
resume_url = jsonResponse.url;
// opent the url
window.open(resume_url, '_blank');
} else {
console.log(`Request returned an error: ${JSON.stringify(jsonResponse)}`);
Expand Down Expand Up @@ -245,7 +210,7 @@
</div>
</div>

<div
<div
class="bg-gray-900 w-3/12 rounded-lg fixed z-[999] p-5 right-48 duration-300 text-gray-200 center-div overflow-y-auto {show_filters_modal
? 'visible opacity-100'
: 'invisible opacity-0'} max-h-screen"
Expand Down Expand Up @@ -273,7 +238,7 @@
</div>

{#if show_majors}
<div class="fixed">
<div on:mouseleave={() => {show_majors = false}} class="fixed">
<ul class="p-2 bg-opacity-4 rounded-md bg-gray-900">
{#each majors as major}
<li class="flex flex-row hover:text-gray-300">
Expand Down Expand Up @@ -316,7 +281,7 @@
</div>

{#if show_grad_year}
<div class="fixed">
<div on:mouseleave={() => {show_grad_year = false}} class="fixed">
<ul class="p-2 bg-opacity-4 rounded-md bg-gray-900 h-48 overflow-scroll">
{#each grad_years as grad_year}
<li class="flex flex-row hover:text-gray-300">
Expand Down Expand Up @@ -356,7 +321,7 @@
</div>

{#if show_job_interest}
<div class="fixed">
<div on:mouseleave={() => {show_job_interest = false}} class="fixed">
<ul class="p-2 bg-opacity-4 rounded-md bg-gray-900">
{#each job_interests as job_interest}
<li class="flex flex-row hover:text-gray-300">
Expand Down
22 changes: 17 additions & 5 deletions src/routes/carp/+page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// import { error } from '@sveltejs/kit';
import { error } from '@sveltejs/kit';
import { API_URL } from '../../constants';
import type { PageLoad } from './$types';
import { get } from 'svelte/store';

// /** @type {import('./$types').PageLoad} */
// export function load({ params }) {
export const load: PageLoad<void> = async ({ fetch }) => {

const url = get(API_URL);
const check = await fetch(`${url}/auth/access/corporate`, {
credentials: 'include'
});

// throw error(404, 'Not found');
// }
// Not authorized or signed in:
// They don't need to know this is an actual route.
if (check.status == 403 || check.status == 401) {
throw error(404, { message: 'Not found' });
}
};

export const ssr = false;

0 comments on commit 1ad6b40

Please sign in to comment.