Merge branch 'master' of https://git.shiblysolution.id/TPAY/dashboard
This commit is contained in:
@ -34,41 +34,43 @@ const ManageAccount = () => {
|
||||
const { GetData } = useCallApi();
|
||||
// console.log(accounts);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAccount = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/user/list`);
|
||||
const data: Account[] = await response.json();
|
||||
setAccounts(data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching data', error);
|
||||
}
|
||||
};
|
||||
// useEffect(() => {
|
||||
// const fetchAccount = async () => {
|
||||
// try {
|
||||
// const response = await axios.get(`${API_URL}/user/list`);
|
||||
// console.log(response);
|
||||
// const data: Account[] = response.data;
|
||||
// setAccounts(data);
|
||||
// } catch (error) {
|
||||
// console.error('Error fetching data', error);
|
||||
// }
|
||||
// };
|
||||
|
||||
fetchAccount();
|
||||
}, []);
|
||||
// fetchAccount();
|
||||
// }, []);
|
||||
|
||||
// const fetchAccount = async (page: number, limit: number, sorting: any, filter: any) => {
|
||||
// try {
|
||||
// const response = await GetData(`${API_URL}/user/list`, {
|
||||
// limit: limit,
|
||||
// page: page + 1,
|
||||
// with_deleted: true,
|
||||
// order_field: sorting[0].id,
|
||||
// order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||
// filter: JSON.stringify(filter)
|
||||
// });
|
||||
const fetchAccount = async (page: number, limit: number, sorting: any, filter: any) => {
|
||||
try {
|
||||
const response = await GetData(`${API_URL}/user/list`, {
|
||||
limit: limit,
|
||||
page: page + 1,
|
||||
with_deleted: true,
|
||||
order_field: sorting[0].id,
|
||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||
filter: JSON.stringify(filter)
|
||||
});
|
||||
|
||||
// setAccounts(response?.data.list);
|
||||
console.log(response?.data.list);
|
||||
setAccounts(response?.data.list);
|
||||
|
||||
// return {
|
||||
// data: response?.data.list,
|
||||
// totalCount: response?.data.total_count
|
||||
// };
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// };
|
||||
return {
|
||||
data: response?.data.list,
|
||||
totalCount: response?.data.total_count
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
@ -83,14 +83,14 @@ const SearchDialog = () => {
|
||||
// console.log(municipios);
|
||||
return (
|
||||
<Dialog open={showSearchDialog} onOpenChange={(open) => handleSearchDialog(open)}>
|
||||
<DialogContent className="container-fixed max-w-96 flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||
<DialogContent className="container-fixed max-w-[700px] flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||
<DialogTitle></DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
<DialogHeader className="p-2 border-0">
|
||||
<div className="flex items-center justify-between flex-wrap grow">
|
||||
<div className="flex flex-col justify-center">
|
||||
<h1 className="text-xl font-semibold leading-none text-gray-900">
|
||||
Search Postu Administravo
|
||||
Search Postoadms
|
||||
</h1>
|
||||
<div className="flex items-center gap-2 text-sm font-normal text-gray-700"></div>
|
||||
</div>
|
||||
@ -116,7 +116,7 @@ const SearchDialog = () => {
|
||||
<div className="card-body grid-cols-6 gap-5 p-0">
|
||||
<div className="grid grid-cols-8 gap-2 w-full items-center">
|
||||
<label className="form-label flex items-center gap-1 col-span-2">
|
||||
Name<span className="text-red-500">*</span>
|
||||
Municipio Name<span className="text-red-500">*</span>
|
||||
</label>
|
||||
|
||||
<Select
|
||||
@ -147,7 +147,7 @@ const SearchDialog = () => {
|
||||
|
||||
{isFound && postoadms.length > 0 && (
|
||||
<div className="mt-4 border-t pt-4">
|
||||
<h2 className="text-md font-semibold">Sucos: </h2>
|
||||
<h2 className="text-md font-semibold">Postu Administravo: </h2>
|
||||
<br />
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm form-hint">
|
||||
|
||||
@ -17,8 +17,10 @@ const ListToolbar = () => {
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search Postu Administrativo"
|
||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
value={(table.getColumn('posto_adms_name')?.getFilterValue() as string) ?? ''}
|
||||
onChange={(event) =>
|
||||
table.getColumn('posto_adms_name')?.setFilterValue(event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
|
||||
@ -82,7 +82,7 @@ const SearchDialog = () => {
|
||||
// console.log(municipios);
|
||||
return (
|
||||
<Dialog open={showSearchDialog} onOpenChange={(open) => handleSearchDialog(open)}>
|
||||
<DialogContent className="container-fixed max-w-96 flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||
<DialogContent className="container-fixed max-w-[700px] flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||
<DialogTitle></DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
<DialogHeader className="p-2 border-0">
|
||||
@ -115,18 +115,18 @@ const SearchDialog = () => {
|
||||
<div className="card-body grid-cols-6 gap-5 p-0">
|
||||
<div className="grid grid-cols-8 gap-2 w-full items-center">
|
||||
<label className="form-label flex items-center gap-1 col-span-2">
|
||||
Name<span className="text-red-500">*</span>
|
||||
PostoAdms Name<span className="text-red-500">*</span>
|
||||
</label>
|
||||
|
||||
<Select
|
||||
value={formField.id.toString()}
|
||||
onValueChange={(target) => {
|
||||
const selectedPostoadms = postoAdms.find((m) => m.id.toString() === target);
|
||||
const selectedPostoadms = postoAdms.find((m) => m.posto_adms_id.toString() === target);
|
||||
if (selectedPostoadms) {
|
||||
setFormField({
|
||||
...formField,
|
||||
id: selectedPostoadms.id,
|
||||
name: selectedPostoadms.name
|
||||
id: selectedPostoadms.posto_adms_id,
|
||||
name: selectedPostoadms.posto_adms_name
|
||||
});
|
||||
}
|
||||
}}
|
||||
@ -136,8 +136,8 @@ const SearchDialog = () => {
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{postoAdms.map((postoAdm) => (
|
||||
<SelectItem key={postoAdm.id} value={postoAdm.id.toString()}>
|
||||
{postoAdm.name}
|
||||
<SelectItem key={postoAdm.posto_adms_id} value={postoAdm.posto_adms_id.toString()}>
|
||||
{postoAdm.posto_adms_name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
@ -146,7 +146,7 @@ const SearchDialog = () => {
|
||||
|
||||
{isFound && sucos.length > 0 && (
|
||||
<div className="mt-4 border-t pt-4">
|
||||
<h2 className="text-md font-semibold">Postu Administravo: </h2>
|
||||
<h2 className="text-md font-semibold">Sucos: </h2>
|
||||
<br />
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm form-hint">
|
||||
|
||||
@ -9,8 +9,9 @@ import { useNavigate, useParams } from 'react-router';
|
||||
import ListToolbar from '../blocks/ListToolbar';
|
||||
|
||||
interface PostoAdmsProps {
|
||||
id: number;
|
||||
name: string;
|
||||
posto_adms_id: number;
|
||||
posto_adms_name: string;
|
||||
municipios_name: string;
|
||||
}
|
||||
|
||||
interface ContextProps {
|
||||
@ -82,7 +83,7 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
|
||||
const columns = useMemo<ColumnDef<any>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorFn: (row) => row.id,
|
||||
accessorFn: (row) => row.posto_adms_id,
|
||||
id: 'id',
|
||||
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
||||
enableSorting: true,
|
||||
@ -92,9 +93,21 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.name,
|
||||
id: 'name',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Municipios Name" column={column} />,
|
||||
accessorFn: (row) => row.posto_adms_name,
|
||||
id: 'posto_adms_name',
|
||||
header: ({ column }) => (
|
||||
<DataGridColumnHeader title="Posto Administrativo Name" column={column} />
|
||||
),
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
meta: {
|
||||
headerClassName: 'w-[1000px]'
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.municipios_name,
|
||||
id: 'municipios_name',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Municipio Name" column={column} />,
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
meta: {
|
||||
|
||||
Reference in New Issue
Block a user