From 65954d2c3aef8b2515979dd288e49499d4a31d6c Mon Sep 17 00:00:00 2001 From: Gyeongho Yang Date: Tue, 5 Nov 2024 23:03:39 +0900 Subject: [PATCH] refactor: send new option as param when selectable --- .../pages/enhance/6-execute/potential/potential.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/enhance/6-execute/potential/potential.tsx b/frontend/src/pages/enhance/6-execute/potential/potential.tsx index d27c62a..e736f1f 100644 --- a/frontend/src/pages/enhance/6-execute/potential/potential.tsx +++ b/frontend/src/pages/enhance/6-execute/potential/potential.tsx @@ -69,6 +69,7 @@ export default function Potential({ const [newGrade, setNewGrade] = useState(); const [newOptions, setNewOptions] = useState([]); + const newOptionsRef = useRef(newOptions); const [conditionGrid, setConditionGrid] = useState( [] ); @@ -98,6 +99,9 @@ export default function Potential({ useEffect(() => { optionsRef.current = options; }, [options]); + useEffect(() => { + newOptionsRef.current = newOptions; + }, [newOptions]); useEffect(() => { gradeRef.current = grade; }, [grade]); @@ -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