import { Alert, Col, Container, Form, Navbar, Row } from 'react-bootstrap';
import { Helmet } from 'react-helmet';
import { useTranslation } from 'react-i18next';
+import { useParams } from 'react-router-dom';
import toastr from 'toastr';
import User from '../app/User';
const [guesses, setGuesses] = React.useState([]);
const [winners, setWinners] = React.useState([]);
+ const { channelId } = useParams();
const { t } = useTranslation();
+ React.useEffect(() => {
+ if (!channelId) return;
+ const fetchChannel = async () => {
+ const response = await axios.get(`/api/channels`, {
+ params: {
+ id: [channelId],
+ manageable: 1,
+ },
+ });
+ if (response.data.length) {
+ setChannel(response.data[0]);
+ }
+ };
+ fetchChannel();
+ }, [channelId]);
+
React.useEffect(() => {
if (!channel) {
setGuesses([]);
joinable
manageable
onChange={({ channel }) => { setChannel(channel); }}
- value={channel ? channel.id : ''}
+ readOnly={!!(channelId && channel)}
+ value={channel ? channel.id : channelId}
/>
<User />
</Container>