feat(expense): display the expenses

This commit is contained in:
2021-11-26 01:50:45 +01:00
parent e332d6ab12
commit b0aa4ad301
4 changed files with 70 additions and 3 deletions

3
package-lock.json generated
View File

@@ -25,6 +25,9 @@
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11" "vue-template-compiler": "^2.6.11"
},
"engines": {
"node": "16.13.0"
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {

View File

@@ -11,4 +11,12 @@ export default {
</script> </script>
<style> <style>
.float-left {
float: left;
}
.float-right {
float: right;
}
</style> </style>

View File

@@ -3,6 +3,15 @@
<b-card no-body> <b-card no-body>
<b-tabs card> <b-tabs card>
<b-tab :title=account.name > <b-tab :title=account.name >
<div>
<div class="expense-button-div float-left">
<b-button variant="success">Ajouter une dépense</b-button>
<b-button variant="info">Importer des dépenses</b-button>
</div>
<div class="float-right">
<b-button variant="light">Partager le compte</b-button></div>
</div>
<b-table striped hover bordered :items="expenses" :fields="fields"></b-table>
</b-tab> </b-tab>
</b-tabs> </b-tabs>
</b-card> </b-card>
@@ -10,13 +19,36 @@
</template> </template>
<script> <script>
import {BCard, BTabs , BTab} from "bootstrap-vue"; import {BCard, BTabs , BTab, BTable} from "bootstrap-vue";
import {getAnAccount} from "@/config/noscomptes"; import {getAnAccount, getExpenses} from "@/config/noscomptes";
export default { export default {
name: 'account', name: 'account',
data: function () { data: function () {
return { return {
fields: [
{
key: 'expenseDate',
label: 'Date',
sortable: true
},
{
key: 'libelle',
label: 'libelle',
},
{
key: 'value',
label: 'Montant',
sortable: false
},
],
account: {}, account: {},
expenses : [{
expenseDate: "Today",
libelle:"Test",
value: 10
}]
} }
}, },
beforeCreate() { beforeCreate() {
@@ -24,6 +56,11 @@ export default {
getAnAccount(loggedUser.oauth_token, loggedUser.nosComptesId, this.$route.params.accountId).then(data => { getAnAccount(loggedUser.oauth_token, loggedUser.nosComptesId, this.$route.params.accountId).then(data => {
this.account = data this.account = data
}) })
getExpenses(loggedUser.oauth_token, loggedUser.nosComptesId, this.$route.params.accountId).then(data => {
if (data.lenght > 0) {
this.expenses = data
}
})
}, },
mounted () { mounted () {
}, },
@@ -40,12 +77,22 @@ export default {
components: { components: {
BCard, BCard,
BTabs, BTabs,
BTab BTab,
BTable
} }
} }
</script> </script>
<style> <style>
.expense-button-div {
margin-bottom: 10px;
}
.expense-button-div .btn {
margin-left: 10px;
}
.sr-only {
display: none;
}
</style> </style>

View File

@@ -47,3 +47,12 @@ export const getAnAccount = (oauthToken, userId, accountId) => {
return response.data return response.data
}) })
} }
export const getExpenses = (oauthToken, userId, accountId) => {
const headers = {
"Authorization": "Bearer " + oauthToken
};
return Vue.axios.get("http://localhost:8081/users/"+userId+"/accounts/"+accountId+"/expenses", {headers}).then(response => {
return response.data
})
}