NotAvailableForReadOnlyUser.tsx 743 B

12345678910111213141516171819202122232425262728
  1. import React from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import { useIsReadOnlyUser } from '~/stores/context';
  4. import { NotAvailable } from './NotAvailable';
  5. export const NotAvailableForReadOnlyUser: React.FC<{
  6. children: JSX.Element
  7. }> = React.memo(({ children }) => {
  8. const { t } = useTranslation();
  9. const { data: isReadOnlyUser } = useIsReadOnlyUser();
  10. const isDisabled = !!isReadOnlyUser;
  11. const title = t('Not available for read only user');
  12. return (
  13. <NotAvailable
  14. isDisabled={isDisabled}
  15. title={title}
  16. classNamePrefix="grw-not-available-for-read-only-user"
  17. >
  18. {children}
  19. </NotAvailable>
  20. );
  21. });
  22. NotAvailableForReadOnlyUser.displayName = 'NotAvailableForReadOnlyUser';