/* eslint-disable react/no-unescaped-entities */ import './WorkspaceLocked.styles.scss'; import type { TabsProps } from 'antd'; import { Alert, Button, Col, Collapse, Flex, List, Modal, Row, Skeleton, Space, Tabs, Typography, } from 'antd'; import updateCreditCardApi from 'api/billing/checkout'; import logEvent from 'api/common/logEvent'; import ROUTES from 'constants/routes'; import { useNotifications } from 'hooks/useNotifications'; import history from 'lib/history'; import { CircleArrowRight } from 'lucide-react'; import { useAppContext } from 'providers/App/App'; import { useCallback, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { useMutation } from 'react-query'; import { LicensePlatform } from 'types/api/licensesV3/getActive'; import { getFormattedDate } from 'utils/timeUtils'; import CustomerStoryCard from './CustomerStoryCard'; import InfoBlocks from './InfoBlocks'; import { customerStoriesData, enterpriseGradeValuesData, faqData, infoData, } from './workspaceLocked.data'; export default function WorkspaceBlocked(): JSX.Element { const { user, isFetchingActiveLicenseV3, trialInfo, activeLicenseV3, } = useAppContext(); const isAdmin = user.role === 'ADMIN'; const { notifications } = useNotifications(); const { t } = useTranslation(['workspaceLocked']); useEffect((): void => { logEvent('Workspace Blocked: Screen Viewed', {}); }, []); const handleContactUsClick = (): void => { logEvent('Workspace Blocked: Contact Us Clicked', {}); }; const handleTabClick = (key: string): void => { logEvent('Workspace Blocked: Screen Tabs Clicked', { tabKey: key }); }; const handleCollapseChange = (key: string | string[]): void => { const lastKey = Array.isArray(key) ? key.slice(-1)[0] : key; logEvent('Workspace Blocked: Screen Tab FAQ Item Clicked', { panelKey: lastKey, }); }; useEffect(() => { if (!isFetchingActiveLicenseV3) { const shouldBlockWorkspace = trialInfo?.workSpaceBlock; if ( !shouldBlockWorkspace || activeLicenseV3?.platform === LicensePlatform.SELF_HOSTED ) { history.push(ROUTES.APPLICATION); } } }, [ isFetchingActiveLicenseV3, trialInfo?.workSpaceBlock, activeLicenseV3?.platform, ]); const { mutate: updateCreditCard, isLoading } = useMutation( updateCreditCardApi, { onSuccess: (data) => { if (data.payload?.redirectURL) { const newTab = document.createElement('a'); newTab.href = data.payload.redirectURL; newTab.target = '_blank'; newTab.rel = 'noopener noreferrer'; newTab.click(); } }, onError: () => notifications.error({ message: t('somethingWentWrong'), }), }, ); const handleUpdateCreditCard = useCallback(async () => { logEvent('Workspace Blocked: User Clicked Update Credit Card', {}); updateCreditCard({ url: window.location.href, }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [updateCreditCard]); const handleExtendTrial = (): void => { logEvent('Workspace Blocked: User Clicked Extend Trial', {}); notifications.info({ message: t('extendTrial'), duration: 0, description: ( {t('extendTrialMsgPart1')}{' '} cloud-support@signoz.io{' '} {t('extendTrialMsgPart2')} ), }); }; const handleViewBilling = (): void => { logEvent('Workspace Blocked: User Clicked View Billing', {}); history.push(ROUTES.BILLING); }; const renderCustomerStories = ( filterCondition: (index: number) => boolean, ): JSX.Element[] => customerStoriesData .filter((_, index) => filterCondition(index)) .map((story) => ( )); const tabItems: TabsProps['items'] = [ { key: 'whyChooseSignoz', label: t('whyChooseSignoz'), children: ( {t('enterpriseGradeObservability')} {t('observabilityDescription')} ( } title={item.title} /> )} /> {isAdmin && ( )} ), }, { key: 'youAreInGoodCompany', label: t('youAreInGoodCompany'), children: ( {/* #FIXME: please suggest if there is any better way to loop in different columns to get the masonry layout */} {renderCustomerStories((index) => index % 2 === 0)} {renderCustomerStories((index) => index % 2 !== 0)} {isAdmin && ( )} ), }, // #TODO: comming soon // { // key: '3', // label: 'Our Pricing', // children: 'Our Pricing', // }, { key: 'faqs', label: t('faqs'), children: ( {isAdmin && ( )} ), }, ]; return (
{t('trialPlanExpired')} {isAdmin && ( )} Got Questions?
} open closable={false} footer={null} width="65%" >
{isFetchingActiveLicenseV3 || !trialInfo ? ( ) : ( <>
Upgrade to Continue
{t('upgradeNow')}
{t('yourDataIsSafe')}{' '} {getFormattedDate(trialInfo?.gracePeriodEnd || Date.now())} {' '} {t('actNow')}
{!isAdmin && ( )} {isAdmin && ( )}
)}
); }