import { clsx } from "clsx"; import { FC, useEffect, useRef, useState } from "react"; import { useSelector } from "react-redux"; import { useSearchParams } from "react-router-dom"; import CharacterSheetSvg from "@dndbeyond/fontawesome-cache/svgs/light/address-card.svg"; import CheckMark from "@dndbeyond/fontawesome-cache/svgs/light/circle-check.svg"; import PdfSvg from "@dndbeyond/fontawesome-cache/svgs/light/file-pdf.svg"; import { Button } from "~/components/Button"; import { usePdfExport } from "~/hooks/usePdfExport"; import pageStyles from "~/subApps/builder/styles/page.module.css"; import { builderEnvSelectors, builderSelectors, } from "~/tools/js/CharacterBuilder/selectors"; import { appEnvSelectors } from "~/tools/js/Shared/selectors"; import { ClipboardUtils, MobileMessengerUtils } from "~/tools/js/Shared/utils"; import styles from "./styles.module.css"; export const WhatsNext: FC = () => { const characterId = useSelector(appEnvSelectors.getCharacterId); const characterListingUrl = useSelector( builderEnvSelectors.getProfileCharacterListingUrl ); const characterSheetUrl = useSelector( builderEnvSelectors.getCharacterSheetUrl ); const isCharacterSheetReady = useSelector( builderSelectors.checkIsCharacterSheetReady ); const [searchParams] = useSearchParams(); const isVttView = searchParams.get("view") === "vtt"; const urlInput = useRef(null); const { exportPdf, isLoading, isFinished, pdfUrl } = usePdfExport(); const [hasCopied, setHasCopied] = useState(false); useEffect(() => { if (pdfUrl !== null && isFinished) { urlInput.current?.focus(); urlInput.current?.setSelectionRange(0, urlInput.current.value.length); } }, [isFinished, pdfUrl]); const handleExportPdf = (evt: React.MouseEvent): void => { if (isCharacterSheetReady && !isLoading && !isFinished) { exportPdf(); } }; const handleClick = (evt: React.MouseEvent): void => { ClipboardUtils.copyTextToClipboard(pdfUrl === null ? "" : pdfUrl); setHasCopied(true); }; const handleMobileSheetShowClick = () => { if (characterId !== null && isCharacterSheetReady) { MobileMessengerUtils.sendMessage( MobileMessengerUtils.createShowCharacterSheetMessage(characterId) ); } }; const renderPdfData = (): React.ReactNode => { if (!isFinished || pdfUrl === null) { return null; } return (
{pdfUrl !== null && ( )}
); }; const getPdfButtonText = (): string => { if (isLoading) { return "Exporting PDF..."; } else if (isFinished) { return "PDF Generated"; } return "Export to PDF"; }; const ButtonLinkProps = { href: characterSheetUrl, }; return (

Once you have completed creating your character, you can view your statistics on the digital character sheet or export it for printing.

{!isVttView && ( )}
{renderPdfData()} {!isCharacterSheetReady && (

If you are unable to create a character due to missing options, return to the Home tab and change your source settings.

)}
{!isVttView && ( )}

Come Together

Most D&D characters don't work alone. Each character plays a role within a party, a group of adventurers working together for a common purpose. Talk to your fellow players and your DM to decide whether your characters know one another, how they met, and what sorts of quests the group might undertake.

A campaign is a series of adventures undertaken by your group's characters. If your DM has a campaign, you can join it by visiting the invite link for the campaign. You can also start your own.

{!isVttView && ( )}
); };