Skip to content

Commit 3d682b2

Browse files
committed
update Credits ui
1 parent ce91077 commit 3d682b2

File tree

2 files changed

+53
-20
lines changed

2 files changed

+53
-20
lines changed

src/store/mainStore.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,28 @@ const mainStore = {
17941794

17951795
},
17961796

1797+
// eslint-disable-next-line
1798+
async ssiCredits({ getters }, payload) {
1799+
const url = `${sanitizeUrl(getters.getSelectedService.tenantUrl)}/api/v1/credit`;
1800+
const options = {
1801+
method: "GET",
1802+
headers: {
1803+
"Content-Type": "application/json",
1804+
"Authorization": `Bearer ${getters.getSelectedService.access_token}`,
1805+
"Origin": '*'
1806+
1807+
}
1808+
}
1809+
1810+
const resp = await fetch(url, {
1811+
...options
1812+
})
1813+
const json = await resp.json()
1814+
1815+
return json
1816+
1817+
1818+
},
17971819

17981820
// eslint-disable-next-line
17991821
async ssiDashboardAllowanceStats({ getters }, payload) {

src/views/playground/SSIDashboardCredit.vue

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ h5 span {
145145
<v-card class="card p-4 mt-1">
146146
<div class="row">
147147
<div class="col-8">
148-
<p><b>Total Credits</b></p>
148+
<p><b>Total Credits Used</b></p>
149149
<p>
150150
<span style="font-size:xx-large;">
151151
{{ numberFormat(parsedAllowanceLimit) }}
@@ -171,10 +171,10 @@ h5 span {
171171
<v-card class="p-4 mt-2">
172172
<div>
173173
<p><b>Scope(s)</b></p>
174-
<p v-if="grants.length > 0">
175-
<span class="badge badge-info mx-1" v-for="eachRow in grants"
176-
v-bind:key="eachRow.authorization.msg">{{
177-
eachRow.authorization.msg.replace('/hypersign.ssi.v1.Msg', '') }}</span>
174+
<p v-if="allowance.scope.length > 0">
175+
<span class="badge badge-info mx-1" v-for="eachRow in allowance.scope"
176+
v-bind:key="eachRow">{{
177+
eachRow }}</span>
178178
</p>
179179
<p v-else>
180180
No scope granted!
@@ -378,26 +378,36 @@ export default {
378378
},
379379
async mounted() {
380380
try {
381+
381382
this.isLoading = true
382-
const payload = {
383-
// wallet: "hid1a4zqvlmp3w9ggctvc873f08k3evh3mmj2vx939",
384-
groupBy: 'daily'
385-
}
386383
387-
// get allowance
388-
const t = await this.ssiDashboardAllowanceStats(payload)
389-
if (t.allowance) {
390-
this.allowance = t.allowance
391-
this.allowance.total = 5000000
392-
this.dougnNutData = [this.parsedAllowanceLimit, this.allowance.total - this.parsedAllowanceLimit]
384+
const credits = await this.ssiCredits()
385+
386+
387+
const credit = credits.filter(each => {
388+
if (each.status == 'Active') {
389+
return each
390+
}
391+
})
392+
393+
394+
// get allowanc
395+
396+
if (credit[0]?.credit) {
397+
398+
// this.allowance = credits[0].credit.amount
399+
this.allowance.spend_limit[0].amount = credit[0].used
400+
this.allowance.total = credit[0].totalCredits
401+
this.dougnNutData = [this.allowance.total - this.parsedAllowanceLimit, this.parsedAllowanceLimit]
402+
403+
this.allowance.scope=credit[0].creditScope
404+
this.allowance.expiration = credit[0].expiresAt
405+
393406
this.redrawChart = true
394407
}
395408
396409
// get grants
397-
this.grants = await this.ssiDashboardGrantsStats(payload)
398410
399-
// get tx stats
400-
this.ssiDashboardStats = await this.ssiDashboardTxStats(payload)
401411
402412
this.isLoading = false
403413
} catch (e) {
@@ -484,7 +494,8 @@ export default {
484494
}
485495
],
486496
"expiration": null,
487-
"total": 5000000
497+
"total": 5000000,
498+
scope: []
488499
},
489500
initialBalance: 1000,
490501
leftBalance: 1000,
@@ -509,7 +520,7 @@ export default {
509520
}
510521
},
511522
methods: {
512-
...mapActions('mainStore', ['ssiDashboardTxStats', 'ssiDashboardAllowanceStats', 'ssiDashboardGrantsStats']),
523+
...mapActions('mainStore', ['ssiDashboardTxStats', 'ssiDashboardAllowanceStats', 'ssiCredits', 'ssiDashboardGrantsStats']),
513524
514525
renderChart() {
515526
const ctx = document.getElementById('doughNutChat');

0 commit comments

Comments
 (0)