-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathpage.tsx
112 lines (101 loc) · 3 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import prisma from "@repo/db/client"
import { getServerSession } from "next-auth"
import { authOptions } from "../../lib/auth"
import { OnRampTransactions } from "../../../components/OnRampTransactions"
async function getOnRampTransactions(status: any) {
const session = await getServerSession(authOptions)
const txns = await prisma.onRampTransaction.findMany({
where: {
userId: Number(session?.user?.id),
status: status,
},
})
return txns.map((t) => ({
time: t.startTime,
amount: t.amount,
status: t.status,
provider: t.provider,
}))
}
async function getsentP2PTransactions() {
const session = await getServerSession(authOptions)
const txns = await prisma.p2pTransfer.findMany({
where: {
fromUserId: Number(session?.user?.id),
},
})
return txns.map((t) => ({
time: t.timestamp,
amount: t.amount,
status: "Success",
provider: t.toUserId,
}))
}
async function getreceiveP2PTransactions() {
const session = await getServerSession(authOptions)
const txns = await prisma.p2pTransfer.findMany({
where: {
toUserId: Number(session?.user?.id),
},
})
return txns.map((t) => ({
time: t.timestamp,
amount: t.amount,
status: "Success",
provider: t.fromUserId,
}))
}
export default async function () {
const successTransactions = await getOnRampTransactions("Success")
const processingTransactions = await getOnRampTransactions("Processing")
const failureTransactions = await getOnRampTransactions("Failure")
const sentTransactions: any = await getsentP2PTransactions()
const receivedTransactions: any = await getreceiveP2PTransactions()
return (
<div className="flex flex-col gap-5">
<h1 className="text-4xl text-[#6a51a6] pt-8 mb-8 font-bold">
Transactions
</h1>
<div className="w-[80vw] grid grid-cols-1 md:grid-cols-2 px-10 gap-3">
<h1 className="text-2xl text-[#6a51a6] pt-2 font-bold col-span-2">
P2P Transactions
</h1>
<div>
<OnRampTransactions
title={"Sent transactions"}
transactions={sentTransactions}
/>
</div>
<div>
<OnRampTransactions
title={"Received transactions"}
transactions={receivedTransactions}
/>
</div>
</div>
<div className="w-[80vw] grid grid-cols-1 md:grid-cols-2 px-10 gap-3">
<h1 className="text-2xl text-[#6a51a6] pt-2 font-bold col-span-2">
Wallet Transactions
</h1>
<div>
<OnRampTransactions
title={"Successfull transactions"}
transactions={successTransactions}
/>
</div>
<div>
<OnRampTransactions
title={"Processing Transactions"}
transactions={processingTransactions}
/>
</div>
<div>
<OnRampTransactions
title={"Failure Transactions"}
transactions={failureTransactions}
/>
</div>
</div>
</div>
)
}