Merge branch 'master' of https://git.shiblysolution.id/TPAY/dashboard
This commit is contained in:
@ -1,10 +1,23 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { useManageAldeiasContext } from '../hooks/useManageAldeiasContext';
|
import { useManageAldeiasContext } from '../hooks/useManageAldeiasContext';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
const ListToolbar = () => {
|
const ListToolbar = () => {
|
||||||
const { table, reload } = useDataGrid();
|
const { table, reload } = useDataGrid();
|
||||||
const { handleAddDialog, handleSearchDialog } = useManageAldeiasContext();
|
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 (
|
return (
|
||||||
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
||||||
@ -16,10 +29,16 @@ const ListToolbar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Aldeia"
|
placeholder="Search Aldeia"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
value={searchValue}
|
||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
onChange={(event) => setSearchValue(event.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</label>
|
</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'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@ -9,6 +9,7 @@ const ListToolbar = () => {
|
|||||||
const { handleAddDialog, handleSearchDialog } = useManageMunicipiosContext();
|
const { handleAddDialog, handleSearchDialog } = useManageMunicipiosContext();
|
||||||
const [searchName, setSearchName] = useState('');
|
const [searchName, setSearchName] = useState('');
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [searchValue, setSearchValue] = useState('');
|
||||||
|
|
||||||
const handleFilterData = useCallback(() => {
|
const handleFilterData = useCallback(() => {
|
||||||
try {
|
try {
|
||||||
@ -19,6 +20,17 @@ const ListToolbar = () => {
|
|||||||
}
|
}
|
||||||
}, [searchName, table]);
|
}, [searchName, table]);
|
||||||
|
|
||||||
|
const handleKeyDown = (event: React.KeyboardEvent) => {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
handleSearch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSearch = () => {
|
||||||
|
table.getColumn('name')?.setFilterValue(searchValue);
|
||||||
|
table.setPageIndex(0);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
<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">
|
<div className="flex flex-wrap gap-2 lg:gap-5 w-full">
|
||||||
@ -29,10 +41,16 @@ const ListToolbar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Municipio"
|
placeholder="Search Municipio"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
value={searchValue}
|
||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
onChange={(event) => setSearchValue(event.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</label>
|
</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'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@ -8,7 +8,6 @@ const ListToolbar = () => {
|
|||||||
const { table, reload } = useDataGrid();
|
const { table, reload } = useDataGrid();
|
||||||
const { handleAddDialog, handleSearchDialog } = useManagePostoAdmsContext();
|
const { handleAddDialog, handleSearchDialog } = useManagePostoAdmsContext();
|
||||||
const [searchPosto, setSearchPosto] = useState('');
|
const [searchPosto, setSearchPosto] = useState('');
|
||||||
const [searchMunicipio, setSearchMunicipio] = useState('');
|
|
||||||
|
|
||||||
const handleKeyDown = (event: React.KeyboardEvent) => {
|
const handleKeyDown = (event: React.KeyboardEvent) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
@ -18,6 +17,7 @@ const ListToolbar = () => {
|
|||||||
|
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
table.getColumn('name')?.setFilterValue(searchPosto);
|
table.getColumn('name')?.setFilterValue(searchPosto);
|
||||||
|
table.setPageIndex(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,10 +1,23 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { useManageSucosContext } from '../hooks/useManageSucosContext';
|
import { useManageSucosContext } from '../hooks/useManageSucosContext';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
const ListToolbar = () => {
|
const ListToolbar = () => {
|
||||||
const { table, reload } = useDataGrid();
|
const { table, reload } = useDataGrid();
|
||||||
const { handleAddDialog, handleSearchDialog } = useManageSucosContext();
|
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 (
|
return (
|
||||||
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
||||||
@ -16,12 +29,16 @@ const ListToolbar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Sucos"
|
placeholder="Search Sucos"
|
||||||
value={String(table.getColumn(`sucos_name`)?.getFilterValue() ?? '')}
|
value={searchValue}
|
||||||
onChange={(event) =>
|
onChange={(event) => setSearchValue(event.target.value)}
|
||||||
table.getColumn('sucos_name')?.setFilterValue(event.target.value)
|
onKeyDown={handleKeyDown}
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</label>
|
</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'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@ -86,7 +86,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
|
|||||||
const columns = useMemo<ColumnDef<any>[]>(
|
const columns = useMemo<ColumnDef<any>[]>(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.sucos_name,
|
accessorFn: (row) => row.name,
|
||||||
id: 'sucos_name',
|
id: 'sucos_name',
|
||||||
filterFn: (row, columnId, filterValue) => {
|
filterFn: (row, columnId, filterValue) => {
|
||||||
const value = row.getValue<string>(columnId);
|
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',
|
id: 'posto_name',
|
||||||
filterFn: (row, columnId, filterValue) => {
|
filterFn: (row, columnId, filterValue) => {
|
||||||
const value = row.getValue<string>(columnId);
|
const value = row.getValue<string>(columnId);
|
||||||
@ -159,7 +159,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
|
|||||||
filter: JSON.stringify(filter)
|
filter: JSON.stringify(filter)
|
||||||
});
|
});
|
||||||
// console.log('Sucos List Response:', response?.data);
|
// 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 };
|
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching Sucos', error);
|
console.error('Error fetching Sucos', error);
|
||||||
|
|||||||
@ -1,10 +1,23 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { useManageWalletContext } from '../hooks/useManageWalletContext';
|
import { useManageWalletContext } from '../hooks/useManageWalletContext';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
const ListToolbar = () => {
|
const ListToolbar = () => {
|
||||||
const { reload, table } = useDataGrid();
|
const { reload, table } = useDataGrid();
|
||||||
const { handleAddDialog } = useManageWalletContext();
|
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 (
|
return (
|
||||||
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
||||||
@ -16,12 +29,16 @@ const ListToolbar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Wallet"
|
placeholder="Search Wallet"
|
||||||
value={(table.getColumn('wallets.name')?.getFilterValue() as string) ?? ''}
|
value={searchValue}
|
||||||
onChange={(event) =>
|
onChange={(event) => setSearchValue(event.target.value)}
|
||||||
table.getColumn('wallets.name')?.setFilterValue(event.target.value)
|
onKeyDown={handleKeyDown}
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</label>
|
</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'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@ -146,7 +146,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
|
|||||||
const getWalletLists = async (page: number, limit: number, sorting: any, filter: any) => {
|
const getWalletLists = async (page: number, limit: number, sorting: any, filter: any) => {
|
||||||
try {
|
try {
|
||||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
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`, {
|
const response = await GetData(`${API_URL_MASTER_DATA}/wallet/list`, {
|
||||||
limit,
|
limit,
|
||||||
page: page + 1,
|
page: page + 1,
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import { toast } from 'sonner';
|
|||||||
|
|
||||||
const TransactionDisbursement = () => {
|
const TransactionDisbursement = () => {
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
customerId: '',
|
msisdn: '',
|
||||||
amount: '',
|
amount: '',
|
||||||
pin: ''
|
pin: ''
|
||||||
});
|
});
|
||||||
@ -21,22 +21,21 @@ const TransactionDisbursement = () => {
|
|||||||
const handleSubmit = async (e: any) => {
|
const handleSubmit = async (e: any) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log('Submitted Data:', form);
|
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.')
|
toast.warning('Please fill in all required fields.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// let requestTopup = await PostData(`${API_URL}/transaction/request-topup`, {
|
let requestTopup = await PostData(`${API_URL}/transaction/topup-downline`, {
|
||||||
// amount: form.topupAmount,
|
msisdn_destination: form.msisdn,
|
||||||
// pin: form.pin
|
amount: form.amount,
|
||||||
// })
|
pin: form.pin
|
||||||
// console.log(requestTopup)
|
})
|
||||||
// if (requestTopup?.status == true) {
|
if (requestTopup?.status == true) {
|
||||||
// toast.success('Success Request Topup')
|
toast.success('Success Request Topup')
|
||||||
// } else {
|
} else {
|
||||||
// toast.warning(`${requestTopup?.message}`)
|
toast.warning(`${requestTopup?.message}`)
|
||||||
// }
|
}
|
||||||
toast.warning('Failed')
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.warning('Failed')
|
toast.warning('Failed')
|
||||||
}
|
}
|
||||||
@ -68,11 +67,12 @@ const TransactionDisbursement = () => {
|
|||||||
{/* form */}
|
{/* form */}
|
||||||
<form onSubmit={handleSubmit} className="space-y-6">
|
<form onSubmit={handleSubmit} className="space-y-6">
|
||||||
<div>
|
<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
|
<Input
|
||||||
id="customerId"
|
id="msisdn"
|
||||||
value={form.customerId}
|
type="number"
|
||||||
onChange={(e) => setForm({ ...form, customerId: e.target.value })}
|
value={form.msisdn}
|
||||||
|
onChange={(e) => setForm({ ...form, msisdn: e.target.value })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@ -30,7 +30,6 @@ const TransactionTopup = () => {
|
|||||||
amount: form.topupAmount,
|
amount: form.topupAmount,
|
||||||
pin: form.pin
|
pin: form.pin
|
||||||
})
|
})
|
||||||
console.log(requestTopup)
|
|
||||||
if (requestTopup?.status == true) {
|
if (requestTopup?.status == true) {
|
||||||
toast.success('Success Request Topup')
|
toast.success('Success Request Topup')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user