@@ -6,7 +6,7 @@ export const createTransaction = async (req: Request, res: Response) => {
6
6
try {
7
7
// Check if wallet_id exists
8
8
const wallet = await prisma . wallet . findUnique ( {
9
- where : { id : req . body . wallet_id } ,
9
+ where : { id : req . body . input . wallet_id } ,
10
10
} ) ;
11
11
if ( ! wallet ) {
12
12
return res . status ( 400 ) . json ( { message : "Wallet not found" } ) ;
@@ -15,10 +15,10 @@ export const createTransaction = async (req: Request, res: Response) => {
15
15
// Create transaction
16
16
let response = await prisma . transaction . create ( {
17
17
data : {
18
- transaction_type : req . body . transaction_type ,
19
- user_id : req . body . user_id ,
20
- wallet_id : req . body . wallet_id ,
21
- amount : req . body . amount ,
18
+ transaction_type : req . body . input . transaction_type ,
19
+ user_id : req . body . input . user_id ,
20
+ wallet_id : req . body . input . wallet_id ,
21
+ amount : req . body . input . amount ,
22
22
} ,
23
23
} ) ;
24
24
@@ -34,7 +34,7 @@ export const createTransaction = async (req: Request, res: Response) => {
34
34
export const updateTransaction = async ( req : Request , res : Response ) => {
35
35
try {
36
36
const { id } = req . params ;
37
- const updateData = req . body ;
37
+ const updateData = req . body . input ;
38
38
39
39
// Check if transaction exists
40
40
const existingTransaction = await prisma . transaction . findUnique ( {
@@ -46,7 +46,7 @@ export const updateTransaction = async (req: Request, res: Response) => {
46
46
47
47
if ( updateData . wallet_id ) {
48
48
const wallet = await prisma . wallet . findUnique ( {
49
- where : { id : updateData . wallet_id } ,
49
+ where : { id : existingTransaction . wallet_id } ,
50
50
} ) ;
51
51
if ( ! wallet ) {
52
52
return res . status ( 400 ) . json ( { message : "Wallet not found" } ) ;
@@ -140,7 +140,10 @@ export const getTransactionsByUser = async (req: Request, res: Response) => {
140
140
} ,
141
141
} ) ;
142
142
143
- res . status ( 200 ) . json ( transactions ) ;
143
+ res . status ( 200 ) . json ( {
144
+ transactions : transactions ,
145
+ message : "Transactions retrieved successfully" ,
146
+ } ) ;
144
147
} catch ( e ) {
145
148
generateError ( res , e ) ;
146
149
}
0 commit comments