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

Add workflow #13

Open
wants to merge 8 commits 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
2 changes: 1 addition & 1 deletion apps/merchant-app/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import NextAuth from "next-auth"
import { authOptions } from "../../../../lib/auth"

//@ts-ignore
const handler = NextAuth(authOptions)

export { handler as GET, handler as POST }
4 changes: 2 additions & 2 deletions apps/merchant-app/app/api/user/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextResponse } from "next/server"
import { PrismaClient } from "@repo/db/client";

import PrismaClient from "@repo/db/client";
//@ts-ignore
const client = new PrismaClient();

export const GET = async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/merchant-app/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";

//@ts-ignore
import { useBalance } from "@repo/store/balance";

export default function() {
Expand Down
5 changes: 5 additions & 0 deletions apps/merchant-app/lib/user/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

export default function () {
return (
"Hi there"
)}
1 change: 1 addition & 0 deletions apps/merchant-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"@repo/db": "*",
"@repo/store": "*",
"@repo/db/client": "*",
"@repo/ui": "*",
"next": "^14.1.1",
"next-auth": "^4.24.7",
Expand Down
4 changes: 2 additions & 2 deletions apps/user-app/app/(dashboard)/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { Quate} from "../../../components/Quate"
export default function() {
return <div>
Dashboard
<Quate/>
</div>
}
114 changes: 110 additions & 4 deletions apps/user-app/app/(dashboard)/transactions/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,112 @@

export default function() {
return <div>
Transactions
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>
}
)
}
2 changes: 1 addition & 1 deletion apps/user-app/app/(dashboard)/transfer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function getOnRampTransactions() {
userId: Number(session?.user?.id)
}
});
return txns.map(t => ({
return txns.map((t) => ({
time: t.startTime,
amount: t.amount,
status: t.status,
Expand Down
2 changes: 1 addition & 1 deletion apps/user-app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AppbarClient } from "../components/AppbarClient";
const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Wallet",
title: "Money Pay",
description: "Simple wallet app",
};

Expand Down
80 changes: 48 additions & 32 deletions apps/user-app/components/OnRampTransactions.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,55 @@
import { Card } from "@repo/ui/card"
import { Card } from '@repo/ui/card'

const getStatement = (status: string) => {
if (status === 'Success') {
return 'Received INR'
} else if (status === 'Processing') {
return 'To be Received INR'
} else {
return 'Failed'
}
}

export const OnRampTransactions = ({
transactions
transactions,
title = 'Recent wallet Transactions',
}: {
transactions: {
time: Date,
amount: number,
// TODO: Can the type of `status` be more specific?
status: string,
provider: string
}[]
transactions: {
time: Date
amount: number
// TODO: Can the type of `status` be more specific?
status: string
provider: string
}[]
title?: string
}) => {
if (!transactions.length) {
return <Card title="Recent Transactions">
<div className="text-center pb-8 pt-8">
No Recent transactions
</div>
</Card>
}
return <Card title="Recent Transactions">
<div className="pt-2">
{transactions.map(t => <div className="flex justify-between">
<div>
<div className="text-sm">
Received INR
</div>
<div className="text-slate-600 text-xs">
{t.time.toDateString()}
</div>
</div>
<div className="flex flex-col justify-center">
+ Rs {t.amount / 100}
</div>
if (!transactions.length) {
return (
<Card title={title}>
<div className="text-center pb-8 pt-8">No {title}</div>
</Card>
)
}

</div>)}
</div>
return (
<Card title={title}>
<div className="pt-2 flex flex-col gap-4">
{transactions.map((t) => (
<>
<div className="flex justify-between">
<div>
<div className="text-sm">{getStatement(t.status)}</div>
<div className="text-slate-600 text-xs">
{t.time.toDateString()}
</div>
</div>
<div className="flex flex-col justify-center">
+ Rs {t.amount / 100}
</div>
</div>
</>
))}
</div>
</Card>
)
}
18 changes: 18 additions & 0 deletions apps/user-app/components/Quate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const Quate = () => {
return <div className="bg-white h-screen w-screen flex justify-center flex-col">
<div className="flex justify-left px-20">
<div className="max-w-lg ">
<div className="text-3xl font-bold">
India's Most-loved Money Transfer Platform
</div>
<div className="max-w-md text-left text-xl font-semibold mt-4">
jules Winnfienld
</div>
<div className="max-w-md text-left text-sm font-semibold text-slate-400">
CEO | Acme Crop
</div>
</div>
</div>

</div>
}
1 change: 1 addition & 0 deletions apps/user-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"@repo/store": "*",
"@repo/ui": "*",
"@repo/db/client": "*",
"@types/bcrypt": "^5.0.2",
"bcrypt": "^5.1.1",
"next": "^14.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"recoil": "^0.7.7"
},
"exports": {
"./balance": "./src/hooks/useBalance"
"./balance": "./src/hooks/useBalance/"
}
}
4 changes: 2 additions & 2 deletions packages/ui/src/Appbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export const Appbar = ({
onSignin,
onSignout
}: AppbarProps) => {
return <div className="flex justify-between border-b px-4 border-slate-300">
return <div className=" bg-white flex justify-between border-b px-4 border-slate-300">
<div className="text-lg flex flex-col justify-center">
PayTM
Money Pay
</div>
<div className="flex flex-col justify-center pt-2">
<Button onClick={user ? onSignout : onSignin}>{user ? "Logout" : "Login"}</Button>
Expand Down