From d3eb988cc58c8beafc7843b2f2c96fecd451827b Mon Sep 17 00:00:00 2001
From: YongJae <sdc689@gmail.com>
Date: Mon, 9 Dec 2019 20:35:49 +0900
Subject: [PATCH] Error, UI fixed

---
 backend/routes/transaction.js                 |  8 +-
 frontend/src/App.vue                          | 12 +--
 frontend/src/components/BookSearchPage.vue    | 18 +++-
 frontend/src/components/Buy.vue               |  4 +-
 frontend/src/components/Sell.vue              |  4 +-
 frontend/src/components/login/Login.vue       | 38 +++------
 frontend/src/components/login/SignUp.vue      | 82 +++++--------------
 .../components/profilecomponent/buylist.vue   | 20 +----
 .../components/profilecomponent/sellist.vue   | 11 +--
 9 files changed, 63 insertions(+), 134 deletions(-)

diff --git a/backend/routes/transaction.js b/backend/routes/transaction.js
index c57c23c..2e55298 100644
--- a/backend/routes/transaction.js
+++ b/backend/routes/transaction.js
@@ -32,7 +32,7 @@ router.post("/cancel", async (req, res) => {
           console.error(err);
           return;
         }
-        transaction.buyerId = "";
+        transaction.buyerId = null;
         transaction.on_transaction = false;
         transaction.save();
         res.json({ result: true });
@@ -43,7 +43,7 @@ router.post("/cancel", async (req, res) => {
   }
 });
 
-router.post("/success", async (req, res) => {
+router.post("/end", async (req, res) => {
   console.log("POST - success start");
   var sess = req.session;
   var req_bookTitle = req.body.bookTitle;
@@ -68,8 +68,6 @@ router.post("/success", async (req, res) => {
           book.stock--;
           book.save();
         });
-        // transaction.on_transaction = "";
-        // transaction.save();
         res.json({ result: true });
       }
     );
@@ -119,7 +117,7 @@ router.post("/sell", async (req, res) => {
 
       var transaction = new Transaction();
       transaction.sellerId = sellerId;
-      transaction.buyerId = "";
+      transaction.buyerId = null;
       transaction.bookTitle = book.title;
       transaction.on_transaction = false;
       book.stock++;
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 8c4c635..a909dcc 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -1,7 +1,7 @@
 <template>
   <div id="app" class="page-container">
     <md-app md-mode="fixed-last">
-      <md-app-toolbar class="md-large md-dense md-primary">
+      <md-app-toolbar class="md-dense md-primary">
         <div class="md-toolbar-row">
           <span class="md-title">MajorBook</span>
         </div>
@@ -15,7 +15,6 @@
             <Logout />
           </div>
         </div>
-
         <div class="md-toolbar-row">
           <md-tabs class="md-primary" style="margin: auto; height: 30px">
             <md-tab id="tab-home" md-label="Home" to="/home"></md-tab>
@@ -67,15 +66,6 @@ export default {
       });
     }
   }
-  // computed: {
-  //   checkLoggedIn() {
-  //     console.log(this.checkSession());
-  //     if (this.checkSession() === true) {
-  //       return true;
-  //     }
-  //     return false;
-  //   }
-  // }
 };
 </script>
 
