diff --git a/src/plugins/balance/pages/Admin.vue b/src/plugins/balance/pages/Admin.vue
index cd41368..ad2d5aa 100644
--- a/src/plugins/balance/pages/Admin.vue
+++ b/src/plugins/balance/pages/Admin.vue
@@ -21,7 +21,28 @@
{{ getName(props.row.userid) }}
- {{ getLimit(props.row.userid) }}€
+
+ {{ getLimit(props.row.userid) }}€
+
+
+
+
{{ getBalance(props.row.debit, props.row.credit) }}€
@@ -148,6 +169,15 @@ export default defineComponent({
updateBalance(receiver);
}
+ function setLimit(userid: string) {
+ setTimeout(() => {
+ void store.setLimit(limit.value, userid);
+ }, 50);
+ setTimeout(() => {
+ limit.value = undefined;
+ }, 100);
+ }
+
const tab = ref('add');
return {
@@ -157,6 +187,7 @@ export default defineComponent({
setLimits: store.setLimits,
getName,
getLimit,
+ setLimit,
getBalance,
updateBalance,
updateBalances,
diff --git a/src/plugins/balance/store.ts b/src/plugins/balance/store.ts
index 4a11fbc..9ad6cc5 100644
--- a/src/plugins/balance/store.ts
+++ b/src/plugins/balance/store.ts
@@ -187,5 +187,15 @@ export const useBalanceStore = defineStore({
}
});
},
+
+ async setLimit(limit: number, userid: string) {
+ await api.put(`users/${userid}/balance/limit`, { limit });
+ const user_limit = this.user_limits.find((a) => a.userid === userid);
+ if (user_limit) {
+ user_limit.limit = limit;
+ } else {
+ this.user_limits.push({ userid, limit });
+ }
+ },
},
});