-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathpage.tsx
56 lines (52 loc) · 1.68 KB
/
page.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
48
49
50
51
52
53
54
55
56
import prisma from "@repo/db/client";
import { AddMoney } from "../../../components/AddMoneyCard";
import { BalanceCard } from "../../../components/BalanceCard";
import { OnRampTransactions } from "../../../components/OnRampTransactions";
import { getServerSession } from "next-auth";
import { authOptions } from "../../lib/auth";
async function getBalance() {
const session = await getServerSession(authOptions);
const balance = await prisma.balance.findFirst({
where: {
userId: Number(session?.user?.id)
}
});
return {
amount: balance?.amount || 0,
locked: balance?.locked || 0
}
}
async function getOnRampTransactions() {
const session = await getServerSession(authOptions);
const txns = await prisma.onRampTransaction.findMany({
where: {
userId: Number(session?.user?.id)
}
});
return txns.map((t) => ({
time: t.startTime,
amount: t.amount,
status: t.status,
provider: t.provider
}))
}
export default async function() {
const balance = await getBalance();
const transactions = await getOnRampTransactions();
return <div className="w-screen">
<div className="text-4xl text-[#6a51a6] pt-8 mb-8 font-bold">
Transfer
</div>
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 p-4">
<div>
<AddMoney />
</div>
<div>
<BalanceCard amount={balance.amount} locked={balance.locked} />
<div className="pt-4">
<OnRampTransactions transactions={transactions} />
</div>
</div>
</div>
</div>
}