Skip to content

Commit

Permalink
refactor: send new option as param when selectable
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed Nov 5, 2024
1 parent 3273692 commit 65954d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/pages/enhance/6-execute/potential/potential.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function Potential({

const [newGrade, setNewGrade] = useState<POTENTIAL_GRADE>();
const [newOptions, setNewOptions] = useState<PotentialResponse[]>([]);
const newOptionsRef = useRef(newOptions);
const [conditionGrid, setConditionGrid] = useState<PotentialCondition[][]>(
[]
);
Expand Down Expand Up @@ -98,6 +99,9 @@ export default function Potential({
useEffect(() => {
optionsRef.current = options;
}, [options]);
useEffect(() => {
newOptionsRef.current = newOptions;
}, [newOptions]);
useEffect(() => {
gradeRef.current = grade;
}, [grade]);
Expand Down Expand Up @@ -141,7 +145,11 @@ export default function Potential({
}

const grade = gradeRef.current;
const options = optionsRef.current;
const options = selectable
? newOptionsRef.current.map((option) =>
option.name.replace("n", option.value.toString())
)
: optionsRef.current;
const guarantee =
grade && guaranteesRef.current[materialType]
? guaranteesRef.current[materialType][grade] ?? 0
Expand Down

0 comments on commit 65954d2

Please sign in to comment.