diff --git a/backend/routes/transaction.js b/backend/routes/transaction.js index d657063d78f2a9c05151b08bd7fdc63f842e2207..c57c23c0ca733f174d2bd872c1032d8dfbb0210d 100644 --- a/backend/routes/transaction.js +++ b/backend/routes/transaction.js @@ -50,7 +50,7 @@ router.post("/success", async (req, res) => { var userId = sess.userid; try { - await Transaction.remove( + await Transaction.deleteOne( { bookTitle: req_bookTitle, $or: [{ buyerId: userId }, { sellerId: userId }] diff --git a/frontend/src/components/Buy.vue b/frontend/src/components/Buy.vue index 2e0c10755ece72e16a38c73ff22a6f5b3bf8a2cd..9bfa8724c9563fd299719a27eb1997cbe0c5789d 100644 --- a/frontend/src/components/Buy.vue +++ b/frontend/src/components/Buy.vue @@ -34,7 +34,9 @@ <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> @@ -98,6 +100,7 @@ export default { }) .then(response => { alert("�대찓�� �꾩넚 �꾨즺"); + this.$router.push("/home"); }), error => { alert(error.response.data.error); @@ -106,4 +109,4 @@ export default { } } }; -</script> \ No newline at end of file +</script> diff --git a/frontend/src/components/Sell.vue b/frontend/src/components/Sell.vue index ae27fd107a0f76e49e76392abbbc010d073ca05a..4ef1e0c15e71d9ddf7787cfb8e8e3a9442a5a867 100644 --- a/frontend/src/components/Sell.vue +++ b/frontend/src/components/Sell.vue @@ -34,7 +34,9 @@ <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> @@ -69,6 +71,7 @@ export default { }) .then(response => { alert("�먮ℓ ��湲곗뿴�� �깅줉�섏��듬땲��."); + this.$router.push("/home"); }) .catch(error => { alert(error); diff --git a/frontend/src/components/login/Login.vue b/frontend/src/components/login/Login.vue index 6ed1512e14363669779758ffe65fbfc13e30f9c5..4fb93701d43fe026d0c89ca16956d6b91cac4f7f 100644 --- a/frontend/src/components/login/Login.vue +++ b/frontend/src/components/login/Login.vue @@ -1,15 +1,17 @@ <template> <div id="login"> <md-button class="md-primary" v-on:click="active = true">Login</md-button> - - <md-dialog :md-active.sync="active" style="width: 500px; height: 500px"> - <md-dialog-title>Login</md-dialog-title> - <form novalidate @submit.prevent="validateUser"> + + <md-dialog :md-active.sync="active" style="width: 500px; height: 500px"> + <md-dialog-title>Login</md-dialog-title> + <form novalidate @submit.prevent="validateUser"> <md-content> <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-if="!$v.user.id.required" + >The ID is required"</span + > <span class="md-error" v-else-if="!$v.user.id.minlength" >�꾩씠�붾뒗 �ㅼ꽢 �먮━ �댁긽�댁뼱�� �⑸땲��.</span > @@ -17,7 +19,11 @@ <md-field :class="getValidationClass('password')"> <label>Password</label> - <md-input v-model="user.password" type="password" :disabled="sending" /> + <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 > @@ -36,9 +42,8 @@ >Close</md-button > </md-content> - </form> - </md-dialog> - </form> + </form> + </md-dialog> </div> </template> @@ -68,11 +73,10 @@ export default { }, validations: { user: { - id: { + id: { required, minLength: minLength(5) - } - , + }, password: { required, minLength: minLength(3) @@ -80,6 +84,11 @@ export default { } }, methods: { + clearForm() { + this.$v.$reset(); + this.user.id = null; + this.user.password = null; + }, getValidationClass(fieldName) { const field = this.$v.user[fieldName]; if (field) { @@ -107,11 +116,14 @@ export default { alert("success login"); this.active = false; this.sending = false; + this.clearForm(); location.reload(); }, error => { // error 瑜� 蹂댁뿬以� alert(error.response.data.error); + this.sending = false; + this.clearForm(); } ) .catch(error => { diff --git a/frontend/src/components/login/SignUp.vue b/frontend/src/components/login/SignUp.vue index 77a90215892a86d85ea2c90637766b436af843df..99fdef738c63f6a0abbefbcba9aaf8b7e6a32255 100644 --- a/frontend/src/components/login/SignUp.vue +++ b/frontend/src/components/login/SignUp.vue @@ -154,6 +154,14 @@ export default { } }, methods: { + clearForm() { + this.$v.$reset(); + this.user.id = null; + this.user.password = null; + this.user.name = null; + this.user.email = null; + this.user.phonenumber = null; + }, getValidationClass(fieldName) { const field = this.$v.user[fieldName]; if (field) { @@ -177,10 +185,14 @@ export default { if (response.data.result === 0) { alert("Error, please, try again"); this.active = false; + this.clearForm(); + this.sending = false; } if (response.data.result === 1) { alert("Success Sign Up !"); this.active = false; + this.clearForm(); + this.sending = false; } }) .catch(function(error) { diff --git a/frontend/src/components/profilecomponent/buylist.vue b/frontend/src/components/profilecomponent/buylist.vue index 445931b5dee178964825004bdec3161f112327fc..9f3af357a07f8128896da76f9cfb5ce20b961142 100644 --- a/frontend/src/components/profilecomponent/buylist.vue +++ b/frontend/src/components/profilecomponent/buylist.vue @@ -9,13 +9,16 @@ :key="transaction._id" v-if="transaction.buyerId == 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"> - <span> {{transaction.bookTitle}}</span> + <span> {{ transaction.bookTitle }}</span> <span> 援щℓ ��湲곗쨷</span> - <span> �먮ℓ�� �꾩씠��: {{transaction.sellerId}}</span> + <span> �먮ℓ�� �꾩씠��: {{ transaction.sellerId }}</span> </div> <md-button class="md-icon-button md-raised md-accent" @@ -60,7 +63,7 @@ export default { methods: { cancelTransaction(book_Title) { this.$http - .post("/api/transaction/cancel", { + .post("/api/transaction/success", { bookTitle: book_Title }) .then(response => { @@ -105,4 +108,4 @@ export default { display: inline-block; vertical-align: top; } -</style> \ No newline at end of file +</style> diff --git a/frontend/src/components/profilecomponent/sellist.vue b/frontend/src/components/profilecomponent/sellist.vue index cb05be6bda95f453417f93208fa0c063ce69effd..1959577298c1df2e3c77ba8c4fc1df2792eb3ce5 100644 --- a/frontend/src/components/profilecomponent/sellist.vue +++ b/frontend/src/components/profilecomponent/sellist.vue @@ -54,7 +54,7 @@ export default { methods: { cancelTransaction(book_Title) { this.$http - .post("/api/transaction/cancel", { + .post("/api/transaction/success", { bookTitle: book_Title }) .then(response => {