diff --git a/apps/user-app/app/(dashboard)/layout.tsx b/apps/user-app/app/(dashboard)/layout.tsx
index 90dc203..7ad9e98 100644
--- a/apps/user-app/app/(dashboard)/layout.tsx
+++ b/apps/user-app/app/(dashboard)/layout.tsx
@@ -12,6 +12,7 @@ export default function Layout({
} title="Home" />
} title="Transfer" />
} title="Transactions" />
+ } title="P2P Transfer" />
{children}
@@ -36,4 +37,10 @@ function TransactionsIcon() {
+}
+
+function P2PTransferIcon() {
+ return
}
\ No newline at end of file
diff --git a/apps/user-app/app/(dashboard)/p2pTransaction/page.tsx b/apps/user-app/app/(dashboard)/p2pTransaction/page.tsx
new file mode 100644
index 0000000..3c25c70
--- /dev/null
+++ b/apps/user-app/app/(dashboard)/p2pTransaction/page.tsx
@@ -0,0 +1,12 @@
+import { SendMoney } from "../../../components/SendMoneyCard";
+
+export default async function() {
+
+ return
+}
\ No newline at end of file
diff --git a/apps/user-app/app/lib/actions/createOnRampTxn.tsx b/apps/user-app/app/lib/actions/createOnRampTxn.tsx
new file mode 100644
index 0000000..e175fc5
--- /dev/null
+++ b/apps/user-app/app/lib/actions/createOnRampTxn.tsx
@@ -0,0 +1,29 @@
+"use server"
+import { getServerSession } from "next-auth";
+import { authOptions } from "../auth";
+import prisma from "@repo/db/client";
+
+export async function createOnRampTxn (amount:number, provider: string) {
+ const session = await getServerSession(authOptions);
+ const token = Math.random().toString();
+ const userId = session.user.id;
+
+ if(!userId){
+ return {
+ messafe : "User not Logged In"
+ }
+ }
+
+ await prisma.onRampTransaction.create({
+ data:{
+ userId : Number(userId),
+ token,
+ amount:amount * 100,
+ status:"Processing",
+ startTime: new Date(),
+ provider,
+ }
+ })
+
+ return { message : 'Done'}
+}
\ No newline at end of file
diff --git a/apps/user-app/app/lib/actions/sendMoney.tsx b/apps/user-app/app/lib/actions/sendMoney.tsx
new file mode 100644
index 0000000..6b27301
--- /dev/null
+++ b/apps/user-app/app/lib/actions/sendMoney.tsx
@@ -0,0 +1,47 @@
+"use server"
+import prisma from "@repo/db/client";
+import { authOptions } from "../auth";
+import { getServerSession } from "next-auth";
+
+export async function SendMoneyTo(number:string, amount:number) {
+ const session = await getServerSession(authOptions);
+ const userId = session?.user?.id
+
+ if(!userId) return { message : "UnAuthorized User!"};
+
+ const toUser = await prisma.user.findFirst({
+ where:{
+ number
+ }
+ })
+
+ if(!toUser) return {message : 'Invalid Number. Please provide a valid one..'};
+
+ try{
+ await prisma.$transaction(async (tx) =>{
+ const sender = await tx.balance.findUnique({
+ where : {
+ userId : Number(userId)
+ }
+ })
+
+ if(!sender || sender.amount / 100 < amount) throw new Error('InSufficient Balance')
+
+ await tx.balance.update({
+ where:{userId : Number(sender.id)},
+ data:{amount : {decrement:amount * 100}}
+ })
+
+ await tx.balance.update({
+ where:{userId : toUser.id},
+ data:{amount : {increment:amount * 100}}
+ })
+ });
+ }catch(e){
+ console.log("Error => ", e);
+ return { message : e}
+ }
+
+ return {message : 'Transaction Successful!'}
+
+}
\ No newline at end of file
diff --git a/apps/user-app/components/AddMoneyCard.tsx b/apps/user-app/components/AddMoneyCard.tsx
index 562f021..fed97a8 100644
--- a/apps/user-app/components/AddMoneyCard.tsx
+++ b/apps/user-app/components/AddMoneyCard.tsx
@@ -5,6 +5,7 @@ import { Center } from "@repo/ui/center";
import { Select } from "@repo/ui/select";
import { useState } from "react";
import { TextInput } from "@repo/ui/textinput";
+import { createOnRampTxn } from "../app/lib/actions/createOnRampTxn";
const SUPPORTED_BANKS = [{
name: "HDFC Bank",
@@ -16,22 +17,26 @@ const SUPPORTED_BANKS = [{
export const AddMoney = () => {
const [redirectUrl, setRedirectUrl] = useState(SUPPORTED_BANKS[0]?.redirectUrl);
+ const [amoutn, setAmount] = useState(0);
+ const [provider, setProvider] = useState('');
return
-
{
-
+ {
+ setAmount(Number(value));
}} />
Bank