Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed : onRamptransactions issue 2 #20

Open
wants to merge 1 commit into
base: migration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/bank-webhook/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ app.post("/hdfcWebhook", async (req, res) => {

})

app.listen(3003);
app.listen(3003,()=>{
console.log("Web hook listening on port 3003");
});
3 changes: 2 additions & 1 deletion apps/user-app/app/(dashboard)/transfer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ async function getOnRampTransactions() {
export default async function() {
const balance = await getBalance();
const transactions = await getOnRampTransactions();
const session = await getServerSession(authOptions);

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 />
<AddMoney user={session.user?.id}/>
</div>
<div>
<BalanceCard amount={balance.amount} locked={balance.locked} />
Expand Down
22 changes: 16 additions & 6 deletions apps/user-app/components/AddMoneyCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"use client"
import { Button } from "@repo/ui/button";
import { Card } from "@repo/ui/card";
import { Center } from "@repo/ui/center";
import { Select } from "@repo/ui/select";
import { useState } from "react";
import { TextInput } from "@repo/ui/textinput";
import { createOnrampTranactions } from "../lib/actions/createOnrampTransactions";



const SUPPORTED_BANKS = [{
name: "HDFC Bank",
Expand All @@ -14,25 +16,33 @@ const SUPPORTED_BANKS = [{
redirectUrl: "https://www.axisbank.com/"
}];

export const AddMoney = () => {
interface AddMoneyProps{
user : Number
}

export const AddMoney = ({user} : AddMoneyProps) => {
const [redirectUrl, setRedirectUrl] = useState(SUPPORTED_BANKS[0]?.redirectUrl);
const [provider, setProvider] = useState("");
const [amount,setAmount] = useState(0);
return <Card title="Add Money">
<div className="w-full">
<TextInput label={"Amount"} placeholder={"Amount"} onChange={() => {

<TextInput label={"Amount"} placeholder={"Amount"} onChange={(e) => {
setAmount(Number(e));
}} />
<div className="py-4 text-left">
Bank
</div>
<Select onSelect={(value) => {
setRedirectUrl(SUPPORTED_BANKS.find(x => x.name === value)?.redirectUrl || "")
setRedirectUrl(SUPPORTED_BANKS.find(x => x.name === value)?.redirectUrl || "");
setProvider(value);
}} options={SUPPORTED_BANKS.map(x => ({
key: x.name,
value: x.name
}))} />
<div className="flex justify-center pt-4">
<Button onClick={() => {
window.location.href = redirectUrl || "";
// window.location.href = redirectUrl || "";
createOnrampTranactions(amount,provider);
}}>
Add Money
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/user-app/components/OnRampTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const OnRampTransactions = ({
{transactions.map(t => <div className="flex justify-between">
<div>
<div className="text-sm">
Received INR
{t.status}
</div>
<div className="text-slate-600 text-xs">
{t.time.toDateString()}
Expand Down
47 changes: 47 additions & 0 deletions apps/user-app/lib/actions/createOnrampTransactions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use server"

import { getServerSession } from "next-auth"
import { authOptions } from "../../app/lib/auth"
import db from "@repo/db/client"


enum statusType {
Success = "Success",
Failure = "Failure",
Processing = "Processing"
}

export async function createOnrampTranactions(amount : number, provider : string)
{
const session = await getServerSession(authOptions);
const userId = session.user?.id;

try{
const x = await db.onRampTransaction.create({
data : {
token : Math.random().toString(),
status : statusType.Processing,
provider,
amount,
startTime : new Date(),
userId : Number(userId)
}
});

console.log("hey");

return {
msg : "onRamp created"
}
}
catch(e : any)
{
console.log(e);
return {
msg : e.toString()
}
}



}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/db/.env.example

This file was deleted.

1 change: 1 addition & 0 deletions packages/db/prisma/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("hey");
2 changes: 1 addition & 1 deletion packages/db/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@repo/typescript-config/react-library.json",
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
},
Expand Down