import { Box, Button, Card, CardBody, CardControls, CardHeader, Icon, Tag } from '@rocket.chat/fuselage'; import { useRole, useSettingSetValue, useSetting, useToastMessageDispatch, useRouter } from '@rocket.chat/ui-contexts'; import type { ComponentProps } from 'react'; import { useTranslation } from 'react-i18next'; import { useIsEnterprise } from '../../../hooks/useIsEnterprise'; import CustomHomepageContent from '../CustomHomePageContent'; const CustomContentCard = (props: Omit, 'type'>) => { const { t } = useTranslation(); const dispatchToastMessage = useToastMessageDispatch(); const router = useRouter(); const { data } = useIsEnterprise(); const isAdmin = useRole('admin'); const customContentBody = useSetting('Layout_Home_Body', ''); const isCustomContentBodyEmpty = customContentBody === ''; const isCustomContentVisible = useSetting('Layout_Home_Custom_Block_Visible', false); const isCustomContentOnly = useSetting('Layout_Custom_Body_Only', false); const setCustomContentVisible = useSettingSetValue('Layout_Home_Custom_Block_Visible'); const setCustomContentOnly = useSettingSetValue('Layout_Custom_Body_Only'); const handleChangeCustomContentVisibility = async () => { try { await setCustomContentVisible(!isCustomContentVisible); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); } }; const handleOnlyShowCustomContent = async () => { try { await setCustomContentOnly(!isCustomContentOnly); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); } }; const isEnterprise = data?.isEnterprise; const willNotShowCustomContent = isCustomContentBodyEmpty || !isCustomContentVisible; const userVisibilityTooltipText = isCustomContentVisible ? t('Now_Its_Visible_For_Everyone') : t('Now_Its_Visible_Only_For_Admins'); let customContentOnlyTooltipText = t('It_Will_Hide_All_Other_Content_Blocks_In_The_Homepage'); if (willNotShowCustomContent) { customContentOnlyTooltipText = t('Action_Available_After_Custom_Content_Added_And_Visible'); } else if (isCustomContentOnly) { customContentOnlyTooltipText = t('It_Will_Show_All_Other_Content_Blocks_In_The_Homepage'); } if (isAdmin) { return ( {willNotShowCustomContent ? t('Not_Visible_To_Workspace') : t('Visible_To_Workspace')} {isCustomContentBodyEmpty ? t('Homepage_Custom_Content_Default_Message') : } ); } if (!willNotShowCustomContent && !isCustomContentOnly) { return ( ); } return ; }; export default CustomContentCard;