From 6f4f0b7a0d5c473f08f9335a4430bf269092a7e2 Mon Sep 17 00:00:00 2001
From: ingrid <ingrimeg@stud.ntnu.no>
Date: Fri, 28 Apr 2023 13:59:45 +0200
Subject: [PATCH] css

---
 src/components/FridgeItem.vue | 18 +++++++++++-------
 src/components/ItemSearch.vue | 21 ++++++++++-----------
 2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/components/FridgeItem.vue b/src/components/FridgeItem.vue
index d7cb9d6..590cbd8 100644
--- a/src/components/FridgeItem.vue
+++ b/src/components/FridgeItem.vue
@@ -33,7 +33,7 @@ export default {
                 return '#EE6D6D';
             }
             else{
-                return 'black';
+                return '#737573';
             }
         },
         getImage(){
@@ -61,7 +61,7 @@ export default {
                 case 3:
                     return "Utgår om tre dager"
                 default:
-                    return "Utgår " + this.actualItem.exp_date
+                    return "Utgår " + this.actualItem.exp_date.split('T')[0]
             }
         }
     },
@@ -82,13 +82,14 @@ export default {
     },
     methods: {
         getDateDifference(){ //returns the difference between two dates
-            const date = this.actualItem.exp_date.split('.');//todo
-            const dateFormat = date[1] + "/" + date [0]+ "/"+date[2];
-            const expDate = new Date(dateFormat);
+            let date = this.actualItem.exp_date.split('T')[0];
+
+            const epDate = new Date(date);
+            const expDate= Date.parse(epDate)
             const today = new Date();
             const ms = expDate-today;
             const numOfDays = Math.ceil(ms/(86400000))
-
+            console.log(numOfDays)
             return numOfDays;
         },
       appleBtnPressed(){
@@ -114,16 +115,19 @@ export default {
 }
 
 #fridgeItemName {
-    font-weight: bold;
+    font-weight: normal;
     font-size: 1.2em;
 }
 
 
 img {
     width: 3rem;
+    height: 3em;
     border-radius: 50%;
     background-color: #00663C;
     margin-right:.6em;
+    object-fit: cover;
+
 
 }
 
diff --git a/src/components/ItemSearch.vue b/src/components/ItemSearch.vue
index 8083ed8..f643d34 100644
--- a/src/components/ItemSearch.vue
+++ b/src/components/ItemSearch.vue
@@ -18,6 +18,7 @@
 
 <script>
 import {API} from "@/util/API";
+import router from "@/router";
 
 export default {
     name: "itemSearch",
@@ -33,21 +34,19 @@ export default {
     methods: {
         async search() {
             this.searchResult = await API.searchItems(this.itemSearch);
-            this.selectedItem= this.searchResult[0];
+            this.selectedItem = this.searchResult[0];
+
         },
         addToFridge(){
             const num = this.numOfItemsToAdd;
+            API.addToFridge(
+                {
+                    "itemId": Number(this.selectedItem.id),
+                    "amount":
+                        {
+                            "quantity": this.selectedItem.amount.quantity*num,
+                            "unit": this.selectedItem.amount.unit}}).then(()=> router.push('/myFridge'))
 
-            /*const ingredient = {
-            {itemId: 123,
-                amount: this.selectedItem.amount}
-            }*/
-
-            //const request = [{ingredient}]
-            //const request = [{ingredient_id: ingred},{ingredient: ingred}]
-            //const request = [{ingredient: JSON.stringify(ingred)}]
-            //console.log(request)
-            API.addToFridge({"itemId": 1, "amount": {"quantity": this.selectedItem.amount.quantity,"unit": this.selectedItem.amount.unit}})
         }
     }
 }
-- 
GitLab