Skip to content

Commit

Permalink
#130 fix: tornando o total de equipamentos dinamico.
Browse files Browse the repository at this point in the history
  • Loading branch information
JPedroCh committed Jun 21, 2023
1 parent 7a0aee0 commit 63cb7ee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions 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,8 +241,7 @@ export default function MovementForm({
</Text>
<Text>
<>
<strong>Total Equipamentos:</strong>{' '}
{selectedEquipmentToMovement?.length}
<strong>Total Equipamentos:</strong> {materiais?.length}
</>
</Text>
</Flex>
Expand Down

0 comments on commit 63cb7ee

Please sign in to comment.