Skip to content

Commit 99c14b4

Browse files
Add starting round safety lock
1 parent 2ab5b35 commit 99c14b4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

client/src/components/forms.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ interface NumInputProps {
3737
min: number
3838
max: number
3939
className?: string
40+
disabled?: boolean
4041
value: number
4142
changeValue: (newValue: number) => void
4243
}
@@ -82,7 +83,12 @@ export const NumInput: React.FC<NumInputProps> = (props) => {
8283

8384
return (
8485
<input
85-
className={'border border-black py-0.5 px-1 rounded-md w-12 ' + (props.className ?? '')}
86+
className={
87+
'border border-black py-0.5 px-1 rounded-md w-12 ' +
88+
(props.disabled ? 'opacity-50 ' : '') +
89+
(props.className ?? '')
90+
}
91+
disabled={props.disabled}
8692
type="number"
8793
value={tempValue ?? props.value}
8894
onBlur={handleInputBlur}

client/src/components/sidebar/tournament/tournament.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Button } from '../../button'
44
import { FiUpload } from 'react-icons/fi'
55
import Tournament, { JsonTournamentGame } from '../../../playback/Tournament'
66
import { NumInput } from '../../forms'
7+
import { BsLock, BsUnlock } from 'react-icons/bs'
78

89
interface TournamentPageProps {
910
open: boolean
@@ -13,7 +14,10 @@ export const TournamentPage: React.FC<TournamentPageProps> = ({ open }) => {
1314
const context = useAppContext()
1415
const inputRef = React.useRef<HTMLInputElement | null>()
1516

17+
const [locked, setLocked] = React.useState(false)
18+
1619
const updateMinRound = (val: number) => {
20+
if (locked) return
1721
context.setState((prevState) => ({ ...prevState, tournamentMinRound: val }))
1822
}
1923

@@ -51,14 +55,25 @@ export const TournamentPage: React.FC<TournamentPageProps> = ({ open }) => {
5155
<span>
5256
<b>Participants:</b> {tournament.participantCount}
5357
</span>
54-
<span className="mt-[-3px]">
58+
<span className="flex items-center mt-[-3px]">
5559
<b className="mr-2">Starting Round:</b>
5660
<NumInput
61+
disabled={locked}
5762
value={context.state.tournamentMinRound}
5863
changeValue={updateMinRound}
5964
min={1}
6065
max={tournament.maxRound}
6166
/>
67+
<button
68+
className="ml-1 hover:bg-lightHighlight p-[0.2rem] rounded-md"
69+
onClick={() => setLocked(!locked)}
70+
>
71+
{locked ? (
72+
<BsLock className="w-[15px] h-[15px]" />
73+
) : (
74+
<BsUnlock className="w-[15px] h-[15px]" />
75+
)}
76+
</button>
6277
</span>
6378
</div>
6479
)}

0 commit comments

Comments
 (0)