fix postoadms

This commit is contained in:
Wikzyy
2025-03-13 14:49:35 +07:00
parent 4eaccf2472
commit 07918aafed
3 changed files with 28 additions and 15 deletions

View File

@ -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'}>

View File

@ -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>
Postu Administrativo 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">

View File

@ -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,8 +93,8 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
}
},
{
accessorFn: (row) => row.name,
id: 'name',
accessorFn: (row) => row.posto_adms_name,
id: 'posto_adms_name',
header: ({ column }) => (
<DataGridColumnHeader title="Posto Administrativo Name" column={column} />
),
@ -103,6 +104,16 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
headerClassName: 'w-[1000px]'
}
},
{
accessorFn: (row) => row.municipios_name,
id: 'municipios_name',
header: ({ column }) => <DataGridColumnHeader title="Municipio Name" column={column} />,
enableSorting: true,
enableHiding: false,
meta: {
headerClassName: 'w-[1000px]'
}
},
{
id: 'actions',
header: ({ column }) => <DataGridColumnHeader title="Actions" column={column} />,