NotAvailableForGuest.tsx 793 B

12345678910111213141516171819202122232425262728293031
  1. import React, { type JSX } from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import { useIsGuestUser } from '~/states/context';
  4. import { NotAvailable } from './NotAvailable';
  5. type NotAvailableForGuestProps = {
  6. children: JSX.Element;
  7. };
  8. export const NotAvailableForGuest = React.memo(
  9. ({ children }: NotAvailableForGuestProps): JSX.Element => {
  10. const { t } = useTranslation();
  11. const isGuestUser = useIsGuestUser();
  12. const isDisabled = !!isGuestUser;
  13. const title = t('Not available for guest');
  14. return (
  15. <NotAvailable
  16. isDisabled={isDisabled}
  17. title={title}
  18. classNamePrefix="grw-not-available-for-guest"
  19. >
  20. {children}
  21. </NotAvailable>
  22. );
  23. },
  24. );
  25. NotAvailableForGuest.displayName = 'NotAvailableForGuest';