Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
dashboard cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mirmirmirr committed Dec 10, 2024
1 parent f13ecb8 commit 1d00e5f
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/pages/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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));
}
}
});
Expand Down Expand Up @@ -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');
Expand All @@ -107,29 +108,22 @@ 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',
};

check_user(data);
console.log(data);

try {
const response = await fetch(
Expand All @@ -145,8 +139,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;

Expand All @@ -162,11 +154,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;
Expand Down

0 comments on commit 1d00e5f

Please sign in to comment.