Skip to content

Commit

Permalink
change: prevent render competence add duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
julio-ufpb committed Dec 31, 2023
1 parent ff53b06 commit d688469
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
14 changes: 5 additions & 9 deletions src/pages/Profile/CompetencesSettings/CompetencesSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { useContext, useState } from "react";
import { ProfileContext } from "@/pages/Profile";
import { Level, LevelToLabel } from "@/types/Competence";
import { UniversimeApi } from "@/services/UniversimeApi";
import { deactivateButtonWhile, setStateAsValue } from "@/utils/tsxUtils";
import * as SwalUtils from "@/utils/sweetalertUtils";
import { FormInputs, UniversiForm } from "@/components/UniversiForm/UniversiForm";

import './CompetencesSettings.less'
Expand All @@ -13,12 +11,8 @@ export function CompetencesSettings() {
const profileContext = useContext(ProfileContext)
const editCompetence = profileContext?.editCompetence ?? null;

const [competenceTypeId, setCompetenceTypeId] = useState<string>(editCompetence?.competenceType.id ?? "");
const [competenceLevel, setCompetenceLevel] = useState<Level | "">(editCompetence?.level ?? "");
const [description, setDescription] = useState<string>(editCompetence?.description ?? "");

return (
profileContext === null ? null :
profileContext &&
<UniversiForm

Check warning on line 16 in src/pages/Profile/CompetencesSettings/CompetencesSettings.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/Profile/CompetencesSettings/CompetencesSettings.tsx#L16

Added line #L16 was not covered by tests
formTitle={editCompetence?.id ? "Editar competência" : "Adicionar competência"}
objects={[
Expand All @@ -35,10 +29,12 @@ export function CompetencesSettings() {
required: true
},
{
DTOName: "description", label: "description", type: FormInputs.HIDDEN, value: description
DTOName: "description", label: "description", type: FormInputs.HIDDEN,
value: editCompetence?.description ?? ""
},
{
DTOName: "competenceId", label: "competenceId", type: FormInputs.HIDDEN, value: editCompetence?.id
DTOName: "competenceId", label: "competenceId", type: FormInputs.HIDDEN,
value: editCompetence?.id
}
]}
requisition={ editCompetence?.id ? UniversimeApi.Competence.update : UniversimeApi.Competence.create }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ export function CurriculumAbility() {
: <p className="empty-competences">Nenhuma competência cadastrada.</p>

Check warning on line 143 in src/pages/Profile/ProfileCurriculum/Competences/Ability/CurriculumAbility.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/Profile/ProfileCurriculum/Competences/Ability/CurriculumAbility.tsx#L143

Added line #L143 was not covered by tests
}
</div>

{ profileContext.editCompetence !== undefined &&
<UniversiModal>
<CompetencesSettings />
</UniversiModal>
}
</div>
);
}

0 comments on commit d688469

Please sign in to comment.