2022-11-27 18:41:04 +03:00
|
|
|
|
import React, {useState, useCallback, useRef} from 'react';
|
2022-11-27 17:45:32 +03:00
|
|
|
|
import { getFeatures } from '@ijl/cli';
|
2022-11-27 16:34:37 +03:00
|
|
|
|
|
|
|
|
|
import logo from '../assets/logo-white.svg';
|
|
|
|
|
import arrow from '../assets/36-arrow-right.svg';
|
|
|
|
|
|
2022-11-27 17:45:32 +03:00
|
|
|
|
import { Keyboard } from '../components/keyboard';
|
|
|
|
|
|
2022-11-27 16:34:37 +03:00
|
|
|
|
import {
|
|
|
|
|
MainWrapper,
|
|
|
|
|
InputElement,
|
|
|
|
|
InputLabel,
|
|
|
|
|
InputWrapper,
|
|
|
|
|
LogoImg,
|
|
|
|
|
ArrowImg,
|
|
|
|
|
IconButton,
|
|
|
|
|
StartWrapper,
|
|
|
|
|
StartI,
|
|
|
|
|
StartInput,
|
|
|
|
|
StartLabel,
|
|
|
|
|
} from './style';
|
2022-11-27 18:41:04 +03:00
|
|
|
|
import {socket} from "../socket";
|
2022-11-27 16:34:37 +03:00
|
|
|
|
|
2022-11-27 17:45:32 +03:00
|
|
|
|
const keyboardFeature = getFeatures('hub-video-start')?.keyboard;
|
|
|
|
|
|
2022-11-27 16:34:37 +03:00
|
|
|
|
const Input = ({ onStart }) => {
|
|
|
|
|
const [value, setValue] = useState('');
|
2022-11-27 17:45:32 +03:00
|
|
|
|
const [inFocuse, setInfocuse] = useState(false);
|
2022-11-27 16:34:37 +03:00
|
|
|
|
const handleChange = useCallback(event => {
|
|
|
|
|
setValue(event.target.value.toUpperCase())
|
|
|
|
|
}, [setValue]);
|
|
|
|
|
|
|
|
|
|
const handleSubmit = useCallback((event) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (value === 'SBER') {
|
|
|
|
|
onStart()
|
|
|
|
|
}
|
|
|
|
|
}, [value])
|
|
|
|
|
|
|
|
|
|
return (
|
2022-11-27 17:45:32 +03:00
|
|
|
|
<>
|
|
|
|
|
<form onSubmit={handleSubmit}>
|
|
|
|
|
<InputWrapper>
|
|
|
|
|
<InputLabel
|
|
|
|
|
htmlFor='input'
|
|
|
|
|
>
|
|
|
|
|
Ввод:
|
|
|
|
|
</InputLabel>
|
|
|
|
|
<InputElement
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
onFocus={() => setInfocuse(true)}
|
|
|
|
|
id="input"
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
/>
|
|
|
|
|
<IconButton type="submit">
|
|
|
|
|
<ArrowImg src={arrow} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</InputWrapper>
|
|
|
|
|
</form>
|
|
|
|
|
{keyboardFeature && inFocuse && (
|
|
|
|
|
<Keyboard onChange={setValue} />
|
|
|
|
|
)}
|
|
|
|
|
</>
|
2022-11-27 16:34:37 +03:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Start = () => {
|
2022-11-27 18:41:04 +03:00
|
|
|
|
const socketRef = useRef({ sent: false })
|
|
|
|
|
|
|
|
|
|
const handleCheck = () => {
|
|
|
|
|
if (!socketRef.current.sent) {
|
|
|
|
|
socket.emit('play')
|
|
|
|
|
socketRef.current.sent = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-27 16:34:37 +03:00
|
|
|
|
return (
|
|
|
|
|
<StartWrapper>
|
|
|
|
|
<StartInput
|
|
|
|
|
id="check"
|
|
|
|
|
type="checkbox"
|
2022-11-27 18:41:04 +03:00
|
|
|
|
onChange={handleCheck}
|
2022-11-27 16:34:37 +03:00
|
|
|
|
/>
|
|
|
|
|
<StartLabel
|
|
|
|
|
htmlFor='check'
|
|
|
|
|
>
|
|
|
|
|
<StartI>СТАРТ</StartI>
|
|
|
|
|
</StartLabel>
|
|
|
|
|
</StartWrapper>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const MainPage = () => {
|
|
|
|
|
const [showStart, setShowStart] = useState(false);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<MainWrapper>
|
|
|
|
|
<LogoImg src={logo} />
|
|
|
|
|
{!showStart && <Input onStart={() => setShowStart(true)} />}
|
|
|
|
|
{showStart && <Start />}
|
|
|
|
|
</MainWrapper>
|
|
|
|
|
);
|
|
|
|
|
};
|