agrega columna dinamica

mto
Freddy Heredia 2 years ago
parent f314811efd
commit 2da9f7904d

@ -21,14 +21,14 @@ interface Props {
export const ManyToOne: FC<Props> = ({ entity, control,columname,columnvalue }) => {
const [values, setValues] = useState([{id:0, nombre: 'Seleccione'}]);
const [values, setValues] = useState([{id:0, columnvalue: 'Seleccione'}]);
const [selectedIndex, setSelectedIndex] = React.useState<IndexPath | IndexPath[]>(new IndexPath(0));
const displayValue = values[(selectedIndex as IndexPath).row];
useEffect(() => {
async function fetchData() {
try {
const { data, error } = await useFetchWithAuth(entity.toLowerCase());
const result = data as {id: number, nombre: string}[]
const result = data as {id: number, columnvalue: string}[]
setValues (result);
console.log(entity.toLowerCase())
} catch (error) {
@ -60,7 +60,7 @@ export const ManyToOne: FC<Props> = ({ entity, control,columname,columnvalue })
{values.map((item) => (
<SelectItem
key={`select-option-${item.id}`}
title={item.nombre}
title={(item as { [columnvalue: string]: any }) [columnvalue]}
/>
))}
</Select>

Loading…
Cancel
Save