Commit e8dcd004 authored by Chunchi Che's avatar Chunchi Che

fix

parent e62cf7c5
Pipeline #21025 passed with stages
in 18 minutes and 6 seconds
...@@ -16,13 +16,14 @@ const CheckCounterModal = () => { ...@@ -16,13 +16,14 @@ const CheckCounterModal = () => {
const counterName = fetchStrings("!counter", `0x${state.counterType!}`); const counterName = fetchStrings("!counter", `0x${state.counterType!}`);
const min = state.min || 0; const min = state.min || 0;
const options = state.options; const options = state.options;
const [selected, setSelected] = useState(options.map((_) => 0)); const [selected, setSelected] = useState(new Array(options.length));
const finishable = selected.reduce((sum, current) => sum + current, 0) == min; const sum = selected.reduce((sum, current) => sum + current, 0);
const finishable = sum == min;
const draggleRef = useRef<HTMLDivElement>(null); const draggleRef = useRef<HTMLDivElement>(null);
const onFinish = () => { const onFinish = () => {
sendSelectCounterResponse(selected); sendSelectCounterResponse(selected);
dispatch(clearCheckCounter); dispatch(clearCheckCounter());
}; };
return ( return (
...@@ -59,10 +60,10 @@ const CheckCounterModal = () => { ...@@ -59,10 +60,10 @@ const CheckCounterModal = () => {
max={option.max} max={option.max}
defaultValue={0} defaultValue={0}
onChange={(value) => { onChange={(value) => {
setSelected((prev) => ({ let newSelected = [...selected];
...prev, newSelected[idx] = value || 0;
[idx]: value || 0,
})); setSelected(newSelected);
}} }}
/> />
</Card> </Card>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment