diff --git a/apps/backoffice/src/app/accounts/components/DataTable.tsx b/apps/backoffice/src/app/accounts/components/DataTable.tsx new file mode 100644 index 0000000..5581679 --- /dev/null +++ b/apps/backoffice/src/app/accounts/components/DataTable.tsx @@ -0,0 +1,68 @@ +import { FC, ReactElement } from 'react'; +import { EditOutlined } from '@ant-design/icons'; +import { Button } from '@imphnen-frontend-service/ui/atoms'; + +interface DataTableProps { + data: Array<{ + id: number; + name: string; + email: string; + phone: string; + address: string; + }>; + onEdit: (id: number) => void; +} + +export const DataTable: FC = ({ + data, + onEdit, +}): ReactElement => { + return ( +
+ + + + + + + + + + + + + + {data.map((item, index) => ( + + + + + + + + + + ))} + +
+ + No.Nama LengkapEmailNomor TelpAlamat PengirimanAction
+ + {index + 1}{item.name}{item.email}{item.phone}{item.address} + +
+
+ ); +}; + +export default DataTable; diff --git a/apps/backoffice/src/app/accounts/components/Pagination.tsx b/apps/backoffice/src/app/accounts/components/Pagination.tsx new file mode 100644 index 0000000..45db0b7 --- /dev/null +++ b/apps/backoffice/src/app/accounts/components/Pagination.tsx @@ -0,0 +1,92 @@ +import { FC, ReactElement } from 'react'; +import { LeftOutlined, RightOutlined } from '@ant-design/icons'; + +interface PaginationProps { + currentPage: number; + totalPages: number; + onPageChange: (page: number) => void; +} + +export const Pagination: FC = ({ + currentPage, + totalPages, + onPageChange, +}): ReactElement => { + // Generate page numbers to display + const getPageNumbers = () => { + const pages = []; + const maxPagesToShow = 5; + + // Always show first page + if (currentPage > 3) { + pages.push(1); + if (currentPage > 4) { + pages.push('...'); + } + } + + // Calculate range of pages to show around current page + const startPage = Math.max(1, currentPage - 1); + const endPage = Math.min(totalPages, currentPage + 1); + + for (let i = startPage; i <= endPage; i++) { + pages.push(i); + } + + // Always show last page + if (currentPage < totalPages - 2) { + if (currentPage < totalPages - 3) { + pages.push('...'); + } + pages.push(totalPages); + } + + return pages; + }; + + return ( +
+ + + {getPageNumbers().map((page, index) => + typeof page === 'number' ? ( + + ) : ( + + {page} + + ) + )} + + +
+ ); +}; + +export default Pagination; diff --git a/apps/backoffice/src/app/accounts/components/index.ts b/apps/backoffice/src/app/accounts/components/index.ts new file mode 100644 index 0000000..887ee93 --- /dev/null +++ b/apps/backoffice/src/app/accounts/components/index.ts @@ -0,0 +1,2 @@ +export * from './DataTable'; +export * from './Pagination'; diff --git a/apps/backoffice/src/app/accounts/page.tsx b/apps/backoffice/src/app/accounts/page.tsx index ffa154e..357b380 100644 --- a/apps/backoffice/src/app/accounts/page.tsx +++ b/apps/backoffice/src/app/accounts/page.tsx @@ -1,6 +1,48 @@ -import { FC, ReactElement } from 'react'; +import { FC, ReactElement, useState } from 'react'; +import { FilterOutlined, SearchOutlined } from '@ant-design/icons'; +import { Button, Input } from '@imphnen-frontend-service/ui/atoms'; +import { DataTable, Pagination } from './components'; + +// Mock data for demonstration +const mockData = Array.from({ length: 20 }, (_, i) => ({ + id: i + 1, + name: i === 0 ? 'Ahmad Wijuana' : 'Nama Lengkap', + email: 'Fullname23@gmail.com', + phone: '081904423804', + address: 'Jl. Pantai Cibaduyut Indonesia', +})); export const Components: FC = (): ReactElement => { + const [searchQuery, setSearchQuery] = useState(''); + const [currentPage, setCurrentPage] = useState(1); + const itemsPerPage = 9; + + // Filter data based on search query + const filteredData = mockData.filter( + (item) => + item.name.toLowerCase().includes(searchQuery.toLowerCase()) || + item.email.toLowerCase().includes(searchQuery.toLowerCase()) + ); + + // Paginate data + const indexOfLastItem = currentPage * itemsPerPage; + const indexOfFirstItem = indexOfLastItem - itemsPerPage; + const currentItems = filteredData.slice(indexOfFirstItem, indexOfLastItem); + + const handleEdit = (id: number) => { + console.log(`Edit item with id: ${id}`); + // Implement edit functionality + }; + + const handlePageChange = (pageNumber: number) => { + setCurrentPage(pageNumber); + }; + + const handleSearch = (e: React.ChangeEvent) => { + setSearchQuery(e.target.value); + setCurrentPage(1); // Reset to first page when searching + }; + return (
{/* Dashboard Header */} @@ -8,8 +50,38 @@ export const Components: FC = (): ReactElement => {

Data Akun

- {/* Transaction Table Section */} -
+ {/* Account Table Section */} +
+ {/* Search and Filter */} +
+
+ +
+ +
+
+ + +
+ + {/* Table */} + + + {/* Pagination */} + +
); };