update,
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
.invitation-container {
|
||||
height: 85vh;
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.invitation-frame {
|
||||
width: 80%;
|
||||
height: 90%;
|
||||
background-color: #f9f9da;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.event-name-container,
|
||||
.datetime-container,
|
||||
.venue-container,
|
||||
.join-button-container {
|
||||
font-size: 20px;
|
||||
font-family: 'Calibri';
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.event-name-container,
|
||||
.join-button-container {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.venue-container,
|
||||
.datetime-container {
|
||||
margin: 20px 40px;
|
||||
}
|
||||
|
||||
.event-name-container {
|
||||
font-size: 50px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#join-event-button {
|
||||
font-size: 20px;
|
||||
color: #293241;
|
||||
font-family: 'Lato', sans-serif;
|
||||
background-color: #f2d492;
|
||||
padding: 10px 20px 10px 20px;
|
||||
border-radius: 20px;
|
||||
margin: 18px;
|
||||
min-width: 110px;
|
||||
border: none;
|
||||
box-shadow: 0px 1px 12px #f2d492;
|
||||
}
|
||||
|
||||
.content-container {
|
||||
height: 50%;
|
||||
width: 90%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css"
|
||||
integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<link rel="stylesheet" href="./invitation.css" />
|
||||
<title>Invitation</title>
|
||||
</head>
|
||||
|
||||
<body style="display: none">
|
||||
<div class="navbar-container container">
|
||||
<!-- NAVBAR: to be loaded with js -->
|
||||
</div>
|
||||
|
||||
<div class="invitation-container">
|
||||
<div class="invitation-frame">
|
||||
<div class="event-name-container"></div>
|
||||
<div class="content-container">
|
||||
<div class="datetime-container"></div>
|
||||
<div class="venue-container"></div>
|
||||
</div>
|
||||
<div class="join-button-container">
|
||||
<button id="join-event-button" type="submit">Join Event Now</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
<script type="module" src="./invitation.js"></script>
|
||||
</body>
|
||||
</html>
|
107
_tecky/party-planner/backend/public/invitationPage/invitation.js
Normal file
107
_tecky/party-planner/backend/public/invitationPage/invitation.js
Normal file
@@ -0,0 +1,107 @@
|
||||
import { addNavbar } from '/functions/addNavbar.js';
|
||||
import { loadName } from '/functions/loadName.js';
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
await checkInvitationValidity();
|
||||
});
|
||||
|
||||
async function checkInvitationValidity() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const eventId = params.get('event-id');
|
||||
const token = params.get('token');
|
||||
const res = await fetch(`/events/invitation/validation/${eventId}/${token}`, {
|
||||
method: 'POST'
|
||||
});
|
||||
const result = await res.json();
|
||||
if (result.status) {
|
||||
addNavbar();
|
||||
await loadName();
|
||||
|
||||
// Load invitation page content
|
||||
document.querySelector('.event-name-container').innerHTML = `
|
||||
<div>
|
||||
🎉 ${result.eventDetail.name}
|
||||
</div>
|
||||
`;
|
||||
|
||||
let dateString = '';
|
||||
if (!result.eventDetail.start_datetime) {
|
||||
dateString += 'To Be Confirmed';
|
||||
} else {
|
||||
dateString += `
|
||||
<div class="subtitle">
|
||||
Start
|
||||
</div>
|
||||
<div>
|
||||
${new Date(result.eventDetail.start_datetime)
|
||||
.toLocaleString('en-US', { hour12: false })
|
||||
.replace(', ', ' ')
|
||||
.slice(0, -3)}
|
||||
</div>
|
||||
<div class="subtitle">
|
||||
End
|
||||
</div>
|
||||
<div>
|
||||
${new Date(result.eventDetail.end_datetime).toLocaleString('en-US', { hour12: false }).replace(', ', ' ').slice(0, -3)}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
document.querySelector('.datetime-container').innerHTML = `
|
||||
<div class="title">
|
||||
Date & Time
|
||||
</div>
|
||||
<div>
|
||||
${dateString}
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.querySelector('.venue-container').innerHTML = `
|
||||
<div class="title">
|
||||
Venue
|
||||
</div>
|
||||
<div>
|
||||
${result.eventDetail.venue ? result.eventDetail.venue : 'To Be Confirmed'}
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.style.display = 'block';
|
||||
} else {
|
||||
if (result.login) {
|
||||
alert('Invitation link is invalid or expired!');
|
||||
window.location.href = '/index.html';
|
||||
} else {
|
||||
alert('Please log in or register to join event!');
|
||||
window.location.href = `/?event-id=${eventId}&token=${token}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelector('#join-event-button').addEventListener('click', async () => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const eventId = params.get('event-id');
|
||||
const token = params.get('token');
|
||||
const res = await fetch(`/events/invitation/participation/${eventId}/${token}`, {
|
||||
method: 'POST'
|
||||
});
|
||||
const result = await res.json();
|
||||
if (result.status) {
|
||||
alert('You have successfully joined the event!');
|
||||
window.location.href = `/eventSummary/event.html?event-id=${eventId}&is-creator=0`;
|
||||
} else {
|
||||
if (result.login) {
|
||||
if (result.isCreator) {
|
||||
alert('You are already a creator of the event, no need to join again!');
|
||||
window.location.href = `/eventSummary/event.html?event-id=${eventId}&is-creator=1`;
|
||||
} else if (result.joined) {
|
||||
alert('You have already joined the event!');
|
||||
window.location.href = `/eventSummary/event.html?event-id=${eventId}&is-creator=0`;
|
||||
} else {
|
||||
alert('Invitation link is invalid or expired!');
|
||||
window.location.href = '/index.html';
|
||||
}
|
||||
} else {
|
||||
alert('Please log in or register to join event!');
|
||||
window.location.href = `/?event-id=${eventId}&token=${token}`;
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user