Add temporary DCA client creation endpoint for testing and enhance quick deposit UI with new form for adding deposits. Clean up code formatting for consistency.
This commit is contained in:
parent
b3332e585a
commit
46b7a1450d
3 changed files with 182 additions and 124 deletions
|
|
@ -96,8 +96,12 @@ window.app = Vue.createApp({
|
|||
methods: {
|
||||
// Utility Methods
|
||||
formatCurrency(amount) {
|
||||
if (!amount) return 'Q 0.00'
|
||||
return `Q ${(amount / 100).toFixed(2)}`
|
||||
if (!amount) return 'Q 0.00';
|
||||
|
||||
return new Intl.NumberFormat('es-GT', {
|
||||
style: 'currency',
|
||||
currency: 'GTQ',
|
||||
}).format(amount);
|
||||
},
|
||||
|
||||
formatDate(dateString) {
|
||||
|
|
@ -119,6 +123,34 @@ window.app = Vue.createApp({
|
|||
}
|
||||
},
|
||||
|
||||
// Test Client Creation (temporary for testing)
|
||||
async createTestClient() {
|
||||
try {
|
||||
const testData = {
|
||||
user_id: this.g.user.id,
|
||||
wallet_id: this.g.user.wallets[0].id,
|
||||
dca_mode: 'flow'
|
||||
}
|
||||
|
||||
const { data: newClient } = await LNbits.api.request(
|
||||
'POST',
|
||||
'/myextension/api/v1/dca/clients',
|
||||
this.g.user.wallets[0].adminkey,
|
||||
testData
|
||||
)
|
||||
|
||||
this.dcaClients.push(newClient)
|
||||
|
||||
this.$q.notify({
|
||||
type: 'positive',
|
||||
message: 'Test client created successfully!',
|
||||
timeout: 5000
|
||||
})
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
},
|
||||
|
||||
// Quick Deposit Methods
|
||||
async sendQuickDeposit() {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,82 @@
|
|||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<!-- Quick Add Deposit Section -->
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<h6 class="text-subtitle2 q-my-none">Quick Add Deposit</h6>
|
||||
<p class="text-caption q-my-none">Add a new deposit for an existing client</p>
|
||||
|
||||
<div v-if="dcaClients.length === 0" class="q-mt-md">
|
||||
<q-banner class="bg-orange-1 text-orange-9">
|
||||
<template v-slot:avatar>
|
||||
<q-icon name="info" color="orange" />
|
||||
</template>
|
||||
No DCA clients registered yet. Clients must first install and configure the DCA client extension.
|
||||
<template v-slot:action>
|
||||
<q-btn
|
||||
flat
|
||||
color="orange"
|
||||
label="Create Test Client"
|
||||
@click="createTestClient"
|
||||
size="sm"
|
||||
/>
|
||||
</template>
|
||||
</q-banner>
|
||||
</div>
|
||||
|
||||
<q-form v-else @submit="sendQuickDeposit" class="q-gutter-md q-mt-md">
|
||||
<div class="row q-gutter-md">
|
||||
<div class="col">
|
||||
<q-select
|
||||
filled
|
||||
dense
|
||||
emit-value
|
||||
v-model="quickDepositForm.client_id"
|
||||
:options="clientOptions"
|
||||
label="Select Client *"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
></q-select>
|
||||
</div>
|
||||
<div class="col">
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
type="number"
|
||||
v-model.number="quickDepositForm.amount"
|
||||
label="Amount (GTQ) *"
|
||||
placeholder="Amount in centavos (GTQ * 100)"
|
||||
hint="Enter amount in centavos"
|
||||
></q-input>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<q-btn
|
||||
unelevated
|
||||
color="primary"
|
||||
type="submit"
|
||||
:disable="!quickDepositForm.client_id || !quickDepositForm.amount"
|
||||
>Add Deposit</q-btn
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
type="textarea"
|
||||
v-model.trim="quickDepositForm.notes"
|
||||
label="Notes (Optional)"
|
||||
placeholder="Optional notes about this deposit"
|
||||
rows="2"
|
||||
></q-input>
|
||||
</div>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<!-- Deposits Management Section -->
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
|
|
@ -262,65 +338,6 @@
|
|||
</q-card>
|
||||
</div>
|
||||
|
||||
<!--/////////////////////////////////////////////////-->
|
||||
<!--//////////////QUICK ADD DEPOSIT SECTION//////////-->
|
||||
<!--/////////////////////////////////////////////////-->
|
||||
|
||||
<q-card v-if="dcaClients.length > 0">
|
||||
<q-card-section>
|
||||
<h6 class="text-subtitle2 q-my-none">Quick Add Deposit</h6>
|
||||
<p class="text-caption q-my-none">Add a new deposit for an existing client</p>
|
||||
<q-form @submit="sendQuickDeposit" class="q-gutter-md q-mt-md">
|
||||
<div class="row q-gutter-md">
|
||||
<div class="col">
|
||||
<q-select
|
||||
filled
|
||||
dense
|
||||
emit-value
|
||||
v-model="quickDepositForm.client_id"
|
||||
:options="clientOptions"
|
||||
label="Select Client *"
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
></q-select>
|
||||
</div>
|
||||
<div class="col">
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
type="number"
|
||||
v-model.number="quickDepositForm.amount"
|
||||
label="Amount (GTQ) *"
|
||||
placeholder="Amount in centavos (GTQ * 100)"
|
||||
hint="Enter amount in centavos"
|
||||
></q-input>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<q-btn
|
||||
unelevated
|
||||
color="primary"
|
||||
type="submit"
|
||||
:disable="!quickDepositForm.client_id || !quickDepositForm.amount"
|
||||
>Add Deposit</q-btn
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
type="textarea"
|
||||
v-model.trim="quickDepositForm.notes"
|
||||
label="Notes (Optional)"
|
||||
placeholder="Optional notes about this deposit"
|
||||
rows="2"
|
||||
></q-input>
|
||||
</div>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<!--/////////////////////////////////////////////////-->
|
||||
<!--//////////////DEPOSIT FORM DIALOG////////////////-->
|
||||
|
|
|
|||
|
|
@ -223,6 +223,15 @@ async def api_get_dca_client(
|
|||
# Note: Client creation/update/delete will be handled by the DCA client extension
|
||||
# Admin extension only reads existing clients and manages their deposits
|
||||
|
||||
# TEMPORARY: Test client creation endpoint (remove in production)
|
||||
@myextension_api_router.post("/api/v1/dca/clients", status_code=HTTPStatus.CREATED)
|
||||
async def api_create_test_dca_client(
|
||||
data: CreateDcaClientData,
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
) -> DcaClient:
|
||||
"""Create a test DCA client (temporary for testing)"""
|
||||
return await create_dca_client(data)
|
||||
|
||||
|
||||
@myextension_api_router.get("/api/v1/dca/clients/{client_id}/balance")
|
||||
async def api_get_client_balance(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue