Эх сурвалжийг харах

Merge remote-tracking branch 'origin/feature/basic/structure' into feature/basic/structure

Liontix 11 сар өмнө
parent
commit
8641bc7dc1

+ 2 - 0
public/html/appointments.html

@@ -8,6 +8,7 @@
     <script type="module" src="../javascripts/appointments.js" async></script>
     <script type="module" src="../javascripts/navbar.js" async></script>
     <link rel="stylesheet" href="../stylesheets/style.css">
+    <link rel="stylesheet" href="../stylesheets/screen.css">
     <link rel="stylesheet" href="../stylesheets/navbar.css">
     <link rel="stylesheet" href="../stylesheets/tables.css">
     <link rel="stylesheet" href="../stylesheets/appointments.css">
@@ -21,6 +22,7 @@
         <li><a href="#" id="logout-button">Logout</a></li>
     </ul>
 </nav>
+<h1 class="msg-screen-size">Please turn your screen or switch to a device with a larger screen</h1>
 <div class="content hidden" id="content">
     <div class="container">
         <h2 class="heading">Appointments</h2>

+ 2 - 0
public/html/bookings.html

@@ -8,6 +8,7 @@
     <script type="module"src="../javascripts/bookings.js" async></script>
     <script type="module" src="../javascripts/utils.js" async></script>
     <link rel="stylesheet" href="../stylesheets/style.css">
+    <link rel="stylesheet" href="../stylesheets/screen.css">
     <link rel="stylesheet" href="../stylesheets/navbar.css">
     <link rel="stylesheet" href="../stylesheets/tables.css">
     <link rel="stylesheet" href="../stylesheets/bookings.css">
@@ -21,6 +22,7 @@
         <li><a href="#" id="logout-button">Logout</a></li>
     </ul>
 </nav>
+<h1 class="msg-screen-size">Please turn your screen or switch to a device with a larger screen</h1>
 <div class="content">
 <div class="container">
     <h1>Appointment Details</h1>

+ 3 - 3
public/html/schedule.html

@@ -17,7 +17,6 @@
     <h3 id="title"></h3>
     <h4 id="place"></h4>
     <p id="description"></p>
-
     <div>
         <div class="input-group">
             <label for="email">Email</label>
@@ -47,9 +46,10 @@
             <input type="text" id="time-span" name="timeSpan" value="10:00 AM to 12:00 PM" readonly>
         </div>
         <button type="submit" id="btn-attend" class="btn-submit">Attend</button>
-        <p class="msg-error" id="appointment-error"></p>
-        <p class="msg-success" id="appointment-success"></p>
+
     </div>
+    <p class="msg-error" id="appointment-error"></p>
+    <p class="msg-success" id="appointment-success"></p>
 </div>
 </div>
 </body>

+ 1 - 0
public/javascripts/appointments.js

@@ -126,6 +126,7 @@ async function fetchAppointments() {
 
     const js = await parseOrRedirect(response);
 
+    if (js.length === 0) return;
     renderAppointments(js);
 }
 

+ 1 - 2
public/javascripts/auth.js

@@ -19,8 +19,6 @@ window.addEventListener("load", function () {
 });
 
 async function sendAuthRequest(type) {
-    console.log(emailInput.value);
-    console.log(passwordInput.value);
     const response = await fetchRegular(
         "/api/auth/" + type,
         {
@@ -39,6 +37,7 @@ async function sendAuthRequest(type) {
     const response_json = await response.json();
 
     if (response.status === 200) {
+        console.log("success")
         localStorage.setItem("token", response_json["token"]);
         window.location.replace("/html/appointments.html");
     } else {

+ 0 - 1
public/stylesheets/bookings.css

@@ -28,7 +28,6 @@
 /* Appointment Info */
 .appointment-info {
     display: grid;
-    gap: 5px;
     font-size: var(--font-size);
     color: var(--text-color);
 }

+ 13 - 0
public/stylesheets/screen.css

@@ -0,0 +1,13 @@
+.msg-screen-size {
+    visibility: hidden;
+}
+
+@media (max-width: 400px) {
+    .msg-screen-size {
+        visibility: visible;
+    }
+
+    .content, .navbar {
+        visibility: hidden;
+    }
+}

+ 2 - 1
public/stylesheets/style.css

@@ -50,4 +50,5 @@ button {
 .msg-success {
   color: var(--success-message-color);
   margin-top: 10px;
-}
+}
+

+ 3 - 3
routes/auth.js

@@ -46,7 +46,7 @@ router.post('/login', function (req, res) {
             if (!user) {
                 return res.status(422).json({ message: 'user not found' });
             }
-
+            console.log(user);
             bcrypt.compare(password, user.password, function (err, result) {
                 if (result) {
                     res.json({ token: generateToken(user) });
@@ -80,14 +80,14 @@ router.post('/register', async function (req, res) {
         if (existingUser) {
             return res.status(403).json({ message: 'user already exists' });
         }
-
         // Hash the password
         bcrypt.hash(password, saltRounds, async function (err, hash) {
             if (err) {
                 return res.status(500).json({ error: err.message });
             } else if (hash) {
                 // Insert user into database and generate token
-                const user = await User.collection.insertOne({ email: email, password: hash });
+                await User.collection.insertOne({ email: email, password: hash });
+                const user = await User.findOne({ email: email });
                 return res.json({ token: generateToken(user) });
             }
         });

+ 2 - 2
routes/members.js

@@ -47,7 +47,7 @@ router.post('/create', function(req, res, next) {
     const newTask = new Appointment({ user, title, description, dueDate, place, startDate, endDate });
 
     newTask.save()
-        .then(doc => res.json({ "id": `${doc._id}` }))
+        .then(doc => res.json({ "id": doc._id }))
         .catch(err => res.status(500).json({ 'message': err }));
 
 });
@@ -71,7 +71,7 @@ router.post('/modify', function (req, res, next) {
         .then(result => {
             if (result.modifiedCount === 1) {
                 console.log("Successfully updated the document.");
-                res.json({ "success": true });
+                res.json({ "id": appointmentId });
             } else {
                 console.log("Document not updated");
                 res.status(500).json({ 'message': 'Document has not changed' });