2025-03-27 16:58:24 +07:00
|
|
|
import { FC, ReactElement, useState } from 'react';
|
2025-03-27 17:22:04 +07:00
|
|
|
import {
|
|
|
|
|
FilterOutlined,
|
|
|
|
|
SearchOutlined,
|
|
|
|
|
FileTextOutlined,
|
2025-03-27 22:28:40 +07:00
|
|
|
AuditOutlined,
|
2025-03-27 17:22:04 +07:00
|
|
|
} from '@ant-design/icons';
|
2025-03-27 16:58:24 +07:00
|
|
|
import { Button, Input } from '@imphnen-frontend-service/ui/atoms';
|
|
|
|
|
import { Pagination } from '@imphnen-frontend-service/ui/molecules';
|
|
|
|
|
import { DataTable } from '@imphnen-frontend-service/ui/organisms';
|
|
|
|
|
|
2025-03-27 17:22:04 +07:00
|
|
|
// Define status type for better type safety
|
|
|
|
|
type TransactionStatus = 'valid' | 'invalid' | 'unchecked';
|
|
|
|
|
|
|
|
|
|
// Define transaction interface
|
|
|
|
|
interface Transaction {
|
|
|
|
|
id: number;
|
|
|
|
|
name: string;
|
|
|
|
|
transactionNumber: string;
|
|
|
|
|
status: TransactionStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mock data for transactions
|
|
|
|
|
const mockTransactions: Transaction[] = Array.from({ length: 20 }, (_, i) => ({
|
2025-03-27 16:58:24 +07:00
|
|
|
id: i + 1,
|
|
|
|
|
name: i === 0 ? 'Ahmad Wijuana' : 'Nama Lengkap',
|
2025-03-27 17:22:04 +07:00
|
|
|
transactionNumber: '25D2133Y9AFYBD',
|
|
|
|
|
status: (i % 3 === 0
|
|
|
|
|
? 'invalid'
|
|
|
|
|
: i % 5 === 0
|
|
|
|
|
? 'unchecked'
|
|
|
|
|
: 'valid') as TransactionStatus,
|
2025-03-27 16:58:24 +07:00
|
|
|
}));
|
2025-03-27 15:06:30 +07:00
|
|
|
|
|
|
|
|
export const Components: FC = (): ReactElement => {
|
2025-03-27 16:58:24 +07:00
|
|
|
const [searchQuery, setSearchQuery] = useState('');
|
|
|
|
|
const [currentPage, setCurrentPage] = useState(1);
|
|
|
|
|
const itemsPerPage = 9;
|
|
|
|
|
|
|
|
|
|
// Filter data based on search query
|
2025-03-27 17:22:04 +07:00
|
|
|
const filteredData = mockTransactions.filter(
|
2025-03-27 16:58:24 +07:00
|
|
|
(item) =>
|
|
|
|
|
item.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
2025-03-27 17:22:04 +07:00
|
|
|
item.transactionNumber.toLowerCase().includes(searchQuery.toLowerCase())
|
2025-03-27 16:58:24 +07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Paginate data
|
|
|
|
|
const indexOfLastItem = currentPage * itemsPerPage;
|
|
|
|
|
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
|
|
|
|
|
const currentItems = filteredData.slice(indexOfFirstItem, indexOfLastItem);
|
|
|
|
|
|
2025-03-27 17:22:04 +07:00
|
|
|
const handleValidate = (id: number) => {
|
|
|
|
|
console.log(`Validate transaction with id: ${id}`);
|
|
|
|
|
// Implement validation functionality
|
2025-03-27 16:58:24 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handlePageChange = (pageNumber: number) => {
|
|
|
|
|
setCurrentPage(pageNumber);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
setSearchQuery(e.target.value);
|
|
|
|
|
setCurrentPage(1); // Reset to first page when searching
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-27 15:06:30 +07:00
|
|
|
return (
|
|
|
|
|
<main className="w-full px-[48px] py-[40px] flex flex-col gap-8">
|
2025-03-27 16:58:24 +07:00
|
|
|
{/* Header */}
|
2025-03-27 15:06:30 +07:00
|
|
|
<header className="bg-white py-4 px-8 rounded-md shadow p-4">
|
|
|
|
|
<h1 className="text-p2 font-semibold">Validasi Transaksi</h1>
|
|
|
|
|
</header>
|
|
|
|
|
|
2025-03-27 16:58:24 +07:00
|
|
|
{/* Account Table Section */}
|
|
|
|
|
<section className="flex flex-col gap-6 p-8 bg-white rounded-md">
|
|
|
|
|
{/* Search and Filter */}
|
|
|
|
|
<div className="flex justify-between items-center gap-8 mb-2">
|
|
|
|
|
<div className="relative w-full">
|
|
|
|
|
<Input
|
|
|
|
|
placeholder="Cari berdasarkan nama lengkap, nomor order Shopee"
|
|
|
|
|
value={searchQuery}
|
|
|
|
|
onChange={handleSearch}
|
|
|
|
|
className="pl-12 w-full max-h-full"
|
|
|
|
|
/>
|
|
|
|
|
<div className="absolute left-3 top-1/2 transform -translate-y-1/2 text-[16px]">
|
|
|
|
|
<SearchOutlined />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
variant="primary"
|
|
|
|
|
size="md"
|
|
|
|
|
className="flex items-center gap-3"
|
|
|
|
|
>
|
|
|
|
|
<FilterOutlined />
|
|
|
|
|
Filters
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Table */}
|
2025-03-27 17:22:04 +07:00
|
|
|
<DataTable
|
|
|
|
|
data={currentItems}
|
|
|
|
|
headers={[
|
|
|
|
|
{
|
|
|
|
|
label: 'No.',
|
|
|
|
|
render: (_, index) => index + 1 + indexOfFirstItem,
|
|
|
|
|
},
|
|
|
|
|
{ label: 'Nama Lengkap', key: 'name' },
|
|
|
|
|
{ label: 'Nomor Transaksi', key: 'transactionNumber' },
|
|
|
|
|
{
|
|
|
|
|
label: 'Order Valid?',
|
|
|
|
|
render: (item: Transaction) => {
|
|
|
|
|
const statusColors: Record<TransactionStatus, string> = {
|
|
|
|
|
valid: 'bg-success-500 text-white',
|
|
|
|
|
invalid: 'bg-danger-500 text-white',
|
|
|
|
|
unchecked: 'bg-yellow-400 text-black',
|
|
|
|
|
};
|
|
|
|
|
const statusText: Record<TransactionStatus, string> = {
|
|
|
|
|
valid: 'Valid',
|
|
|
|
|
invalid: 'Invalid',
|
|
|
|
|
unchecked: 'Unchecked',
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={`py-1 px-3 rounded-md text-center ${
|
|
|
|
|
statusColors[item.status]
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{statusText[item.status]}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Action',
|
|
|
|
|
render: (item: Transaction) => (
|
|
|
|
|
<Button
|
|
|
|
|
variant="primary"
|
|
|
|
|
size="sm"
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
handleValidate(item.id);
|
|
|
|
|
}}
|
2025-03-27 22:28:40 +07:00
|
|
|
className="flex items-center gap-2 w-full"
|
2025-03-27 17:22:04 +07:00
|
|
|
>
|
2025-03-27 22:28:40 +07:00
|
|
|
<AuditOutlined className="text-[16px]" /> Validate
|
2025-03-27 17:22:04 +07:00
|
|
|
</Button>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
/>
|
2025-03-27 16:58:24 +07:00
|
|
|
|
|
|
|
|
{/* Pagination */}
|
|
|
|
|
<Pagination
|
|
|
|
|
currentPage={currentPage}
|
|
|
|
|
totalPages={Math.ceil(filteredData.length / itemsPerPage)}
|
|
|
|
|
onPageChange={handlePageChange}
|
|
|
|
|
/>
|
|
|
|
|
</section>
|
2025-03-27 15:06:30 +07:00
|
|
|
</main>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Components;
|