This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into env-support
- Loading branch information
Showing
8 changed files
with
17 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,6 @@ export default function Availability() { | |
const location = useLocation(); | ||
const { eventName2, isUpdating } = location.state || {}; | ||
|
||
console.log(eventName2); | ||
console.log(isUpdating); | ||
|
||
console.log('RAN'); | ||
|
||
function getCookieValue(cookieName) { | ||
const cookies = document.cookie.split('; '); | ||
for (const cookie of cookies) { | ||
|
@@ -29,15 +24,12 @@ export default function Availability() { | |
} | ||
|
||
let x = document.cookie; | ||
console.log(x); | ||
|
||
const eventCode = getCookieValue('code'); | ||
var userEmail = getCookieValue('login_email'); | ||
var userPW = getCookieValue('login_password'); | ||
var guestEmail = getCookieValue('guest_email'); | ||
var guestPW = getCookieValue('guest_password'); | ||
console.log('Code cookie:', eventCode); | ||
console.log('email', userEmail); | ||
|
||
const { isDarkMode, toggleTheme } = useTheme(); | ||
|
||
|
@@ -171,18 +163,12 @@ export default function Availability() { | |
async function handleEventDetails() { | ||
try { | ||
const data = { | ||
// email: '[email protected]', | ||
// password: '123', | ||
event_code: eventCode, | ||
}; | ||
|
||
console.log('Before user check:', data); | ||
|
||
// Wait for check_user to complete | ||
await check_user(data); | ||
|
||
console.log('After user check:', data); | ||
|
||
// Proceed with fetch after check_user completes | ||
const response = await fetch( | ||
import.meta.env.VITE_API_HOST + '/event_details', | ||
|
@@ -200,7 +186,6 @@ export default function Availability() { | |
} | ||
|
||
const eventData = await response.json(); | ||
console.log('Event details:', eventData); | ||
|
||
// Update state based on the event details | ||
setEventDetails(eventData); | ||
|
@@ -211,7 +196,7 @@ export default function Availability() { | |
} | ||
|
||
if (eventCode) { | ||
handleEventDetails(); // Call the async function | ||
handleEventDetails(); | ||
} | ||
}, [eventCode]); | ||
|
||
|
@@ -230,16 +215,11 @@ export default function Availability() { | |
} = data; | ||
setEventName(title); | ||
|
||
console.log(event_type); | ||
console.log(all_dates[0].weekdayName); | ||
|
||
var daysArray = []; | ||
const weekdaysArray = []; | ||
if (event_type == 'date_range') { | ||
const startDate = new Date(start_date + ' ' + start_time); | ||
const endDate = new Date(end_date + ' ' + end_time); | ||
console.log(startDate); | ||
console.log(endDate); | ||
|
||
// Format the dates to the desired format | ||
const formattedStartDate = startDate.toLocaleDateString('en-US', { | ||
|
@@ -272,7 +252,6 @@ export default function Availability() { | |
} else { | ||
setIsGenericWeek(true); | ||
setEventDates(`${start_day} - ${end_day}`); | ||
console.log('here'); | ||
|
||
const abbreviations = all_dates[0].weekdayName.map((day) => { | ||
switch (day) { | ||
|
@@ -315,7 +294,6 @@ export default function Availability() { | |
setTotalDays(daysArray.length); | ||
}; | ||
|
||
console.log('ALLDAYS', allDays); | ||
const displayedDays = allDays.slice( | ||
currentPage * daysPerPage, | ||
(currentPage + 1) * daysPerPage | ||
|
@@ -326,12 +304,9 @@ export default function Availability() { | |
(currentPage + 1) * daysPerPage | ||
); | ||
|
||
console.log('CurrentPage: ', currentPage); | ||
console.log('TOTAL DAYS: ', totalDays); | ||
|
||
useEffect(() => { | ||
console.log('Availability updated:', availability); | ||
}, [availability]); | ||
// useEffect(() => { | ||
// console.log('Availability updated:', availability); | ||
// }, [availability]); | ||
|
||
const goToPrevPage = () => { | ||
if (currentPage > 0) { | ||
|
@@ -411,7 +386,6 @@ export default function Availability() { | |
return; | ||
} | ||
const transposedAvailability = transpose(availability); | ||
console.log(transposedAvailability); | ||
|
||
var credentials = { | ||
event_code: eventCode, | ||
|
@@ -420,13 +394,8 @@ export default function Availability() { | |
}; | ||
|
||
if (isUpdating === true) { | ||
console.log('UPDATINGGGGGGGGGGGGGGGGGGGG'); | ||
console.log(availability); | ||
|
||
check_user(credentials); | ||
|
||
console.log(credentials); | ||
|
||
try { | ||
const response = await fetch( | ||
import.meta.env.VITE_API_HOST + '/update_availability', | ||
|
@@ -438,15 +407,13 @@ export default function Availability() { | |
body: JSON.stringify(credentials), | ||
} | ||
); | ||
console.log(credentials); | ||
|
||
if (response.ok) { | ||
const result = await response.json(); | ||
console.log(result.message); | ||
if (result.message.localeCompare('Availability updated') === 0) { | ||
navigate('/dashboard'); | ||
} else { | ||
console.log(result); | ||
} | ||
|
||
// session management with dashboard | ||
} else { | ||
console.error('Failed to record time:', response.statusText); | ||
|
@@ -455,15 +422,10 @@ export default function Availability() { | |
console.error('Error:', error); | ||
} | ||
} else { | ||
console.log('Ran this random thing'); | ||
// console.log(name); | ||
// console.log(availability); | ||
|
||
if (userEmail == null && userPW == null) { | ||
if (guestEmail != null && guestPW != null) { | ||
credentials.guest_id = parseInt(guestEmail); | ||
credentials.guest_password = guestPW; | ||
console.log('SET GUEST STUFF'); | ||
} else { | ||
await fetch(import.meta.env.VITE_API_HOST + '/create_guest', { | ||
method: 'GET', | ||
|
@@ -475,15 +437,12 @@ export default function Availability() { | |
.then((data) => { | ||
credentials.guest_id = data.guest_id; | ||
credentials.guest_password = data.guest_password; | ||
console.log(credentials.guest_id); | ||
}); | ||
} | ||
console.log('HEREEEEFORTHEUSERAND'); | ||
} else { | ||
credentials.email = userEmail; | ||
credentials.password = userPW; | ||
} | ||
console.log(credentials); | ||
try { | ||
const response = await fetch( | ||
import.meta.env.VITE_API_HOST + '/add_availability', | ||
|
@@ -495,17 +454,14 @@ export default function Availability() { | |
body: JSON.stringify(credentials), | ||
} | ||
); | ||
console.log(credentials); | ||
|
||
if (response.ok) { | ||
const result = await response.json(); | ||
|
||
if (result.message != 'Availability added') { | ||
handleError(result.message); | ||
return; | ||
} | ||
console.log('Time Set Successfully', result); | ||
|
||
// session management with dashboard | ||
navigate('/results', { state: { eventCode, eventName } }); | ||
} else { | ||
console.error('Failed to record time:', response.statusText); | ||
|
@@ -516,8 +472,6 @@ export default function Availability() { | |
} | ||
}; | ||
|
||
console.log('EVENT DATES', eventDates); | ||
|
||
return ( | ||
<div | ||
className={`relative flex flex-col min-h-screen lg:h-[100vh] p-4 ${isDarkMode ? 'bg-[#3E505B]' : 'bg-[#F5F5F5]'}`} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,8 +153,6 @@ export default function CreateEvent() { | |
|
||
const get_event_data = async () => { | ||
const data = { | ||
// email: '[email protected]', | ||
// password: '123', | ||
title: eventName, | ||
description: eventDescription, | ||
duration: parseInt(selectedInterval), | ||
|
@@ -164,7 +162,6 @@ export default function CreateEvent() { | |
|
||
const cookies = document.cookie; // Get all cookies as a single string | ||
const cookieObj = {}; | ||
console.log('Ran here 1'); | ||
|
||
cookies.split(';').forEach((cookie) => { | ||
const [key, value] = cookie.split('=').map((part) => part.trim()); | ||
|
@@ -212,8 +209,6 @@ export default function CreateEvent() { | |
} | ||
} | ||
|
||
console.log('data sent:', data); | ||
|
||
if (selectDaysOfWeek) { | ||
data.event_type = 'generic_week'; | ||
data.start_day = selectedStartDay.toLowerCase(); | ||
|
@@ -222,13 +217,8 @@ export default function CreateEvent() { | |
data.event_type = 'date_range'; | ||
data.start_date = startCalendarDay; | ||
data.end_date = endCalendarDay; | ||
console.log(data.start_date); | ||
console.log(data.end_date); | ||
} | ||
|
||
console.log(data); | ||
console.log('works'); | ||
|
||
try { | ||
const response = await fetch( | ||
import.meta.env.VITE_API_HOST + '/create_event', | ||
|
@@ -243,11 +233,8 @@ export default function CreateEvent() { | |
|
||
if (response.ok) { | ||
const responseData = await response.json(); | ||
console.log('Response Data:', responseData); | ||
console.log(responseData); | ||
|
||
if (responseData.message != 'Event created') { | ||
console.log('ERROR'); | ||
handleError(responseData.message); | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ function deleteAllCookies() { | |
} | ||
|
||
const check_user = async (dataToUse) => { | ||
const cookies = document.cookie; // Get all cookies as a single string | ||
const cookies = document.cookie; | ||
const cookieObj = {}; | ||
|
||
cookies.split(';').forEach((cookie) => { | ||
|
@@ -27,7 +27,7 @@ const check_user = async (dataToUse) => { | |
const parsedValue = JSON.parse(decodeURIComponent(value)); | ||
cookieObj[key] = String(parsedValue); | ||
} catch { | ||
cookieObj[key] = String(decodeURIComponent(value)); // Handle plain strings | ||
cookieObj[key] = String(decodeURIComponent(value)); | ||
} | ||
} | ||
}); | ||
|
@@ -86,6 +86,7 @@ export default function Dashboard() { | |
} | ||
document.body.removeChild(textArea); | ||
|
||
// Please uncomment this when the server does have HTTPS certifications | ||
// try { | ||
// navigator.clipboard.writeText(event.code).then(() => { | ||
// setNotification('Link copied to clipboard'); | ||
|
@@ -107,29 +108,21 @@ export default function Dashboard() { | |
}; | ||
|
||
const handleEditEvent = async (event) => { | ||
console.log('ran'); | ||
console.log(event); | ||
try { | ||
const codeChange = `code=${encodeURIComponent(JSON.stringify(event.code))}; path=/;`; | ||
document.cookie = codeChange; | ||
navigate('/availability', { | ||
state: { eventName2: event.title, isUpdating: true }, | ||
}); | ||
// console.log(event); | ||
// navigate(data.editUrl); | ||
} catch (error) { | ||
console.error('Error editing availability:', error); | ||
} | ||
}; | ||
|
||
const get_all_events = async () => { | ||
const data = { | ||
// email: '[email protected]', | ||
// password: '123', | ||
}; | ||
const data = {}; | ||
|
||
check_user(data); | ||
console.log(data); | ||
|
||
try { | ||
const response = await fetch( | ||
|
@@ -145,8 +138,6 @@ export default function Dashboard() { | |
|
||
if (response.ok) { | ||
const result = await response.json(); | ||
console.log('Events retrieved successfully', result); | ||
console.log(result); | ||
const createdEvents = result.my_events; | ||
const participatingEvents = result.other_events; | ||
|
||
|
@@ -162,11 +153,10 @@ export default function Dashboard() { | |
} | ||
|
||
setArrayTwo(alpha); | ||
// console.log(mockIndividualEvents); | ||
|
||
id = 1; | ||
var beta = []; | ||
for (const [key, value] of Object.entries(participatingEvents)) { | ||
console.log(key, value); | ||
const myDictionary = {}; | ||
myDictionary.id = id; | ||
myDictionary.code = key; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.