Skip to content

Commit 299cf82

Browse files
Fix undefined variables
1 parent ccf762f commit 299cf82

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

frontend/src/component/form/field/NumberField.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import FormHelperText from "@mui/material/FormHelperText";
44
import InputLabel from "@mui/material/InputLabel";
55
import OutlinedInput from "@mui/material/OutlinedInput";
66
import { useStore } from "@tanstack/react-form";
7-
import { useId } from "react";
7+
import { useId, useMemo } from "react";
88
import { useFieldContext } from "../../../contexts/formContext";
99

1010
type Props = {
@@ -20,6 +20,18 @@ export const NumberField = ({ label, id: idProp, min, max }: Props) => {
2020
id = idProp;
2121
}
2222

23+
const message = useMemo(() => {
24+
if (min !== undefined && max !== undefined) {
25+
return `Enter value between ${min} and ${max}`;
26+
} else if (min !== undefined) {
27+
return `Enter value above ${min}`;
28+
} else if (max !== undefined) {
29+
return `Enter value below ${max}`;
30+
} else {
31+
return `Enter a number`;
32+
}
33+
}, [min, max]);
34+
2335
return (
2436
<BaseNumberField.Root
2537
render={(props, state) => (
@@ -81,9 +93,7 @@ export const NumberField = ({ label, id: idProp, min, max }: Props) => {
8193
/>
8294
)}
8395
/>
84-
<FormHelperText sx={{ ml: 0, "&:empty": { mt: 0 } }}>
85-
{`Enter value between ${min} and ${max}`}
86-
</FormHelperText>
96+
<FormHelperText sx={{ ml: 0, "&:empty": { mt: 0 } }}>{message}</FormHelperText>
8797
</BaseNumberField.Root>
8898
);
8999
};

frontend/src/routes/_admin.admin.settings.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -531,20 +531,7 @@ const AnticheatSection = ({ tab, settings, mutate }: { tab: tabs; settings: Conf
531531
onSubmit: async ({ value }) => {
532532
mutate({
533533
...settings,
534-
anticheat: {
535-
action: value.action,
536-
duration: value.duration,
537-
enabled: value.enabled,
538-
max_aim_snap: value.max_aim_snap,
539-
max_psilent: value.max_psilent,
540-
max_bhop: value.max_bhop,
541-
max_fake_ang: value.max_fake_ang,
542-
max_cmd_num: value.max_cmd_num,
543-
max_too_many_connections: value.max_too_many_connections,
544-
max_cheat_cvar: value.max_cheat_cvar,
545-
max_oob_var: value.max_oob_var,
546-
max_invalid_user_cmd: value.max_invalid_user_cmd,
547-
},
534+
anticheat: value,
548535
});
549536
},
550537
defaultValues,

0 commit comments

Comments
 (0)