'use client' import React, { useEffect, useState } from 'react'; import { EditRoomForm } from './EditRoomForm'; import debounce from 'lodash/debounce'; import { createRoom } from '../../../actions/rooms'; import { Loader } from '../../view/Loader'; import { useRouter } from '../../../i18n/routing'; import { RoomsType } from '../../../types/rooms'; export const CreateRoom = ({ locale, jwt }: { locale: string, jwt: string }) => { const [roomId, setRoomId] = useState(); const [loading, setLoading] = useState(false); const router = useRouter(); const getRoom = debounce(() => { createRoom(locale, jwt) .then((data) => { setRoomId(data); }) .finally(() => { setLoading(false); }) }, 500); useEffect(() => { setLoading(true); getRoom(); }, []); return ( {roomId && ( router.push(`/account/rooms/${RoomsType.UPCOMING}`)} /> )} ) };