Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add axios request for room current num #93

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/main/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import blockInterface from '../../interface/block.interface';
import MyAvatar from '../../assets/avatar/MyAvatar';
import ThemeImage from '../atoms/ThemeImages';
import { ReactComponent as Bar } from '../../assets/svg/Room/Bar.svg';
import useRoom from '../../hooks/useRoom';

export default function Block({
isMain,
Expand All @@ -20,12 +21,20 @@ export default function Block({
}: blockInterface) {
const navigate = useNavigate();
const { nickname } = UserStore();
const { data } = useRoom(itemId);

const enterRoom = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
if (!nickname) {
alert('로그인이 필요합니다.');
return;
}

if (data.current === data.total) {
alert('방이 이미 초과되었습니다.');
return;
}

navigate(`/ready/${itemId}`);
};
return (
Expand Down