baruser cann add amount to a user
This commit is contained in:
parent
e59429ddd6
commit
9e32270f10
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<v-content>
|
<v-content>
|
||||||
<v-container>
|
<v-container v-for="user in users" :key="user.id">
|
||||||
<v-card v-for="user in users" :key="user.id" raised shaped>
|
<v-card raised shaped>
|
||||||
|
|
||||||
<v-list-item three-line>
|
<v-list-item three-line>
|
||||||
<v-list-item-content>
|
<v-list-item-content>
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-list-item-action-text class="title">{{(user.amount/100).toFixed(2)}} €</v-list-item-action-text>
|
<v-list-item-action-text :class="getColor(user.type)">{{(user.amount/100).toFixed(2)}} €</v-list-item-action-text>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
|
@ -70,6 +70,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "CreditLists",
|
name: "CreditLists",
|
||||||
props: {
|
props: {
|
||||||
|
@ -83,7 +84,14 @@
|
||||||
methods: {
|
methods: {
|
||||||
addAmount(username, amount) {
|
addAmount(username, amount) {
|
||||||
this.$emit("add:amount", username, amount)
|
this.$emit("add:amount", username, amount)
|
||||||
|
},
|
||||||
|
getColor(type) {
|
||||||
|
return type === 'credit' ? 'title green--text' : 'title red--text'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -15,7 +15,9 @@ class Service {
|
||||||
return axios.get(this.url+'bar', {headers: {Token: token}})
|
return axios.get(this.url+'bar', {headers: {Token: token}})
|
||||||
}
|
}
|
||||||
addAmountBar(token, data) {
|
addAmountBar(token, data) {
|
||||||
return axios.post(this.url+'baradd', ...data, {headers: {Token: token}})
|
// eslint-disable-next-line no-console
|
||||||
|
console.log("addAmountdata: ", data)
|
||||||
|
return axios.post(this.url+'baradd', {...data}, {headers: {Token: token}})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
import TitleBar from "@/components/TitleBar";
|
import TitleBar from "@/components/TitleBar";
|
||||||
import CreditLists from "@/components/baruser/CreditLists";
|
import CreditLists from "@/components/baruser/CreditLists";
|
||||||
import httpClient from "../plugins/restService";
|
import httpClient from "../plugins/restService";
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
export default {
|
export default {
|
||||||
name: "BarView",
|
name: "BarView",
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
methods: {
|
methods: {
|
||||||
getUser() {
|
getUser() {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
this. users = []
|
||||||
httpClient.getUserBar(this.$store.getters.getToken)
|
httpClient.getUserBar(this.$store.getters.getToken)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
@ -35,27 +37,33 @@
|
||||||
username: response.data[user].username,
|
username: response.data[user].username,
|
||||||
firstname: response.data[user].firstname,
|
firstname: response.data[user].firstname,
|
||||||
lastname: response.data[user].lastname,
|
lastname: response.data[user].lastname,
|
||||||
amount: response.data[user].amount
|
amount: response.data[user].amount,
|
||||||
|
type: response.data[user].type
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
this.$store.dispatch("logout")
|
||||||
this.users = []
|
this.users = []
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
addAmount(username, amount) {
|
addAmount(username, amount) {
|
||||||
axios.post('http://192.168.5.118:5000/baradd', {userId: username, amount: amount}, {headers: {Token: this.$store.getters.getToken}})
|
httpClient.addAmountBar(this.$store.getters.getToken, {userId: username, amount: amount})
|
||||||
//httpClient.addAmountBar(this.$store.getters.getToken, {username: username, amount: amount})
|
.then((response) => {
|
||||||
/*.then(response => {
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log("responsedata: ", response.data)
|
console.log(response.data)
|
||||||
|
|
||||||
|
let user = this.users.find(user => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(user)
|
||||||
|
return user.username === username ? user : false
|
||||||
|
})
|
||||||
|
user.amount = response.data.amount
|
||||||
})
|
})
|
||||||
.catch(error => {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log("error: ", error.response.data.error)
|
|
||||||
})*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue