status kind filter on transfer type
This commit is contained in:
@ -52,7 +52,7 @@ const ListToolbar = () => {
|
|||||||
const { handleAddDialog } = useManageTransferTypeContext();
|
const { handleAddDialog } = useManageTransferTypeContext();
|
||||||
const [transferTypes, setTransferTypes] = useState<TransferType[]>([]);
|
const [transferTypes, setTransferTypes] = useState<TransferType[]>([]);
|
||||||
const { GetData } = useCallApi();
|
const { GetData } = useCallApi();
|
||||||
|
const [statusKind, setStatusKind] = useState('');
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
const [statusTypes, setStatusTypes] = useState('');
|
const [statusTypes, setStatusTypes] = useState('');
|
||||||
const [approval, setApproval] = useState('');
|
const [approval, setApproval] = useState('');
|
||||||
@ -83,6 +83,10 @@ const ListToolbar = () => {
|
|||||||
table.getColumn('status_approval')?.setFilterValue(approval);
|
table.getColumn('status_approval')?.setFilterValue(approval);
|
||||||
}, [approval, table]);
|
}, [approval, table]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
table.getColumn('status_kind')?.setFilterValue(statusKind);
|
||||||
|
}, [statusKind, table]);
|
||||||
|
|
||||||
const fetchTransferTypes = async () => {
|
const fetchTransferTypes = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await GetData(`${API_URL}/transactiontype/list`, {
|
const response = await GetData(`${API_URL}/transactiontype/list`, {
|
||||||
@ -106,7 +110,9 @@ const ListToolbar = () => {
|
|||||||
setSearchValue('');
|
setSearchValue('');
|
||||||
setStatusTypes('');
|
setStatusTypes('');
|
||||||
setApproval('');
|
setApproval('');
|
||||||
|
setStatusKind('');
|
||||||
|
|
||||||
|
table.getColumn('status_kind')?.setFilterValue('');
|
||||||
table.getColumn('name')?.setFilterValue('');
|
table.getColumn('name')?.setFilterValue('');
|
||||||
table.getColumn('type')?.setFilterValue('');
|
table.getColumn('type')?.setFilterValue('');
|
||||||
table.getColumn('status_approval')?.setFilterValue('');
|
table.getColumn('status_approval')?.setFilterValue('');
|
||||||
@ -122,7 +128,6 @@ const ListToolbar = () => {
|
|||||||
<div className="flex flex-wrap gap-1 w-full">
|
<div className="flex flex-wrap gap-1 w-full">
|
||||||
<div className="flex justify-between w-full items-center mb-3">
|
<div className="flex justify-between w-full items-center mb-3">
|
||||||
<div className="flex flex-nowrap items-end gap-3 w-full overflow-x-auto">
|
<div className="flex flex-nowrap items-end gap-3 w-full overflow-x-auto">
|
||||||
{/* Fixed Search Input dengan icon yang selalu terlihat */}
|
|
||||||
<div className="relative w-48 shrink-0">
|
<div className="relative w-48 shrink-0">
|
||||||
<div className="absolute left-3 top-1/2 transform -translate-y-1/2 pointer-events-none ">
|
<div className="absolute left-3 top-1/2 transform -translate-y-1/2 pointer-events-none ">
|
||||||
<KeenIcon icon="magnifier" />
|
<KeenIcon icon="magnifier" />
|
||||||
@ -144,7 +149,10 @@ const ListToolbar = () => {
|
|||||||
onValueChange={setStatusTypes}
|
onValueChange={setStatusTypes}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="h-8">
|
<SelectTrigger className="h-8">
|
||||||
<SelectValue placeholder="Select Status Transaction Type" className="text-ellipsis overflow-hidden" />
|
<SelectValue
|
||||||
|
placeholder="Select Status Transaction Type"
|
||||||
|
className="text-ellipsis overflow-hidden"
|
||||||
|
/>
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent className="max-h-64 overflow-y-auto">
|
<SelectContent className="max-h-64 overflow-y-auto">
|
||||||
{types.map((opt) => (
|
{types.map((opt) => (
|
||||||
@ -163,7 +171,10 @@ const ListToolbar = () => {
|
|||||||
onValueChange={setApproval}
|
onValueChange={setApproval}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="h-8">
|
<SelectTrigger className="h-8">
|
||||||
<SelectValue placeholder="Select Status Approval" className="text-ellipsis overflow-hidden" />
|
<SelectValue
|
||||||
|
placeholder="Select Status Approval"
|
||||||
|
className="text-ellipsis overflow-hidden"
|
||||||
|
/>
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent className="max-h-64 overflow-y-auto">
|
<SelectContent className="max-h-64 overflow-y-auto">
|
||||||
<SelectItem value="Y" className="truncate">
|
<SelectItem value="Y" className="truncate">
|
||||||
@ -175,6 +186,31 @@ const ListToolbar = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="min-w-[220px] shrink-0">
|
||||||
|
<Select
|
||||||
|
key={`status-kind-filter-${statusKind}`}
|
||||||
|
value={statusKind}
|
||||||
|
onValueChange={setStatusKind}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-8">
|
||||||
|
<SelectValue
|
||||||
|
placeholder="Select Status Kind"
|
||||||
|
className="text-ellipsis overflow-hidden"
|
||||||
|
/>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent className="max-h-64 overflow-y-auto">
|
||||||
|
<SelectItem value="R">Return</SelectItem>
|
||||||
|
<SelectItem value="T">Transfer</SelectItem>
|
||||||
|
<SelectItem value="P">Purchase</SelectItem>
|
||||||
|
<SelectItem value="W">Withdraw</SelectItem>
|
||||||
|
<SelectItem value="U">Top Up</SelectItem>
|
||||||
|
<SelectItem value="N">Top Up Patner</SelectItem>
|
||||||
|
<SelectItem value="E">Reward</SelectItem>
|
||||||
|
<SelectItem value="L">Purchase Loja</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<DefaultTooltip title={'Reset Filter'} placement={'top'}>
|
<DefaultTooltip title={'Reset Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@ -201,7 +237,6 @@ const ListToolbar = () => {
|
|||||||
</DefaultTooltip>
|
</DefaultTooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -278,7 +278,7 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React
|
|||||||
U: { label: 'Top Up', className: 'bg-yellow-100 text-yellow-600' },
|
U: { label: 'Top Up', className: 'bg-yellow-100 text-yellow-600' },
|
||||||
N: { label: 'Top Up Patner', className: 'bg-purple-100 text-purple-600' },
|
N: { label: 'Top Up Patner', className: 'bg-purple-100 text-purple-600' },
|
||||||
E: { label: 'Reward', className: 'bg-rose-100 text-rose-600' },
|
E: { label: 'Reward', className: 'bg-rose-100 text-rose-600' },
|
||||||
L: {label: 'Purchase Loja', className: 'bg-rose-100 text-rose-600'},
|
L: { label: 'Purchase Loja', className: 'bg-rose-100 text-rose-600' }
|
||||||
};
|
};
|
||||||
|
|
||||||
const kindInfo = mapping[kind] || {
|
const kindInfo = mapping[kind] || {
|
||||||
@ -369,6 +369,8 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React
|
|||||||
filterObject['wallet_origin.name'] = filter.value.toLowerCase();
|
filterObject['wallet_origin.name'] = filter.value.toLowerCase();
|
||||||
} else if (filter.id === 'wallet_destination') {
|
} else if (filter.id === 'wallet_destination') {
|
||||||
filterObject['wallet_destination.name'] = filter.value.toLowerCase();
|
filterObject['wallet_destination.name'] = filter.value.toLowerCase();
|
||||||
|
} else if (filter.id === 'status_kind') {
|
||||||
|
filterObject[filter.id] = filter.value;
|
||||||
} else {
|
} else {
|
||||||
filterObject[filter.id] = filter.value.toLowerCase();
|
filterObject[filter.id] = filter.value.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user