Skip to content

Commit

Permalink
Merge pull request #43 from fga-eps-mds/130-total-equipamento
Browse files Browse the repository at this point in the history
130 fix: pegando a quantidade correta de equipamentos
  • Loading branch information
DafneM authored Jun 21, 2023
2 parents 70b3648 + 63cb7ee commit ad59711
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/movement-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { format } from 'date-fns';
import { useCallback, useEffect, useState } from 'react';
import { AxiosResponse } from 'axios';
import { useForm } from 'react-hook-form';
import { set } from 'lodash';
import { TIPOS_LOTACAO } from '@/constants/movements';
import { api } from '../../config/lib/axios';
import { Input } from '../form-fields/input';
Expand Down Expand Up @@ -164,9 +165,12 @@ export default function MovementForm({
setEquipments(data);
} else {
setEquipments(selectedEquipmentToMovement!);
const materiaisSave: string[] = [];
selectedEquipmentToMovement?.forEach((equip) => {
setMateriais((prev) => [...prev, equip.id]);
materiaisSave.push(equip.id);
});
setMateriais(Array.from(new Set(materiaisSave)));
}
} catch (error) {
setEquipments([]);
Expand Down Expand Up @@ -237,7 +241,7 @@ export default function MovementForm({
</Text>
<Text>
<>
<strong>Total Equipamentos:</strong> {1}
<strong>Total Equipamentos:</strong> {materiais?.length}
</>
</Text>
</Flex>
Expand Down

0 comments on commit ad59711

Please sign in to comment.