/* 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 useLicense from 'hooks/useLicense'; import { useNotifications } from 'hooks/useNotifications'; import history from 'lib/history'; import { CircleArrowRight } from 'lucide-react'; import { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useMutation } from 'react-query'; import { useSelector } from 'react-redux'; import { AppState } from 'store/reducers'; import { License } from 'types/api/licenses/def'; import AppReducer from 'types/reducer/app'; 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 { role } = useSelector((state) => state.app); const isAdmin = role === 'ADMIN'; const [activeLicense, setActiveLicense] = useState(null); const { notifications } = useNotifications(); const { t } = useTranslation(['workspaceLocked']); const { isFetching: isFetchingLicenseData, isLoading: isLoadingLicenseData, data: licensesData, } = useLicense(); 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 (!isFetchingLicenseData) { const shouldBlockWorkspace = licensesData?.payload?.workSpaceBlock; if (!shouldBlockWorkspace) { history.push(ROUTES.APPLICATION); } const activeValidLicense = licensesData?.payload?.licenses?.find( (license) => license.isCurrent === true, ) || null; setActiveLicense(activeValidLicense); } }, [isFetchingLicenseData, licensesData]); 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({ licenseKey: activeLicense?.key || '', successURL: window.location.origin, cancelURL: window.location.origin, }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [activeLicense?.key, 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 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')} Got Questions?
} open closable={false} footer={null} width="65%" >
{isLoadingLicenseData || !licensesData ? ( ) : ( <>
Upgrade to Continue
{t('upgradeNow')}
{t('yourDataIsSafe')}{' '} {getFormattedDate( licensesData.payload?.gracePeriodEnd || Date.now(), )} {' '} {t('actNow')}
{!isAdmin && ( )} {isAdmin && ( )}
)}
); }