feat: update payment views
This commit is contained in:
43
app/src/components/payment/create-ledger.controller.ts
Normal file
43
app/src/components/payment/create-ledger.controller.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { CurrencySchema } from "@module/payment/client";
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
|
||||
import { api } from "@/services/api.ts";
|
||||
|
||||
import { Controller } from "../../lib/controller.tsx";
|
||||
|
||||
export class CreateLedgerController extends Controller<
|
||||
{
|
||||
isSubmitting: boolean;
|
||||
},
|
||||
{ title: string; icon: LucideIcon }
|
||||
> {
|
||||
#label?: string;
|
||||
#currencies: string[] = [];
|
||||
|
||||
async onInit() {
|
||||
return {
|
||||
isSubmitting: false,
|
||||
};
|
||||
}
|
||||
|
||||
setLabel(label: string) {
|
||||
this.#label = label;
|
||||
}
|
||||
|
||||
setCurrencies(currencies: string[]) {
|
||||
this.#currencies = currencies;
|
||||
}
|
||||
|
||||
async submit() {
|
||||
this.setState("isSubmitting", true);
|
||||
const result = await api.payment.ledger.create({
|
||||
body: {
|
||||
beneficiaryId: crypto.randomUUID(),
|
||||
label: this.#label,
|
||||
currencies: this.#currencies.map((currency) => CurrencySchema.parse(currency)),
|
||||
},
|
||||
});
|
||||
console.log(result);
|
||||
this.setState("isSubmitting", false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user