Skip to content

Commit

Permalink
Adicionando US53 (Pequeno bug a corrigir)
Browse files Browse the repository at this point in the history
Co-authored-by: Artur <[email protected]>
  • Loading branch information
JoaoBarreto03 and ArturRSA19 committed Dec 9, 2023
1 parent 20c9766 commit 4fca8b2
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions frontend/src/pages/ViewPlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { saveAs } from 'file-saver';

const ViewPlan = () => {
const { id } = useParams();
const { idDrill } = useParams();
const [title, setTitle] = useState('');
const [titleAux, setTitleAux] = useState('');
const [goals, setGoals] = useState('');
Expand Down Expand Up @@ -41,6 +42,7 @@ const ViewPlan = () => {
userId = '';
}


const [titleDrill, setTitleDrill] = useState('');
const [descriptionDrill, setDescriptionDrill] = useState('');
const [observationsDrill, setObservationsDrill] = useState('');
Expand All @@ -53,13 +55,11 @@ const ViewPlan = () => {

const [drillUpdated, setDrillUpdated] = useState({
id: '',
title: titleDrill,
description: descriptionDrill,
observations: observationsDrill,
classPlanId: id,
title: '',
description: '',
observations: '',
classPlanId: '',
});



async function loadData() {
if (id != null) {
Expand All @@ -69,8 +69,8 @@ const ViewPlan = () => {
}

async function loadDataDrill() {
if (id != null) {
const response = await drill.getById(id);
if (idDrill != null) {
const response = await drill.getById(idDrill);
setDrillUpdated(response.data);
}
}
Expand Down Expand Up @@ -154,10 +154,10 @@ const ViewPlan = () => {

useEffect(() => {
loadDataDrill();
setTitleDrill(titleDrill);
setDescriptionDrill(descriptionDrill);
setObservationsDrill(observationsDrill);
}, [titleDrill, descriptionDrill, observationsDrill]);
setTitleDrill(drillUpdated.title);
setDescriptionDrill(drillUpdated.description);
setObservationsDrill(drillUpdated.observations);
}, [drillUpdated]);



Expand Down Expand Up @@ -252,11 +252,10 @@ const ViewPlan = () => {
goals: planUpdated.goals,
observations: planUpdated.observations,
},
drills: drills.map((drill) => ({
title: drillUpdated.title,
description: drillUpdated.description,
observations: drillUpdated.observations,

drills: drills.map((Drill) => ({
title: Drill.title || '',
description: Drill.description || '',
observations: Drill.observations || '',
})),
};

Expand Down

0 comments on commit 4fca8b2

Please sign in to comment.