From 040eafe651023574e5e1a37365121a8b3c562148 Mon Sep 17 00:00:00 2001
From: henrikburmann <haburmann@gmail.com>
Date: Mon, 2 May 2022 10:13:56 +0200
Subject: [PATCH] Now actually sends time to DB

---
 src/components/RentingComponents/ItemInfo.vue | 31 ++++++++++---------
 src/components/RentingComponents/NewRent.vue  | 10 +++---
 src/router/index.js                           |  2 +-
 3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/components/RentingComponents/ItemInfo.vue b/src/components/RentingComponents/ItemInfo.vue
index 61c4e60..4462235 100644
--- a/src/components/RentingComponents/ItemInfo.vue
+++ b/src/components/RentingComponents/ItemInfo.vue
@@ -44,7 +44,10 @@
         <div class="mt-6">
           <!-- Add in method for displaying user card. Use item.userID on the method -->
           (Placeholder) Add usercard here
-          <UserListItemCard :admin="false" :user="this.item.userID"></UserListItemCard>
+          <UserListItemCard
+            :admin="false"
+            :user="this.item.userID"
+          ></UserListItemCard>
         </div>
         <div>
           <div class="mt-4 space-y-6">
@@ -112,21 +115,21 @@ export default {
     async getItemPictures() {
       let id = this.$router.currentRoute.value.params.id;
       this.images = await getItemPictures(id);
-      
-      if(this.images.length < 1) {
-          let noImage = {
-              src: require('@/assets/default-product.png'),
-              alt: "No image found",
-          };
-          this.pictures.push(noImage);
+
+      if (this.images.length < 1) {
+        let noImage = {
+          src: require("@/assets/default-product.png"),
+          alt: "No image found",
+        };
+        this.pictures.push(noImage);
       } else {
         for (let i = 0; i < this.images.length; i++) {
-            let oneImage = {
-                src: this.images[i].picture,
-                //How do i make this accurate to the image?
-                alt: "An image",
-            };
-            this.pictures.push(oneImage);
+          let oneImage = {
+            src: this.images[i].picture,
+            //How do i make this accurate to the image?
+            alt: "An image",
+          };
+          this.pictures.push(oneImage);
         }
       }
       //TODO fixs so each image get a correct alt text.
diff --git a/src/components/RentingComponents/NewRent.vue b/src/components/RentingComponents/NewRent.vue
index 726fae5..33240c2 100644
--- a/src/components/RentingComponents/NewRent.vue
+++ b/src/components/RentingComponents/NewRent.vue
@@ -46,11 +46,10 @@ export default {
       title: this.newRentBox.title,
       fromTime: this.newRentBox.fromTime,
       toTime: this.newRentBox.toTime,
-      fromTimeMilliseconds: new Date(this.newRentBox.fromTime).getMilliseconds,
-      toTimeMilliseconds: new Date(this.newRentBox.toTime).getMilliseconds,
+      fromTimeMilliseconds: new Date(this.newRentBox.fromTime).valueOf(),
+      toTimeMilliseconds: new Date(this.newRentBox.toTime).valueOf(),
       message: "",
       price: this.newRentBox.price_per_day,
-
     };
   },
   props: {
@@ -71,13 +70,14 @@ export default {
     },
     sendRent: async function () {
       const rent = {
-        // message: this.message,
+        message: this.message,
         listingId: this.newRentBox.listingId,
         renterId: this.newRentBox.renterId,
         isAccepted: false,
         toTime: this.toTimeMilliseconds,
-        fromTime: this.fromTimeMilliseconds,
+        fromTime: this.fromTimeMilliseconds,  
       };
+      
       await postNewRent(rent);
       console.log(rent);
     },
diff --git a/src/router/index.js b/src/router/index.js
index f1b5c56..35301d2 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -103,7 +103,7 @@ const routes = [
     name: "newRent",
     component: () => import("../views/RentingViews/NewRentView.vue"),
   },
-    {
+  {
     beforeEnter: guardRoute,
     path: "/test",
     name: "test",
-- 
GitLab