This commit is contained in:
Raja Oktafrianto
2025-04-16 14:55:56 +07:00
9 changed files with 105 additions and 35 deletions

View File

@ -1,10 +1,23 @@
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
import { Button } from '@/components/ui/button';
import { useManageAldeiasContext } from '../hooks/useManageAldeiasContext';
import React, { useState } from 'react';
const ListToolbar = () => {
const { table, reload } = useDataGrid();
const { handleAddDialog, handleSearchDialog } = useManageAldeiasContext();
const [searchValue, setSearchValue] = useState('');
const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
handleSearch();
}
};
const handleSearch = () => {
table.getColumn('name')?.setFilterValue(searchValue);
table.setPageIndex(0);
};
return (
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
@ -16,10 +29,16 @@ const ListToolbar = () => {
<input
type="text"
placeholder="Search Aldeia"
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
value={searchValue}
onChange={(event) => setSearchValue(event.target.value)}
onKeyDown={handleKeyDown}
/>
</label>
<DefaultTooltip title={'Search'} placement={'top'}>
<Button variant="outline" className="h-7.5" onClick={handleSearch}>
<KeenIcon icon="magnifier" />
</Button>
</DefaultTooltip>
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
<Button
variant="outline"

View File

@ -9,6 +9,7 @@ const ListToolbar = () => {
const { handleAddDialog, handleSearchDialog } = useManageMunicipiosContext();
const [searchName, setSearchName] = useState('');
const [isLoading, setIsLoading] = useState(false);
const [searchValue, setSearchValue] = useState('');
const handleFilterData = useCallback(() => {
try {
@ -19,6 +20,17 @@ const ListToolbar = () => {
}
}, [searchName, table]);
const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
handleSearch();
}
};
const handleSearch = () => {
table.getColumn('name')?.setFilterValue(searchValue);
table.setPageIndex(0);
};
return (
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
<div className="flex flex-wrap gap-2 lg:gap-5 w-full">
@ -29,10 +41,16 @@ const ListToolbar = () => {
<input
type="text"
placeholder="Search Municipio"
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
value={searchValue}
onChange={(event) => setSearchValue(event.target.value)}
onKeyDown={handleKeyDown}
/>
</label>
<DefaultTooltip title={'Search'} placement={'top'}>
<Button variant="outline" className="h-7.5" onClick={handleSearch}>
<KeenIcon icon="magnifier" />
</Button>
</DefaultTooltip>
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
<Button
variant="outline"

View File

@ -8,7 +8,6 @@ const ListToolbar = () => {
const { table, reload } = useDataGrid();
const { handleAddDialog, handleSearchDialog } = useManagePostoAdmsContext();
const [searchPosto, setSearchPosto] = useState('');
const [searchMunicipio, setSearchMunicipio] = useState('');
const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
@ -18,6 +17,7 @@ const ListToolbar = () => {
const handleSearch = () => {
table.getColumn('name')?.setFilterValue(searchPosto);
table.setPageIndex(0);
};
return (

View File

@ -1,10 +1,23 @@
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
import { Button } from '@/components/ui/button';
import { useManageSucosContext } from '../hooks/useManageSucosContext';
import React, { useState } from 'react';
const ListToolbar = () => {
const { table, reload } = useDataGrid();
const { handleAddDialog, handleSearchDialog } = useManageSucosContext();
const [searchValue, setSearchValue] = useState('');
const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
handleSearch();
}
};
const handleSearch = () => {
table.getColumn('sucos_name')?.setFilterValue(searchValue);
table.setPageIndex(0);
};
return (
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
@ -16,12 +29,16 @@ const ListToolbar = () => {
<input
type="text"
placeholder="Search Sucos"
value={String(table.getColumn(`sucos_name`)?.getFilterValue() ?? '')}
onChange={(event) =>
table.getColumn('sucos_name')?.setFilterValue(event.target.value)
}
value={searchValue}
onChange={(event) => setSearchValue(event.target.value)}
onKeyDown={handleKeyDown}
/>
</label>
<DefaultTooltip title={'Search'} placement={'top'}>
<Button variant="outline" className="h-7.5" onClick={handleSearch}>
<KeenIcon icon="magnifier" />
</Button>
</DefaultTooltip>
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
<Button
variant="outline"

View File

@ -86,7 +86,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
const columns = useMemo<ColumnDef<any>[]>(
() => [
{
accessorFn: (row) => row.sucos_name,
accessorFn: (row) => row.name,
id: 'sucos_name',
filterFn: (row, columnId, filterValue) => {
const value = row.getValue<string>(columnId);
@ -100,7 +100,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
}
},
{
accessorKey: 'posto_name',
accessorKey: 'posto.name',
id: 'posto_name',
filterFn: (row, columnId, filterValue) => {
const value = row.getValue<string>(columnId);
@ -159,7 +159,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
filter: JSON.stringify(filter)
});
// console.log('Sucos List Response:', response?.data);
setSucos(response?.data.list || []); // Pastikan default value adalah array kosong
setSucos(response?.data.list || []);
return { data: response?.data.list, totalCount: response?.data.total_count };
} catch (error) {
console.error('Error fetching Sucos', error);

View File

@ -1,10 +1,23 @@
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
import { Button } from '@/components/ui/button';
import { useManageWalletContext } from '../hooks/useManageWalletContext';
import React, { useState } from 'react';
const ListToolbar = () => {
const { reload, table } = useDataGrid();
const { handleAddDialog } = useManageWalletContext();
const [searchValue, setSearchValue] = useState('');
const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
handleSearch();
}
};
const handleSearch = () => {
table.getColumn('wallets.name')?.setFilterValue(searchValue);
table.setPageIndex(0);
};
return (
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
@ -16,12 +29,16 @@ const ListToolbar = () => {
<input
type="text"
placeholder="Search Wallet"
value={(table.getColumn('wallets.name')?.getFilterValue() as string) ?? ''}
onChange={(event) =>
table.getColumn('wallets.name')?.setFilterValue(event.target.value)
}
value={searchValue}
onChange={(event) => setSearchValue(event.target.value)}
onKeyDown={handleKeyDown}
/>
</label>
<DefaultTooltip title={'Search'} placement={'top'}>
<Button variant="outline" className="h-7.5" onClick={handleSearch}>
<KeenIcon icon="magnifier" />
</Button>
</DefaultTooltip>
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
<Button
variant="outline"

View File

@ -146,7 +146,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
const getWalletLists = async (page: number, limit: number, sorting: any, filter: any) => {
try {
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
filter = filter.length == 0 ? {} : { name: { like: `%${filter[0].value?.toLowerCase()}%` } };
filter = filter.length == 0 ? {} : { 'wallets.name': { like: `%${filter[0].value?.toLowerCase()}%` } };
const response = await GetData(`${API_URL_MASTER_DATA}/wallet/list`, {
limit,
page: page + 1,

View File

@ -11,7 +11,7 @@ import { toast } from 'sonner';
const TransactionDisbursement = () => {
const [form, setForm] = useState({
customerId: '',
msisdn: '',
amount: '',
pin: ''
});
@ -21,22 +21,21 @@ const TransactionDisbursement = () => {
const handleSubmit = async (e: any) => {
e.preventDefault();
console.log('Submitted Data:', form);
if (form.amount == '' || form.customerId == '' || form.pin == '') {
if (form.amount == '' || form.msisdn == '' || form.pin == '') {
toast.warning('Please fill in all required fields.')
return
}
try {
// let requestTopup = await PostData(`${API_URL}/transaction/request-topup`, {
// amount: form.topupAmount,
// pin: form.pin
// })
// console.log(requestTopup)
// if (requestTopup?.status == true) {
// toast.success('Success Request Topup')
// } else {
// toast.warning(`${requestTopup?.message}`)
// }
toast.warning('Failed')
let requestTopup = await PostData(`${API_URL}/transaction/topup-downline`, {
msisdn_destination: form.msisdn,
amount: form.amount,
pin: form.pin
})
if (requestTopup?.status == true) {
toast.success('Success Request Topup')
} else {
toast.warning(`${requestTopup?.message}`)
}
} catch (error) {
toast.warning('Failed')
}
@ -68,11 +67,12 @@ const TransactionDisbursement = () => {
{/* form */}
<form onSubmit={handleSubmit} className="space-y-6">
<div>
<label htmlFor="customerId">Customer ID</label><span className="text-red-500">*</span>
<label htmlFor="msisdn">Destination MSISDN</label><span className="text-red-500">*</span>
<Input
id="customerId"
value={form.customerId}
onChange={(e) => setForm({ ...form, customerId: e.target.value })}
id="msisdn"
type="number"
value={form.msisdn}
onChange={(e) => setForm({ ...form, msisdn: e.target.value })}
/>
</div>
<div>

View File

@ -30,7 +30,6 @@ const TransactionTopup = () => {
amount: form.topupAmount,
pin: form.pin
})
console.log(requestTopup)
if (requestTopup?.status == true) {
toast.success('Success Request Topup')
} else {