-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from adyen-examples/get-transactions
Get transactions
- Loading branch information
Showing
12 changed files
with
384 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import axios from "axios"; | ||
|
||
import Box from '@mui/material/Box'; | ||
import Chip from '@mui/material/Chip'; | ||
import Toolbar from '@mui/material/Toolbar'; | ||
import Divider from '@mui/material/Divider'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import Paper from '@mui/material/Paper'; | ||
import Table from '@mui/material/Table'; | ||
import TableBody from '@mui/material/TableBody'; | ||
import TableCell from '@mui/material/TableCell'; | ||
import TableContainer from '@mui/material/TableContainer'; | ||
import TableHead from '@mui/material/TableHead'; | ||
import TablePagination from '@mui/material/TablePagination'; | ||
import TableRow from '@mui/material/TableRow'; | ||
|
||
import DashboardHeader from "./DashboardHeader.js"; | ||
import DashboardDrawer from "./DashboardDrawer.js"; | ||
|
||
export default function Products() { | ||
|
||
const navigate = useNavigate() | ||
|
||
const [page, setPage] = useState(0); | ||
const [rowsPerPage, setRowsPerPage] = useState(10); | ||
const [rows, setRows] = useState([]); | ||
|
||
const handleChangePage = (event, newPage) => { | ||
setPage(newPage); | ||
}; | ||
|
||
const handleChangeRowsPerPage = (event) => { | ||
setRowsPerPage(+event.target.value); | ||
setPage(0); | ||
}; | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
const response = await axios.post('/api/dashboard/getTransactions'); | ||
setRows(response.data); | ||
} catch (error) { | ||
console.error('API request error:', error); | ||
navigate('/'); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, []); | ||
|
||
return ( | ||
<Box sx={{ display: 'flex' }}> | ||
|
||
<DashboardHeader/> | ||
|
||
<DashboardDrawer/> | ||
|
||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
alignItems="center" | ||
width="100%" | ||
sx={{ p: 3 }} | ||
> | ||
|
||
<Toolbar /> | ||
|
||
<Divider sx={{ padding: 1 }}> | ||
<Chip label="My Transactions" variant="elevated" sx={{ minWidth: 100, fontSize: "20px", backgroundColor: "#0abf53", color: "white" }}/> | ||
</Divider> | ||
<Paper sx={{ width: '100%' }}> | ||
<TableContainer> | ||
<Table stickyHeader aria-label="sticky table"> | ||
<TableHead> | ||
<TableRow> | ||
{columns.map((column) => ( | ||
<TableCell | ||
key={column.id} | ||
align={column.align} | ||
style={{ minWidth: column.minWidth }} | ||
sx={{ fontSize: "18px", fontWeight: "bold" }} | ||
> | ||
{column.label} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{rows | ||
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) | ||
.map((row) => { | ||
return ( | ||
<TableRow hover role="checkbox" tabIndex={-1} key={row.code}> | ||
{columns.map((column) => { | ||
const value = row[column.id]; | ||
return ( | ||
<TableCell key={column.id} align={column.align} | ||
sx={{ fontSize: "15px", | ||
color: value === 'Outgoing' ? '#1573C1' : value === 'Incoming' ? '#0A912E' : 'black', | ||
fontWeight: value === 'Outgoing' ? 'bold' : value === 'Incoming' ? 'bold' : 'normal' | ||
}} | ||
> | ||
{column.format && typeof value === 'number'? column.format(value) : value} | ||
</TableCell> | ||
); | ||
})} | ||
</TableRow> | ||
); | ||
})} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
<TablePagination | ||
rowsPerPageOptions={[10, 25]} | ||
component="div" | ||
count={rows.length} | ||
rowsPerPage={rowsPerPage} | ||
page={page} | ||
onPageChange={handleChangePage} | ||
onRowsPerPageChange={handleChangeRowsPerPage} | ||
/> | ||
</Paper> | ||
|
||
|
||
</Box> | ||
</Box> | ||
); | ||
} | ||
|
||
const columns = [ | ||
{ id: 'id', label: 'ID', minWidth: 100 }, | ||
{ id: 'status', label: 'Status', minWidth: 120 }, | ||
{ id: 'type', label: 'Type', minWidth: 120 }, | ||
{ id: 'created', label: 'Created', minWidth: 220 }, | ||
{ id: 'amount', label: 'Amount', minWidth: 150 }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.adyen.model; | ||
|
||
public class TransactionItem { | ||
private String id; | ||
private String status; | ||
private String type; | ||
private String created; | ||
private String amount; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(String status) { | ||
this.status = status; | ||
} | ||
|
||
public String getCreated() { | ||
return created; | ||
} | ||
|
||
public void setCreated(String created) { | ||
this.created = created; | ||
} | ||
|
||
public String getAmount() { | ||
return amount; | ||
} | ||
|
||
public void setAmount(String amount) { | ||
this.amount = amount; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public TransactionItem id(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public TransactionItem status(String status) { | ||
this.status = status; | ||
return this; | ||
} | ||
|
||
public TransactionItem created(String created) { | ||
this.created = created; | ||
return this; | ||
} | ||
|
||
public TransactionItem amount(String amount) { | ||
this.amount = amount; | ||
return this; | ||
} | ||
|
||
public TransactionItem type(String type) { | ||
this.type = type; | ||
return this; | ||
} | ||
|
||
} |
Oops, something went wrong.