import CloseIcon from "@mui/icons-material/Close"; import VideocamIcon from "@mui/icons-material/Videocam"; import Box from "@mui/material/Box"; import Button from "@mui/material/Button"; import Dialog from "@mui/material/Dialog"; import DialogContent from "@mui/material/DialogContent"; import DialogContentText from "@mui/material/DialogContentText"; import DialogTitle from "@mui/material/DialogTitle"; import IconButton from "@mui/material/IconButton"; import React, { useEffect, useState } from "react"; import { useSelector } from "react-redux"; import { rulesEngineSelectors } from "@dndbeyond/character-rules-engine/es"; import { MaxCharactersDialog } from "~/components/MaxCharactersDialog"; import { useAuth } from "~/contexts/Authentication"; import { useClaimCharacter } from "~/hooks/useClaimCharacter"; import { appEnvSelectors } from "~/tools/js/Shared/selectors"; import ClaimConfirmationDialog from "./ClaimConfirmationDialog"; export const WatchTourDialog: React.FC = () => { const theme = useSelector(rulesEngineSelectors.getCharacterTheme); const { isDarkMode } = theme; const params = new URLSearchParams(globalThis.location.search); const campaignJoinCode = params.get("campaignJoinCode"); const isAssigned = params.get("isAssigned") === "false" ? false : true; const [isOpen, setIsOpen] = useState(false); const { characterSlotLimit, activeCharacterCount } = useSelector( appEnvSelectors.getCharacterSlots ); // Character slot limit is null for admin accounts const hasOpenSlot = characterSlotLimit === null || activeCharacterCount < characterSlotLimit; const [isMaxCharacterMessageOpen, setIsMaxCharacterMessageOpen] = useState(false); const user = useAuth(); const signedIn = !!user; const signupLink = `/create-account?returnUrl=${window.location.pathname}`; const [ claimCharacter, isClaimingCharacter, isFinishedClaimingCharacter, newCharacterId, campaignId, ] = useClaimCharacter({ campaignJoinCode, isAssigned, }); const open = () => { setIsOpen(true); }; const close = () => { setIsOpen(false); }; const handleClaim = () => { if (hasOpenSlot) { claimCharacter(); } else { setIsMaxCharacterMessageOpen(true); setIsOpen(false); } }; useEffect(() => { if (isFinishedClaimingCharacter) { setIsOpen(false); } }, [isFinishedClaimingCharacter]); return ( <> D&D Beyond Character Sheet Tour
For a complete guide to getting your game started, see{" "} How to Play Dungeons & Dragons Using D&D Beyond .
setIsMaxCharacterMessageOpen(false)} useMyCharactersLink /> {isFinishedClaimingCharacter && !!newCharacterId && ( )} ); }; export default WatchTourDialog;