fix filter
This commit is contained in:
@ -17,9 +17,9 @@ const ListToolbar = () => {
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search Postu"
|
||||
value={(table.getColumn('posto_adms_name')?.getFilterValue() as string) ?? ''}
|
||||
value={(table.getColumn('PostoAdms_name')?.getFilterValue() as string) ?? ''}
|
||||
onChange={(event) =>
|
||||
table.getColumn('posto_adms_name')?.setFilterValue(event.target.value)
|
||||
table.getColumn('PostoAdms_name')?.setFilterValue(event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
@ -83,7 +83,7 @@ const SearchDialog = () => {
|
||||
setIsFound(false);
|
||||
setSucos([]);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Dialog open={showSearchDialog} onOpenChange={handleSearchDialog}>
|
||||
<DialogContent className="container-fixed max-w-[700px] flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||
@ -128,17 +128,17 @@ const SearchDialog = () => {
|
||||
<CommandGroup>
|
||||
{postoAdms.map((postoAdm) => (
|
||||
<CommandItem
|
||||
key={postoAdm.posto_adms_id}
|
||||
value={postoAdm.posto_adms_name}
|
||||
key={postoAdm.PostoAdms_id}
|
||||
value={postoAdm.PostoAdms_name}
|
||||
onSelect={() => {
|
||||
setFormField({
|
||||
id: postoAdm.posto_adms_id,
|
||||
name: postoAdm.posto_adms_name
|
||||
id: postoAdm.PostoAdms_id,
|
||||
name: postoAdm.PostoAdms_name
|
||||
});
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
{postoAdm.posto_adms_name}
|
||||
{postoAdm.PostoAdms_name}
|
||||
</CommandItem>
|
||||
))}
|
||||
</CommandGroup>
|
||||
|
||||
@ -9,8 +9,8 @@ import ListToolbar from '../blocks/ListToolbar';
|
||||
import { useCallApi } from '@/hooks';
|
||||
|
||||
interface PostoAdmsProps {
|
||||
posto_adms_id: number;
|
||||
posto_adms_name: string;
|
||||
PostoAdms_id: number;
|
||||
PostoAdms_name: string;
|
||||
municipios_name: string;
|
||||
}
|
||||
|
||||
@ -84,8 +84,9 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
|
||||
const columns = useMemo<ColumnDef<any>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorFn: (row) => row.posto_adms_id,
|
||||
id: 'id',
|
||||
// accessorFn: (row) => row.PostoAdms_id,
|
||||
// id: 'PostoAdms_id',
|
||||
accessorKey: 'PostoAdms_id',
|
||||
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
@ -96,7 +97,7 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
|
||||
{
|
||||
// accessorFn: (row) => row.posto_adms_name,
|
||||
// id: 'posto_adms_name',
|
||||
accessorKey: 'posto_adms_name',
|
||||
accessorKey: 'PostoAdms_name',
|
||||
header: ({ column }) => (
|
||||
<DataGridColumnHeader title="Posto Administrativo Name" column={column} />
|
||||
),
|
||||
@ -127,13 +128,13 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
|
||||
<>
|
||||
<button
|
||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||
onClick={() => handleEditDialog(true, row.posto_adms_id)}
|
||||
onClick={() => handleEditDialog(true, row.PostoAdms_id)}
|
||||
>
|
||||
<KeenIcon icon="notepad-edit" />
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||
onClick={() => handleDeleteDialog(true, row.posto_adms_id)}
|
||||
onClick={() => handleDeleteDialog(true, row.PostoAdms_id)}
|
||||
>
|
||||
<KeenIcon icon="trash" />
|
||||
</button>
|
||||
@ -151,16 +152,17 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
|
||||
|
||||
const getPostoAdmsLists = async (page: number, limit: number, sorting: any, filter: any) => {
|
||||
try {
|
||||
sorting: sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
|
||||
const response = await GetData(`${API_URL}/postoadms/list`, {
|
||||
limit,
|
||||
page: page + 1,
|
||||
with_deleted: false,
|
||||
order_field: sorting[0].id,
|
||||
order_direction: sorting[0].desc ? 'DESC' : 'ASC'
|
||||
order_direction: sorting[0].desc ? 'DESC' : 'ASC',
|
||||
filter: JSON.stringify(filter)
|
||||
});
|
||||
// console.log(response.data);
|
||||
console.log(response?.data);
|
||||
// const sortedList = response.data.data.list.sort((a: PostoAdmsProps, b: PostoAdmsProps) => {
|
||||
// if (a.name < b.name) return -1;
|
||||
// if (a.name > b.name) return 1;
|
||||
|
||||
Reference in New Issue
Block a user