2023-10-16 23:57:44 +05:30
|
|
|
/* eslint-disable react/no-unescaped-entities */
|
|
|
|
|
import './WorkspaceLocked.styles.scss';
|
|
|
|
|
|
2024-01-19 11:11:29 +05:30
|
|
|
import {
|
|
|
|
|
CreditCardOutlined,
|
|
|
|
|
LockOutlined,
|
|
|
|
|
SendOutlined,
|
|
|
|
|
} from '@ant-design/icons';
|
2023-10-26 18:39:04 +05:30
|
|
|
import { Button, Card, Skeleton, Typography } from 'antd';
|
2023-10-16 23:57:44 +05:30
|
|
|
import updateCreditCardApi from 'api/billing/checkout';
|
|
|
|
|
import { SOMETHING_WENT_WRONG } from 'constants/api';
|
2023-10-26 18:39:04 +05:30
|
|
|
import ROUTES from 'constants/routes';
|
2024-01-05 11:15:31 +05:30
|
|
|
import FullViewHeader from 'container/FullViewHeader/FullViewHeader';
|
2024-01-19 11:11:29 +05:30
|
|
|
import useAnalytics from 'hooks/analytics/useAnalytics';
|
2023-10-16 23:57:44 +05:30
|
|
|
import useLicense from 'hooks/useLicense';
|
|
|
|
|
import { useNotifications } from 'hooks/useNotifications';
|
2023-10-26 18:39:04 +05:30
|
|
|
import history from 'lib/history';
|
2023-10-16 23:57:44 +05:30
|
|
|
import { useCallback, useEffect, useState } from 'react';
|
|
|
|
|
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';
|
2023-10-18 21:43:46 +05:30
|
|
|
import { getFormattedDate } from 'utils/timeUtils';
|
2023-10-16 23:57:44 +05:30
|
|
|
|
|
|
|
|
export default function WorkspaceBlocked(): JSX.Element {
|
|
|
|
|
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
|
|
|
|
const isAdmin = role === 'ADMIN';
|
|
|
|
|
const [activeLicense, setActiveLicense] = useState<License | null>(null);
|
2024-01-19 11:11:29 +05:30
|
|
|
const { trackEvent } = useAnalytics();
|
2023-10-16 23:57:44 +05:30
|
|
|
|
|
|
|
|
const { notifications } = useNotifications();
|
|
|
|
|
|
2023-10-26 18:39:04 +05:30
|
|
|
const {
|
|
|
|
|
isFetching: isFetchingLicenseData,
|
|
|
|
|
isLoading: isLoadingLicenseData,
|
|
|
|
|
data: licensesData,
|
|
|
|
|
} = useLicense();
|
2023-10-16 23:57:44 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
2023-10-26 18:39:04 +05:30
|
|
|
if (!isFetchingLicenseData) {
|
|
|
|
|
const shouldBlockWorkspace = licensesData?.payload?.workSpaceBlock;
|
2023-10-16 23:57:44 +05:30
|
|
|
|
2023-10-26 18:39:04 +05:30
|
|
|
if (!shouldBlockWorkspace) {
|
|
|
|
|
history.push(ROUTES.APPLICATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const activeValidLicense =
|
|
|
|
|
licensesData?.payload?.licenses?.find(
|
|
|
|
|
(license) => license.isCurrent === true,
|
|
|
|
|
) || null;
|
|
|
|
|
|
|
|
|
|
setActiveLicense(activeValidLicense);
|
|
|
|
|
}
|
|
|
|
|
}, [isFetchingLicenseData, licensesData]);
|
2023-10-16 23:57:44 +05:30
|
|
|
|
|
|
|
|
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: SOMETHING_WENT_WRONG,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const handleUpdateCreditCard = useCallback(async () => {
|
2024-01-19 11:11:29 +05:30
|
|
|
trackEvent('Workspace Blocked: User Clicked Update Credit Card');
|
|
|
|
|
|
2023-10-16 23:57:44 +05:30
|
|
|
updateCreditCard({
|
|
|
|
|
licenseKey: activeLicense?.key || '',
|
|
|
|
|
successURL: window.location.origin,
|
|
|
|
|
cancelURL: window.location.origin,
|
|
|
|
|
});
|
2024-01-19 11:11:29 +05:30
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2023-10-16 23:57:44 +05:30
|
|
|
}, [activeLicense?.key, updateCreditCard]);
|
|
|
|
|
|
2024-01-19 11:11:29 +05:30
|
|
|
const handleExtendTrial = (): void => {
|
|
|
|
|
trackEvent('Workspace Blocked: User Clicked Extend Trial');
|
|
|
|
|
|
|
|
|
|
const recipient = 'cloud-support@signoz.io';
|
|
|
|
|
const subject = 'Extend SigNoz Cloud Trial';
|
|
|
|
|
const body = `I'd like to request an extension for SigNoz Cloud for my account. Please find my account details below
|
|
|
|
|
|
|
|
|
|
SigNoz URL:
|
|
|
|
|
Admin Email:
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
// Create the mailto link
|
|
|
|
|
const mailtoLink = `mailto:${recipient}?subject=${encodeURIComponent(
|
|
|
|
|
subject,
|
|
|
|
|
)}&body=${encodeURIComponent(body)}`;
|
|
|
|
|
|
|
|
|
|
// Open the default email client
|
|
|
|
|
window.location.href = mailtoLink;
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-16 23:57:44 +05:30
|
|
|
return (
|
2024-01-05 11:15:31 +05:30
|
|
|
<>
|
|
|
|
|
<FullViewHeader overrideRoute={ROUTES.WORKSPACE_LOCKED} />
|
|
|
|
|
|
|
|
|
|
<Card className="workspace-locked-container">
|
|
|
|
|
{isLoadingLicenseData || !licensesData?.payload?.workSpaceBlock ? (
|
|
|
|
|
<Skeleton />
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<LockOutlined style={{ fontSize: '36px', color: '#08c' }} />
|
|
|
|
|
<Typography.Title level={4}> Workspace Locked </Typography.Title>
|
|
|
|
|
<Typography.Paragraph className="workpace-locked-details">
|
|
|
|
|
You have been locked out of your workspace because your trial ended
|
|
|
|
|
without an upgrade to a paid plan. Your data will continue to be ingested
|
|
|
|
|
till{' '}
|
|
|
|
|
{getFormattedDate(licensesData?.payload?.gracePeriodEnd || Date.now())} ,
|
|
|
|
|
at which point we will drop all the ingested data and terminate the
|
|
|
|
|
account.
|
|
|
|
|
{!isAdmin && 'Please contact your administrator for further help'}
|
|
|
|
|
</Typography.Paragraph>
|
2024-01-19 11:11:29 +05:30
|
|
|
|
|
|
|
|
<div className="cta">
|
|
|
|
|
{isAdmin && (
|
|
|
|
|
<Button
|
|
|
|
|
className="update-credit-card-btn"
|
|
|
|
|
type="primary"
|
|
|
|
|
icon={<CreditCardOutlined />}
|
|
|
|
|
size="middle"
|
|
|
|
|
loading={isLoading}
|
|
|
|
|
onClick={handleUpdateCreditCard}
|
|
|
|
|
>
|
|
|
|
|
Update Credit Card
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
|
2024-01-05 11:15:31 +05:30
|
|
|
<Button
|
2024-01-19 11:11:29 +05:30
|
|
|
className="extend-trial-btn"
|
|
|
|
|
type="default"
|
|
|
|
|
icon={<SendOutlined />}
|
2024-01-05 11:15:31 +05:30
|
|
|
size="middle"
|
2024-01-19 11:11:29 +05:30
|
|
|
onClick={handleExtendTrial}
|
2024-01-05 11:15:31 +05:30
|
|
|
>
|
2024-01-19 11:11:29 +05:30
|
|
|
Extend Trial
|
2024-01-05 11:15:31 +05:30
|
|
|
</Button>
|
2024-01-19 11:11:29 +05:30
|
|
|
</div>
|
2024-01-05 11:15:31 +05:30
|
|
|
<div className="contact-us">
|
|
|
|
|
Got Questions?
|
|
|
|
|
<span>
|
|
|
|
|
<a href="mailto:support@signoz.io"> Contact Us </a>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Card>
|
|
|
|
|
</>
|
2023-10-16 23:57:44 +05:30
|
|
|
);
|
|
|
|
|
}
|