import type { FC } from 'react';

import useSelectCustomPage from '~/src/hooks/useSelectCustomPage';
import CustomPage from './index';

const DraftCustomPage: FC<{ customPageId: number }> = ({ customPageId }) => {
  const customPage = useSelectCustomPage(customPageId);

  if (!customPage) {
    throw new Error(`Custom page ${customPageId} missing in store`);
  }

  return (
    <CustomPage customPageId={customPageId} withRedirectIfNeeded={false} />
  );
};

export default DraftCustomPage;
