Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit 34c4a4c

Browse files
✨ Support for listing invoices
1 parent 118cc71 commit 34c4a4c

6 files changed

Lines changed: 111 additions & 23 deletions

File tree

components/LargeMessage.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class LargeMessage extends Vue {
2727
<style lang="scss" scoped>
2828
div {
2929
text-align: center;
30-
max-width: 600px;
30+
max-width: 400px;
3131
margin: auto;
3232
}
3333
h1 {

components/Manage.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
<font-awesome-icon class="nav-icon" icon="credit-card" fixed-width />
1515
<span>Billing</span>
1616
</nuxt-link>
17+
<nuxt-link class="item" to="/manage/invoices">
18+
<font-awesome-icon class="nav-icon" icon="file-invoice" fixed-width />
19+
<span>Invoices</span>
20+
</nuxt-link>
1721
<!-- <nuxt-link class="item" to="/manage/data">
1822
<font-awesome-icon class="nav-icon" icon="database" fixed-width />
1923
<span>Data &amp; security</span>
@@ -35,9 +39,10 @@ import {
3539
faDatabase,
3640
faUsers,
3741
faCog,
38-
faCreditCard
42+
faCreditCard,
43+
faFileInvoice
3944
} from "@fortawesome/free-solid-svg-icons";
40-
library.add(faDatabase, faUsers, faCog, faCreditCard);
45+
library.add(faDatabase, faUsers, faCog, faCreditCard, faFileInvoice);
4146
4247
@Component({
4348
components: {

pages/manage/billing.vue

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,47 +55,41 @@
5555
/>
5656
<Input
5757
:value="addressLine1"
58-
label="Line1"
59-
placeholder="Choose the addressLine1"
60-
required
58+
label="Address"
59+
placeholder="Enter your address"
6160
@input="val => (addressLine1 = val)"
6261
/>
6362
<Input
6463
:value="addressLine2"
65-
label="Line2"
66-
placeholder="Choose the addressLine2"
67-
required
64+
label="Line 2"
65+
placeholder="Add another address line"
6866
@input="val => (addressLine2 = val)"
6967
/>
7068
<Input
7169
:value="addressCity"
7270
label="City"
73-
placeholder="Choose the addressCity"
74-
required
71+
placeholder="Enter your city"
7572
@input="val => (addressCity = val)"
7673
/>
77-
<Select
78-
:value="addressCountry"
79-
label="Country"
80-
placeholder="Select your billing country"
81-
:options="countries"
82-
required
83-
@input="val => (addressCountry = val)"
84-
/>
8574
<Input
8675
:value="addressPostalCode"
8776
label="Postal code"
88-
placeholder="Choose the addressPostalCode"
89-
required
77+
placeholder="Enter your postal code"
9078
@input="val => (addressPostalCode = val)"
9179
/>
9280
<Input
9381
:value="addressState"
9482
label="State"
95-
placeholder="Choose the addressState"
96-
required
83+
placeholder="Enter your state"
9784
@input="val => (addressState = val)"
9885
/>
86+
<Select
87+
:value="addressCountry"
88+
label="Country"
89+
placeholder="Select your billing country"
90+
:options="countries"
91+
@input="val => (addressCountry = val)"
92+
/>
9993
<button class="button">
10094
Update settings
10195
</button>

pages/manage/invoices.vue

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<template>
2+
<main>
3+
<Manage>
4+
<h1>Invoices</h1>
5+
<Loading v-if="loading" :message="loading" />
6+
<LargeMessage
7+
v-else-if="!loading && !invoices.length"
8+
heading="No invoices yet"
9+
text="You don't have any invoices yet, come back here once you've made your first payment."
10+
/>
11+
<div v-else>
12+
<table class="table table--type-cols">
13+
<tbody>
14+
<tr
15+
v-for="(invoice, index) in invoices.data"
16+
:key="`${invoice.id}_${index}`"
17+
>
18+
<td>
19+
{{ invoice }}
20+
</td>
21+
</tr>
22+
</tbody>
23+
</table>
24+
</div>
25+
</Manage>
26+
</main>
27+
</template>
28+
29+
<script lang="ts">
30+
import { Component, Vue, Watch } from "vue-property-decorator";
31+
import { mapGetters } from "vuex";
32+
import Manage from "@/components/Manage.vue";
33+
import Loading from "@/components/Loading.vue";
34+
import LargeMessage from "@/components/LargeMessage.vue";
35+
import Input from "@/components/form/Input.vue";
36+
import Select from "@/components/form/Select.vue";
37+
import Checkbox from "@/components/form/Checkbox.vue";
38+
import { getAllCountries } from "countries-and-timezones";
39+
import { User } from "../../types/auth";
40+
41+
@Component({
42+
components: {
43+
Manage,
44+
Loading,
45+
Input,
46+
Select,
47+
LargeMessage,
48+
Checkbox
49+
},
50+
computed: mapGetters({
51+
organization: "auth/activeOrganization",
52+
user: "auth/user",
53+
invoices: "manage/invoices"
54+
})
55+
})
56+
export default class ManageSettings extends Vue {
57+
organization!: any;
58+
invoices!: any;
59+
user!: any;
60+
loading = "";
61+
62+
private mounted() {
63+
this.loading = "Loading invoices details";
64+
this.$store
65+
.dispatch("manage/getInvoices", this.organization.organization.id)
66+
.then(invoices => {})
67+
.catch(error => {
68+
if (error.response.data.error === "no-customer") {
69+
// this.name = this.user.name;
70+
}
71+
})
72+
.finally(() => (this.loading = ""));
73+
}
74+
}
75+
</script>
76+
77+
<style lang="scss" scoped></style>

store/manage.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ export const mutations: MutationTree<RootState> = {
1616
setBilling(state: RootState, billing: any): void {
1717
Vue.set(state, "billing", billing);
1818
},
19+
setInvoices(state: RootState, invoices: any): void {
20+
Vue.set(state, "invoices", invoices);
21+
},
1922
clearAll(state: RootState): void {
2023
delete state.organization;
2124
delete state.billing;
25+
delete state.invoices;
2226
delete state.members;
2327
delete state.membership;
2428
}
@@ -73,11 +77,18 @@ export const actions: ActionTree<RootState, RootState> = {
7377
delete data.id;
7478
await this.$axios.patch(`/organizations/${context.id}/billing`, data);
7579
return dispatch("getBilling", context.id);
80+
},
81+
async getInvoices({ commit }, context) {
82+
const invoices: any = (await this.$axios.get(
83+
`/organizations/${context}/invoices`
84+
)).data;
85+
commit("setInvoices", invoices);
7686
}
7787
};
7888

7989
export const getters: GetterTree<RootState, RootState> = {
8090
membership: state => state.membership,
8191
billing: state => state.billing,
92+
invoices: state => state.invoices,
8293
members: state => state.members
8394
};

types/manage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ export interface RootState {
1616
organization?: Organization;
1717
members: Member[];
1818
billing?: any;
19+
invoices?: any;
1920
}

0 commit comments

Comments
 (0)