2023-04-16 12:18:29 +03:00
|
|
|
|
import React, {useState, useCallback, useRef, useEffect} from 'react';
|
2022-11-27 16:34:37 +03:00
|
|
|
|
|
|
|
|
|
import arrow from '../assets/36-arrow-right.svg';
|
2022-11-27 17:45:32 +03:00
|
|
|
|
|
2022-11-27 16:34:37 +03:00
|
|
|
|
import {
|
|
|
|
|
MainWrapper,
|
|
|
|
|
InputElement,
|
|
|
|
|
InputLabel,
|
|
|
|
|
InputWrapper,
|
|
|
|
|
ArrowImg,
|
|
|
|
|
IconButton,
|
|
|
|
|
} from './style';
|
2023-04-16 12:18:29 +03:00
|
|
|
|
import { Journal } from './Journal';
|
2022-11-27 17:45:32 +03:00
|
|
|
|
|
2022-11-27 16:34:37 +03:00
|
|
|
|
const Input = ({ onStart }) => {
|
|
|
|
|
const [value, setValue] = useState('');
|
2022-11-29 22:40:13 +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]);
|
2022-11-29 21:36:30 +03:00
|
|
|
|
const inputRef = useRef<HTMLInputElement>(null);
|
2022-11-27 16:34:37 +03:00
|
|
|
|
|
2023-04-16 12:18:29 +03:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
const pass = localStorage.getItem('pass')
|
|
|
|
|
|
|
|
|
|
if (pass) {
|
|
|
|
|
onStart();
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
2022-11-27 16:34:37 +03:00
|
|
|
|
const handleSubmit = useCallback((event) => {
|
|
|
|
|
event.preventDefault();
|
2023-04-16 12:18:29 +03:00
|
|
|
|
localStorage.setItem('pass', 'true')
|
|
|
|
|
if (value === 'OYB0Y') {
|
2022-11-27 16:34:37 +03:00
|
|
|
|
onStart()
|
|
|
|
|
}
|
|
|
|
|
}, [value])
|
|
|
|
|
|
|
|
|
|
return (
|
2022-11-27 17:45:32 +03:00
|
|
|
|
<>
|
|
|
|
|
<form onSubmit={handleSubmit}>
|
|
|
|
|
<InputWrapper>
|
|
|
|
|
<InputLabel
|
|
|
|
|
htmlFor='input'
|
|
|
|
|
>
|
2023-04-16 12:18:29 +03:00
|
|
|
|
Введите пароль:
|
2022-11-27 17:45:32 +03:00
|
|
|
|
</InputLabel>
|
|
|
|
|
<InputElement
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
onFocus={() => setInfocuse(true)}
|
2022-11-29 21:36:30 +03:00
|
|
|
|
ref={inputRef}
|
2022-11-27 17:45:32 +03:00
|
|
|
|
id="input"
|
2023-04-16 12:18:29 +03:00
|
|
|
|
type="password"
|
2022-11-27 17:45:32 +03:00
|
|
|
|
autoComplete="off"
|
|
|
|
|
/>
|
|
|
|
|
<IconButton type="submit">
|
|
|
|
|
<ArrowImg src={arrow} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</InputWrapper>
|
|
|
|
|
</form>
|
|
|
|
|
</>
|
2022-11-27 16:34:37 +03:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const MainPage = () => {
|
2023-04-16 12:18:29 +03:00
|
|
|
|
const [shoList, setShoList] = useState(false);
|
2022-11-27 16:34:37 +03:00
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<MainWrapper>
|
2023-04-16 12:18:29 +03:00
|
|
|
|
{!shoList && <Input onStart={() => setShoList(true)} />}
|
|
|
|
|
{shoList && <Journal />}
|
2022-11-27 16:34:37 +03:00
|
|
|
|
</MainWrapper>
|
|
|
|
|
);
|
|
|
|
|
};
|