|
|
@@ -1,6 +1,6 @@
|
|
|
"use strict";
|
|
|
|
|
|
-import {fetchWithToken, parseOrRedirect} from "./utils.js";
|
|
|
+import {fetchRegular, fetchWithToken, parseOrRedirect} from "./utils.js";
|
|
|
|
|
|
const appointmentErrorParagraph = document.getElementById("appointment-error");
|
|
|
const appointmentSuccessParagraph = document.getElementById("appointment-success");
|
|
|
@@ -12,7 +12,7 @@ const endDateInput = document.getElementById('endDate');
|
|
|
const placeInput = document.getElementById('place');
|
|
|
|
|
|
|
|
|
-window.addEventListener("load", async function() {
|
|
|
+window.addEventListener("load", async function () {
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
|
const appointment = urlParams.get('appointment');
|
|
|
|
|
|
@@ -46,7 +46,14 @@ async function displayAppointment(data) {
|
|
|
async function loadAppointment(appointment) {
|
|
|
let options = {method: 'GET', headers: {'User-Agent': 'insomnia/10.0.0'}};
|
|
|
|
|
|
- const response = await fetch(`/api/schedule?appointmentId=${appointment}&isUser=true`, options)
|
|
|
+ console.log(window.location.host);
|
|
|
+
|
|
|
+ const searchParams = new URLSearchParams({
|
|
|
+ appointmentId: appointment,
|
|
|
+ isUser: true
|
|
|
+ });
|
|
|
+
|
|
|
+ const response = await fetchRegular("/api/schedule?" + searchParams.toString(), options)
|
|
|
.catch(err => console.error('error:' + err));
|
|
|
|
|
|
const js = await parseOrRedirect(response);
|
|
|
@@ -74,7 +81,7 @@ async function createAppointment() {
|
|
|
}
|
|
|
|
|
|
async function setAppointment(endpoint, appointment) {
|
|
|
- const { title, description, dueDate, startDate, endDate, place } = getParameters();
|
|
|
+ const {title, description, dueDate, startDate, endDate, place} = getParameters();
|
|
|
|
|
|
if (!title || !description || !dueDate || !startDate || !endDate) {
|
|
|
appointmentSuccessParagraph.innerText = "";
|
|
|
@@ -100,7 +107,11 @@ async function setAppointment(endpoint, appointment) {
|
|
|
appointmentSuccessParagraph.innerText = "";
|
|
|
appointmentErrorParagraph.innerText = js["message"];
|
|
|
} else {
|
|
|
- const path = `/html/schedule.html?appointment=${js["id"]}`;
|
|
|
+ const searchParams = new URLSearchParams({
|
|
|
+ appointment: js["id"],
|
|
|
+ });
|
|
|
+
|
|
|
+ const path = '/html/schedule.html?' + searchParams.toString();
|
|
|
appointmentErrorParagraph.innerText = "";
|
|
|
appointmentSuccessParagraph.innerText = "Appointment created successfully. The share link " +
|
|
|
"was copied to your clipboard";
|