diff --git a/frontend/src/components/BookSearchPage.vue b/frontend/src/components/BookSearchPage.vue
index 2f2e00d..848dee4 100644
--- a/frontend/src/components/BookSearchPage.vue
+++ b/frontend/src/components/BookSearchPage.vue
@@ -120,8 +120,22 @@ export default {
       grade: null,
       major: null,
       type: null,
-      option1: ["1�숇뀈", "2�숇뀈", "3�숇뀈", "4�숇뀈","�꾪븰��"],
-      option2: ["�뚰봽�몄썾�댄븰怨�", "誘몃뵒�댄븰怨�", "寃쎌젣�숆낵","寃쎌쁺�숆낵","�섑븰怨�","�곗뾽怨듯븰怨�","�ы쉶�숆낵","�꾩옄怨듯븰怨�","湲곌퀎怨듯븰怨�","�좎냼�ш났�숆낵","�섍꼍�덉쟾怨듯븰怨�","�섑븰�꾧났","怨듯넻怨쇰ぉ"],
+      option1: ["1�숇뀈", "2�숇뀈", "3�숇뀈", "4�숇뀈", "�꾪븰��"],
+      option2: [
+        "�뚰봽�몄썾�댄븰怨�",
+        "誘몃뵒�댄븰怨�",
+        "寃쎌젣�숆낵",
+        "寃쎌쁺�숆낵",
+        "�섑븰怨�",
+        "�곗뾽怨듯븰怨�",
+        "�ы쉶�숆낵",
+        "�꾩옄怨듯븰怨�",
+        "湲곌퀎怨듯븰怨�",
+        "�좎냼�ш났�숆낵",
+        "�섍꼍�덉쟾怨듯븰怨�",
+        "�섑븰�꾧났",
+        "怨듯넻怨쇰ぉ"
+      ],
       option3: ["�꾧났�꾩닔", "�꾧났�좏깮", "援먯뼇�좏깮", "湲곗큹怨쇰ぉ"],
       Books: [],
       submit: {
diff --git a/frontend/src/components/Buy.vue b/frontend/src/components/Buy.vue
index 9bfa872..804389d 100644
--- a/frontend/src/components/Buy.vue
+++ b/frontend/src/components/Buy.vue
@@ -34,9 +34,7 @@
         <div class="md-title">�� 梨낆쓣 援щℓ�섏떆寃좎뒿�덇퉴?</div>
       </md-card-header>
       <md-card-actions>
-        <md-button class="md-raised md-primary" v-on:click="buyBook"
-          >援щℓ</md-button
-        >
+        <md-button class="md-raised md-primary" v-on:click="buyBook">援щℓ</md-button>
       </md-card-actions>
     </md-card>
   </div>
diff --git a/frontend/src/components/Sell.vue b/frontend/src/components/Sell.vue
index 4ef1e0c..2a336be 100644
--- a/frontend/src/components/Sell.vue
+++ b/frontend/src/components/Sell.vue
@@ -34,9 +34,7 @@
         <div class="md-title">�� 梨낆쓣 �먮ℓ�섏떆寃좎뒿�덇퉴?</div>
       </md-card-header>
       <md-card-actions>
-        <md-button class="md-raised md-primary" v-on:click="sellBook"
-          >�먮ℓ</md-button
-        >
+        <md-button class="md-raised md-primary" v-on:click="sellBook">�먮ℓ</md-button>
       </md-card-actions>
     </md-card>
   </div>
diff --git a/frontend/src/components/login/Login.vue b/frontend/src/components/login/Login.vue
index 4fb9370..2b6dfa8 100644
--- a/frontend/src/components/login/Login.vue
+++ b/frontend/src/components/login/Login.vue
@@ -9,38 +9,19 @@
           <md-field :class="getValidationClass('id')">
             <label>ID</label>
             <md-input name="ID" id="ID" v-model="user.id" :disabled="sending" />
-            <span class="md-error" v-if="!$v.user.id.required"
-              >The ID is required"</span
-            >
-            <span class="md-error" v-else-if="!$v.user.id.minlength"
-              >�꾩씠�붾뒗 �ㅼ꽢 �먮━ �댁긽�댁뼱�� �⑸땲��.</span
-            >
+            <span class="md-error" v-if="!$v.user.id.required">The ID is required"</span>
+            <span class="md-error" v-else-if="!$v.user.id.minlength">�꾩씠�붾뒗 �ㅼ꽢 �먮━ �댁긽�댁뼱�� �⑸땲��.</span>
           </md-field>
 
           <md-field :class="getValidationClass('password')">
             <label>Password</label>
-            <md-input
-              v-model="user.password"
-              type="password"
-              :disabled="sending"
-            />
-            <span class="md-error" v-if="!$v.user.password.required"
-              >The Password is required</span
-            >
-            <span class="md-error" v-else-if="!$v.user.password.minlength"
-              >鍮꾨�踰덊샇�� �� �먮━ �댁긽�댁뼱�� �⑸땲��.</span
-            >
+            <md-input v-model="user.password" type="password" :disabled="sending" />
+            <span class="md-error" v-if="!$v.user.password.required">The Password is required</span>
+            <span class="md-error" v-else-if="!$v.user.password.minlength">鍮꾨�踰덊샇�� �� �먮━ �댁긽�댁뼱�� �⑸땲��.</span>
           </md-field>
 
-          <md-button
-            class="md-raised md-primary"
-            type="submit"
-            :disabled="sending"
-            >Login</md-button
-          >
-          <md-button class="md-primary" v-on:click="active = false"
-            >Close</md-button
-          >
+          <md-button class="md-raised md-primary" type="submit" :disabled="sending">Login</md-button>
+          <md-button class="md-primary" v-on:click="active = false">Close</md-button>
         </md-content>
       </form>
     </md-dialog>
@@ -134,7 +115,10 @@ export default {
 };
 </script>
 
-<style>
+<style scoped>
+.md-primary {
+  margin: 0;
+}
 .select {
   margin: 15px;
   display: inline-flex;
diff --git a/frontend/src/components/login/SignUp.vue b/frontend/src/components/login/SignUp.vue
index 99fdef7..b12ce01 100644
--- a/frontend/src/components/login/SignUp.vue
+++ b/frontend/src/components/login/SignUp.vue
@@ -8,84 +8,43 @@
           <md-field :class="getValidationClass('name')">
             <label>Name</label>
             <md-input name="name" v-model="user.name" :disabled="sending" />
-            <span class="md-error" v-if="!$v.user.name.required"
-              >The Name is required"</span
-            >
-            <span class="md-error" v-else-if="!$v.user.name.minlength"
-              >�대쫫�� �� �먮━ �댁긽�댁뼱�� �⑸땲��.</span
-            >
+            <span class="md-error" v-if="!$v.user.name.required">The Name is required"</span>
+            <span class="md-error" v-else-if="!$v.user.name.minlength">�대쫫�� �� �먮━ �댁긽�댁뼱�� �⑸땲��.</span>
           </md-field>
 
           <md-field :class="getValidationClass('id')">
             <label for="id">ID</label>
             <md-input name="id" v-model="user.id" :disabled="sending" />
-            <span class="md-error" v-if="!$v.user.id.required"
-              >The ID is required"</span
-            >
-            <span class="md-error" v-else-if="!$v.user.id.minlength"
-              >�꾩씠�붾뒗 �ㅼ꽢 �먮━ �댁긽�댁뼱�� �⑸땲��.</span
-            >
+            <span class="md-error" v-if="!$v.user.id.required">The ID is required"</span>
+            <span class="md-error" v-else-if="!$v.user.id.minlength">�꾩씠�붾뒗 �ㅼ꽢 �먮━ �댁긽�댁뼱�� �⑸땲��.</span>
           </md-field>
 
-          <md-field
-            :md-toggle-password="true"
-            :class="getValidationClass('password')"
-          >
+          <md-field :md-toggle-password="true" :class="getValidationClass('password')">
             <label for="password">Password</label>
-            <md-input
-              name="password"
-              v-model="user.password"
-              type="password"
-              :disabled="sending"
-            />
-            <span class="md-error" v-if="!$v.user.password.required"
-              >The Password is required</span
-            >
-            <span class="md-error" v-else-if="!$v.user.password.minlength"
-              >鍮꾨�踰덊샇�� �� �먮━ �댁긽�댁뼱�� �⑸땲��.</span
-            >
+            <md-input name="password" v-model="user.password" type="password" :disabled="sending" />
+            <span class="md-error" v-if="!$v.user.password.required">The Password is required</span>
+            <span class="md-error" v-else-if="!$v.user.password.minlength">鍮꾨�踰덊샇�� �� �먮━ �댁긽�댁뼱�� �⑸땲��.</span>
           </md-field>
 
           <md-field :class="getValidationClass('email')">
             <label for="email">Email</label>
-            <md-input
-              name="email"
-              type="email"
-              v-model="user.email"
-              :disabled="sending"
-            />
-            <span class="md-error" v-if="!$v.user.email.required"
-              >The email is required</span
-            >
-            <span class="md-error" v-else-if="!$v.user.email.email"
-              >Invalid email</span
-            >
+            <md-input name="email" type="email" v-model="user.email" :disabled="sending" />
+            <span class="md-error" v-if="!$v.user.email.required">The email is required</span>
+            <span class="md-error" v-else-if="!$v.user.email.email">Invalid email</span>
           </md-field>
 
           <md-field :class="getValidationClass('phonenumber')">
             <label for="phonenumber">Phone Number</label>
-            <md-input
-              name="phonenumber"
-              v-model="user.phonenumber"
-              :disabled="sending"
-            />
-            <span class="md-error" v-if="!$v.user.phonenumber.required"
-              >The Phone Number is required</span
-            >
-            <span class="md-error" v-else-if="!$v.user.phonenumber.minlength"
-              >�대��� 踰덊샇�� 10�먮━ �댁긽�댁뼱�� �⑸땲��.</span
-            >
+            <md-input name="phonenumber" v-model="user.phonenumber" :disabled="sending" />
+            <span class="md-error" v-if="!$v.user.phonenumber.required">The Phone Number is required</span>
+            <span
+              class="md-error"
+              v-else-if="!$v.user.phonenumber.minlength"
+            >�대��� 踰덊샇�� 10�먮━ �댁긽�댁뼱�� �⑸땲��.</span>
           </md-field>
 
-          <md-button
-            class="md-raised md-primary"
-            type="submit"
-            :disabled="sending"
-            >Sign Up</md-button
-          >
-          <md-button class="md-primary" v-on:click="active = false"
-            >Close</md-button
-          >
+          <md-button class="md-raised md-primary" type="submit" :disabled="sending">Sign Up</md-button>
+          <md-button class="md-primary" v-on:click="active = false">Close</md-button>
         </md-content>
       </form>
     </md-dialog>
@@ -93,6 +52,9 @@
 </template>
 
 <style scoped>
+.md-primary {
+  margin: 0;
+}
 .select {
   margin: 15px;
   display: inline-flex;
diff --git a/frontend/src/components/profilecomponent/buylist.vue b/frontend/src/components/profilecomponent/buylist.vue
index 9f3af35..141c5a5 100644
--- a/frontend/src/components/profilecomponent/buylist.vue
+++ b/frontend/src/components/profilecomponent/buylist.vue
@@ -7,12 +7,9 @@
       <md-list-item
         v-for="transaction in transactions"
         :key="transaction._id"
-        v-if="transaction.buyerId == userId"
+        v-if="transaction.buyerId == userId && transaction.buyerId != null"
       >
-        <md-button
-          class="md-icon-button md-raised"
-          style="color:#1DDB16;backgroundColor:#1DDB16"
-        >
+        <md-button class="md-icon-button md-raised" style="color:#1DDB16;backgroundColor:#1DDB16">
           <img src="../../assets/book-open-flat.png" />
         </md-button>
         <div class="md-list-item-text">
@@ -51,19 +48,10 @@ export default {
     transactions: [],
     userId: ""
   }),
-  computed: {
-    // buyerTransaction() { - v-for�� computed �덉벐硫� 肄붾뱶 鍮④컙�됰맖, �묐룞�� ��
-    //   return this.transactions.filter(tran => {
-    //     if(this.buyerId === this.userId) {
-    //       return mov;
-    //     }
-    //   })
-    // }
-  },
   methods: {
     cancelTransaction(book_Title) {
       this.$http
-        .post("/api/transaction/success", {
+        .post("/api/transaction/cancel", {
           bookTitle: book_Title
         })
         .then(response => {
@@ -76,7 +64,7 @@ export default {
     },
     successTransaction(book_Title) {
       this.$http
-        .post("/api/transaction/success", {
+        .post("/api/transaction/end", {
           bookTitle: book_Title
         })
         .then(response => {
diff --git a/frontend/src/components/profilecomponent/sellist.vue b/frontend/src/components/profilecomponent/sellist.vue
index 1959577..846e2a5 100644
--- a/frontend/src/components/profilecomponent/sellist.vue
+++ b/frontend/src/components/profilecomponent/sellist.vue
@@ -9,10 +9,7 @@
         :key="transaction._id"
         v-if="transaction.sellerId == userId"
       >
-        <md-button
-          class="md-icon-button md-raised"
-          style="color:#1DDB16;backgroundColor:#1DDB16"
-        >
+        <md-button class="md-icon-button md-raised" style="color:#1DDB16;backgroundColor:#1DDB16">
           <img src="../../assets/book-open-flat.png" />
         </md-button>
         <div class="md-list-item-text">
@@ -54,11 +51,11 @@ export default {
   methods: {
     cancelTransaction(book_Title) {
       this.$http
-        .post("/api/transaction/success", {
+        .post("/api/transaction/end", {
           bookTitle: book_Title
         })
         .then(response => {
-          alert("嫄곕옒瑜� 痍⑥냼�섏��듬땲��.");
+          alert("�먮ℓ瑜� 痍⑥냼�섏��듬땲��.");
           location.reload();
         })
         .catch(error => {
@@ -67,7 +64,7 @@ export default {
     },
     successTransaction(book_Title) {
       this.$http
-        .post("/api/transaction/success", {
+        .post("/api/transaction/end", {
           bookTitle: book_Title
         })
         .then(response => {
-- 
GitLab