-
Notifications
You must be signed in to change notification settings - Fork 644
/
Copy pathAddMoneyCard.tsx
47 lines (44 loc) · 1.59 KB
/
AddMoneyCard.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use client"
import { Button } from "@repo/ui/button";
import { Card } from "@repo/ui/card";
import { Select } from "@repo/ui/select";
import { useState } from "react";
import { TextInput } from "@repo/ui/textinput";
import { createOnRampTransaction } from "../app/lib/actions/createOnRamptxn";
const SUPPORTED_BANKS = [{
name: "HDFC Bank",
redirectUrl: "https://netbanking.hdfcbank.com"
}, {
name: "Axis Bank",
redirectUrl: "https://www.axisbank.com/"
}];
export const AddMoney = () => {
const [redirectUrl, setRedirectUrl] = useState(SUPPORTED_BANKS[0]?.redirectUrl);
const [amount, setAmount] = useState(0);
const [provider, setProvider] = useState(SUPPORTED_BANKS[0]?.name || "");
return <Card title="Add Money">
<div className="w-full">
<TextInput label={"Amount"} placeholder={"Amount"} onChange={(value) => {
setAmount(Number(value))
}} />
<div className="py-4 text-left">
Bank
</div>
<Select onSelect={(value) => {
setRedirectUrl(SUPPORTED_BANKS.find(x => x.name === value)?.redirectUrl || "")
setProvider(SUPPORTED_BANKS.find(x => x.name === value)?.name || "")
}} options={SUPPORTED_BANKS.map(x => ({
key: x.name,
value: x.name
}))} />
<div className="flex justify-center pt-4">
<Button onClick={async () => {
await createOnRampTransaction(amount * 100, provider)
window.location.href = redirectUrl || "";
}}>
Add Money
</Button>
</div>
</div>
</Card>
}