diff --git a/.env.template b/.env.template
index 82b2d6795..de4cdbd7a 100644
--- a/.env.template
+++ b/.env.template
@@ -1,2 +1,2 @@
REACT_APP_API_URL=https://dev.unguess.io/api
-REACT_APP_CROWD_WP_URL=https://dev.unguess.io
+REACT_APP_CROWD_WP_URL=https://dev.unguess.io
\ No newline at end of file
diff --git a/package.json b/package.json
index bf1117604..d6eb98a67 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@analytics/google-tag-manager": "^0.6.0",
+ "@analytics/hubspot": "^0.5.1",
"@appquality/languages": "1.4.3",
"@appquality/unguess-design-system": "4.0.50",
"@atlaskit/pragmatic-drag-and-drop": "^1.7.4",
@@ -129,4 +130,4 @@
"*.{tsx,ts,js,css,md}": "prettier --write"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
-}
+}
\ No newline at end of file
diff --git a/src/@types/analytics__hubspot/index.d.ts b/src/@types/analytics__hubspot/index.d.ts
new file mode 100644
index 000000000..426841358
--- /dev/null
+++ b/src/@types/analytics__hubspot/index.d.ts
@@ -0,0 +1,10 @@
+declare module '@analytics/hubspot' {
+ type AnalyticsPlugin = import('analytics').AnalyticsPlugin;
+
+ type HubspotConfig = {
+ portalId: string;
+ };
+
+ function hubspotPlugin(config: HubspotConfig): AnalyticsPlugin;
+ export default hubspotPlugin;
+}
diff --git a/src/analytics.ts b/src/analytics.ts
index 189b52756..7af21f064 100644
--- a/src/analytics.ts
+++ b/src/analytics.ts
@@ -1,5 +1,6 @@
import googleTagManager from '@analytics/google-tag-manager';
import Analytics from 'analytics';
+import hubspotPlugin from '@analytics/hubspot';
import userpilot from './common/analytics-plugins/userpilot';
import { isDev } from './common/isDevEnvironment';
@@ -17,6 +18,9 @@ const analytics = Analytics({
userpilot({
token: 'NX-54e88e10',
}),
+ hubspotPlugin({
+ portalId: isDev() ? '50612068' : '6087279',
+ }),
],
}),
});
diff --git a/src/hooks/usePlan.ts b/src/hooks/usePlan.ts
index c5a707370..9170b728e 100644
--- a/src/hooks/usePlan.ts
+++ b/src/hooks/usePlan.ts
@@ -98,7 +98,6 @@ const usePlan = (planId?: string) => {
isFetching: isFetching || isCiFetching || isTemplateFetching,
activeWorkspace,
plan: undefined,
- ...(hasCI ? { checkoutItem: ci } : {}),
planComposedStatus,
};
}
@@ -107,10 +106,33 @@ const usePlan = (planId?: string) => {
isLoading: isLoading || isCiLoading || isTemplateLoading,
isFetching: isFetching || isCiFetching || isTemplateFetching,
activeWorkspace,
- plan: { ...plan, isPurchasable: hasCI },
- ...(hasCI ? { checkoutItem: ci } : {}),
+ plan,
planComposedStatus,
};
};
-export { usePlan };
+const usePlanIsDraft = (planId?: string) => {
+ const { planComposedStatus } = usePlan(planId);
+
+ const isDraft =
+ !!planComposedStatus &&
+ ['PurchasableDraft', 'UnquotedDraft', 'PrequotedDraft'].includes(
+ planComposedStatus
+ );
+
+ return isDraft;
+};
+
+const usePlanIsPurchasable = (planId?: string) => {
+ const { planComposedStatus } = usePlan(planId);
+
+ const isPurchasable =
+ !!planComposedStatus &&
+ ['PurchasableDraft', 'AwaitingPayment', 'PurchasedPlan', 'Paying'].includes(
+ planComposedStatus
+ );
+
+ return isPurchasable;
+};
+
+export { usePlan, usePlanIsDraft, usePlanIsPurchasable };
diff --git a/src/pages/Plan/Controls/ConfirmPlanButton.tsx b/src/pages/Plan/Controls/ConfirmPlanButton.tsx
index 52fd5c481..ece83217c 100644
--- a/src/pages/Plan/Controls/ConfirmPlanButton.tsx
+++ b/src/pages/Plan/Controls/ConfirmPlanButton.tsx
@@ -3,7 +3,7 @@ import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { usePatchPlansByPidStatusMutation } from 'src/features/api';
-import { usePlan } from '../../../hooks/usePlan';
+import { usePlan, usePlanIsPurchasable } from '../../../hooks/usePlan';
import { BuyButton } from '../summary/components/BuyButton';
const ConfirmPlanButton = () => {
@@ -13,10 +13,11 @@ const ConfirmPlanButton = () => {
const { planId } = useParams();
const { plan, planComposedStatus } = usePlan(planId);
const { t } = useTranslation();
+ const isPurchasable = usePlanIsPurchasable(planId);
if (!plan) return null;
- if (plan.isPurchasable) {
+ if (isPurchasable) {
return ;
}
diff --git a/src/pages/Plan/Controls/IconButtonMenu.tsx b/src/pages/Plan/Controls/IconButtonMenu.tsx
index 4a41d04f2..fee77b924 100644
--- a/src/pages/Plan/Controls/IconButtonMenu.tsx
+++ b/src/pages/Plan/Controls/IconButtonMenu.tsx
@@ -9,8 +9,8 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { ReactComponent as SaveTemplateIcon } from 'src/assets/icons/template.svg';
import { Divider } from 'src/common/components/divider';
+import { usePlan, usePlanIsDraft } from '../../../hooks/usePlan';
import { usePlanContext } from '../context/planContext';
-import { usePlan } from '../../../hooks/usePlan';
const OptionalTooltip = ({
children,
@@ -36,7 +36,8 @@ const IconButtonMenu = () => {
const { setIsSaveTemplateModalOpen, setIsDeleteModalOpen } = usePlanContext();
const { planId } = useParams();
- const { plan, planComposedStatus } = usePlan(planId);
+ const { planComposedStatus } = usePlan(planId);
+ const isDraft = usePlanIsDraft(planId);
const handleMenuClick = (value?: string) => {
if (value === 'delete') {
@@ -74,14 +75,14 @@ const IconButtonMenu = () => {
>
)}
}
>
{t('__PLAN_DELETE_PLAN_CTA')}
diff --git a/src/pages/Plan/Controls/SaveConfigurationButton.tsx b/src/pages/Plan/Controls/SaveConfigurationButton.tsx
index a0b5fd552..30afdc2d5 100644
--- a/src/pages/Plan/Controls/SaveConfigurationButton.tsx
+++ b/src/pages/Plan/Controls/SaveConfigurationButton.tsx
@@ -7,8 +7,7 @@ import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { useSubmit } from 'src/features/modules/useModuleConfiguration';
import { useValidateForm } from 'src/features/planModules';
-import { getPlanStatus } from 'src/pages/Dashboard/hooks/getPlanStatus';
-import { usePlan } from '../../../hooks/usePlan';
+import { usePlan, usePlanIsDraft } from '../../../hooks/usePlan';
const SaveConfigurationButton = () => {
const { t } = useTranslation();
@@ -20,15 +19,10 @@ const SaveConfigurationButton = () => {
useSubmit(planId || '');
const { plan } = usePlan(planId);
+ const isDraft = usePlanIsDraft(planId);
if (!plan) return null;
- const { status } = getPlanStatus({
- planStatus: plan.status,
- quote: plan.quote,
- t,
- });
-
const handleSaveConfiguration = async () => {
validateForm();
try {
@@ -65,7 +59,7 @@ const SaveConfigurationButton = () => {