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