update sucos
This commit is contained in:
@ -65,6 +65,9 @@ const SearchDialog = () => {
|
||||
|
||||
try {
|
||||
const response = await axios.get(`${API_URL}/sucos/aldeias/${id}`);
|
||||
console.log('API Response Data:', response.data.data);
|
||||
console.log('aldeias data:', aldeias);
|
||||
console.log('isFound:', isFound);
|
||||
|
||||
if (response.data.status) {
|
||||
setAldeias(response.data.data);
|
||||
@ -110,7 +113,7 @@ const SearchDialog = () => {
|
||||
</div>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
<DialogBody className="scrollable-y px-0 pb-0" ref={parentRef}>
|
||||
<DialogBody className="scrollable-x px-0 pb-0" ref={parentRef}>
|
||||
<div className="flex flex-col px-0">
|
||||
{alert.show && (
|
||||
<Alert variant="danger" className="mb-5">
|
||||
@ -127,12 +130,12 @@ const SearchDialog = () => {
|
||||
<Select
|
||||
value={formField.id?.toString() ?? ''}
|
||||
onValueChange={(target) => {
|
||||
const selectedSuco = sucos.find((m) => m.id.toString() === target);
|
||||
const selectedSuco = sucos.find((m) => m.sucos_id.toString() === target);
|
||||
if (selectedSuco) {
|
||||
setFormField({
|
||||
...formField,
|
||||
id: selectedSuco.id,
|
||||
name: selectedSuco.name
|
||||
id: selectedSuco.sucos_id,
|
||||
name: selectedSuco.sucos_name
|
||||
});
|
||||
}
|
||||
}}
|
||||
@ -142,11 +145,17 @@ const SearchDialog = () => {
|
||||
</SelectTrigger>
|
||||
|
||||
<SelectContent>
|
||||
{sucos?.map((suco) => (
|
||||
<SelectItem key={suco.id} value={suco.id}>
|
||||
{suco.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
{sucos?.map((suco) => {
|
||||
if (!suco.sucos_id) {
|
||||
console.error('suco.id is undefined or null', suco);
|
||||
return null; // Skip rendering this item if id is not valid
|
||||
}
|
||||
return (
|
||||
<SelectItem key={suco.sucos_id} value={suco.sucos_id.toString()}>
|
||||
{suco.sucos_name}
|
||||
</SelectItem>
|
||||
);
|
||||
})}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
@ -157,7 +166,7 @@ const SearchDialog = () => {
|
||||
<br />
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm form-hint">
|
||||
{aldeias.map((aldeiasID) => aldeiasID.name).join(', ')}
|
||||
{aldeias.map((aldeia) => aldeia.name).join(', ')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user