Skip to content

Commit 8752a70

Browse files
Merge pull request #1456 from AppQuality/develop
release-20251028
2 parents 16dffd6 + 2effa62 commit 8752a70

File tree

22 files changed

+84
-60
lines changed

22 files changed

+84
-60
lines changed

.env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
REACT_APP_API_URL=https://dev.unguess.io/api
2-
REACT_APP_CROWD_WP_URL=https://dev.unguess.io
2+
REACT_APP_CROWD_WP_URL=https://dev.unguess.io

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"dependencies": {
66
"@analytics/google-tag-manager": "^0.6.0",
7+
"@analytics/hubspot": "^0.5.1",
78
"@appquality/languages": "1.4.3",
89
"@appquality/unguess-design-system": "4.0.50",
910
"@atlaskit/pragmatic-drag-and-drop": "^1.7.4",
@@ -129,4 +130,4 @@
129130
"*.{tsx,ts,js,css,md}": "prettier --write"
130131
},
131132
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
132-
}
133+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
declare module '@analytics/hubspot' {
2+
type AnalyticsPlugin = import('analytics').AnalyticsPlugin;
3+
4+
type HubspotConfig = {
5+
portalId: string;
6+
};
7+
8+
function hubspotPlugin(config: HubspotConfig): AnalyticsPlugin;
9+
export default hubspotPlugin;
10+
}

src/analytics.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import googleTagManager from '@analytics/google-tag-manager';
22
import Analytics from 'analytics';
3+
import hubspotPlugin from '@analytics/hubspot';
34
import userpilot from './common/analytics-plugins/userpilot';
45
import { isDev } from './common/isDevEnvironment';
56

@@ -17,6 +18,9 @@ const analytics = Analytics({
1718
userpilot({
1819
token: 'NX-54e88e10',
1920
}),
21+
hubspotPlugin({
22+
portalId: isDev() ? '50612068' : '6087279',
23+
}),
2024
],
2125
}),
2226
});

src/hooks/usePlan.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ const usePlan = (planId?: string) => {
9898
isFetching: isFetching || isCiFetching || isTemplateFetching,
9999
activeWorkspace,
100100
plan: undefined,
101-
...(hasCI ? { checkoutItem: ci } : {}),
102101
planComposedStatus,
103102
};
104103
}
@@ -107,10 +106,33 @@ const usePlan = (planId?: string) => {
107106
isLoading: isLoading || isCiLoading || isTemplateLoading,
108107
isFetching: isFetching || isCiFetching || isTemplateFetching,
109108
activeWorkspace,
110-
plan: { ...plan, isPurchasable: hasCI },
111-
...(hasCI ? { checkoutItem: ci } : {}),
109+
plan,
112110
planComposedStatus,
113111
};
114112
};
115113

116-
export { usePlan };
114+
const usePlanIsDraft = (planId?: string) => {
115+
const { planComposedStatus } = usePlan(planId);
116+
117+
const isDraft =
118+
!!planComposedStatus &&
119+
['PurchasableDraft', 'UnquotedDraft', 'PrequotedDraft'].includes(
120+
planComposedStatus
121+
);
122+
123+
return isDraft;
124+
};
125+
126+
const usePlanIsPurchasable = (planId?: string) => {
127+
const { planComposedStatus } = usePlan(planId);
128+
129+
const isPurchasable =
130+
!!planComposedStatus &&
131+
['PurchasableDraft', 'AwaitingPayment', 'PurchasedPlan', 'Paying'].includes(
132+
planComposedStatus
133+
);
134+
135+
return isPurchasable;
136+
};
137+
138+
export { usePlan, usePlanIsDraft, usePlanIsPurchasable };

src/pages/Plan/Controls/ConfirmPlanButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useState } from 'react';
33
import { useTranslation } from 'react-i18next';
44
import { useParams } from 'react-router-dom';
55
import { usePatchPlansByPidStatusMutation } from 'src/features/api';
6-
import { usePlan } from '../../../hooks/usePlan';
6+
import { usePlan, usePlanIsPurchasable } from '../../../hooks/usePlan';
77
import { BuyButton } from '../summary/components/BuyButton';
88

99
const ConfirmPlanButton = () => {
@@ -13,10 +13,11 @@ const ConfirmPlanButton = () => {
1313
const { planId } = useParams();
1414
const { plan, planComposedStatus } = usePlan(planId);
1515
const { t } = useTranslation();
16+
const isPurchasable = usePlanIsPurchasable(planId);
1617

1718
if (!plan) return null;
1819

19-
if (plan.isPurchasable) {
20+
if (isPurchasable) {
2021
return <BuyButton />;
2122
}
2223

src/pages/Plan/Controls/IconButtonMenu.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { useTranslation } from 'react-i18next';
99
import { useParams } from 'react-router-dom';
1010
import { ReactComponent as SaveTemplateIcon } from 'src/assets/icons/template.svg';
1111
import { Divider } from 'src/common/components/divider';
12+
import { usePlan, usePlanIsDraft } from '../../../hooks/usePlan';
1213
import { usePlanContext } from '../context/planContext';
13-
import { usePlan } from '../../../hooks/usePlan';
1414

1515
const OptionalTooltip = ({
1616
children,
@@ -36,7 +36,8 @@ const IconButtonMenu = () => {
3636

3737
const { setIsSaveTemplateModalOpen, setIsDeleteModalOpen } = usePlanContext();
3838
const { planId } = useParams();
39-
const { plan, planComposedStatus } = usePlan(planId);
39+
const { planComposedStatus } = usePlan(planId);
40+
const isDraft = usePlanIsDraft(planId);
4041

4142
const handleMenuClick = (value?: string) => {
4243
if (value === 'delete') {
@@ -74,14 +75,14 @@ const IconButtonMenu = () => {
7475
</>
7576
)}
7677
<OptionalTooltip
77-
show={plan?.status !== 'draft'}
78+
show={!isDraft}
7879
content={t('__PLAN_DELETE_PLAN_TOOLTIP')}
7980
>
8081
<ButtonMenu.Item
8182
data-qa="delete-action-item"
8283
type="danger"
8384
value="delete"
84-
isDisabled={plan?.status !== 'draft'}
85+
isDisabled={!isDraft}
8586
icon={<TrashIcon />}
8687
>
8788
{t('__PLAN_DELETE_PLAN_CTA')}

src/pages/Plan/Controls/SaveConfigurationButton.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { useTranslation } from 'react-i18next';
77
import { useParams } from 'react-router-dom';
88
import { useSubmit } from 'src/features/modules/useModuleConfiguration';
99
import { useValidateForm } from 'src/features/planModules';
10-
import { getPlanStatus } from 'src/pages/Dashboard/hooks/getPlanStatus';
11-
import { usePlan } from '../../../hooks/usePlan';
10+
import { usePlan, usePlanIsDraft } from '../../../hooks/usePlan';
1211

1312
const SaveConfigurationButton = () => {
1413
const { t } = useTranslation();
@@ -20,15 +19,10 @@ const SaveConfigurationButton = () => {
2019
useSubmit(planId || '');
2120

2221
const { plan } = usePlan(planId);
22+
const isDraft = usePlanIsDraft(planId);
2323

2424
if (!plan) return null;
2525

26-
const { status } = getPlanStatus({
27-
planStatus: plan.status,
28-
quote: plan.quote,
29-
t,
30-
});
31-
3226
const handleSaveConfiguration = async () => {
3327
validateForm();
3428
try {
@@ -65,7 +59,7 @@ const SaveConfigurationButton = () => {
6559
<Button
6660
type="button"
6761
size="small"
68-
disabled={isSubmitting || status !== 'draft'}
62+
disabled={isSubmitting || !isDraft}
6963
onClick={handleSaveConfiguration}
7064
>
7165
{t('__PLAN_SAVE_CONFIGURATION_CTA')}

src/pages/Plan/Controls/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Pipe } from 'src/common/components/Pipe';
77
import { useModule } from 'src/features/modules/useModule';
88
import styled from 'styled-components';
99
import { useSubmit } from '../../../features/modules/useModuleConfiguration';
10-
import { usePlan } from '../../../hooks/usePlan';
10+
import { usePlan, usePlanIsPurchasable } from '../../../hooks/usePlan';
1111
import { usePlanContext } from '../context/planContext';
1212
import { DateInThePastAlertModal } from '../modals/DateInThePastAlertModal';
1313
import { DeletePlanModal } from '../modals/DeletePlanModal';
@@ -37,6 +37,7 @@ export const Controls = () => {
3737
} = usePlanContext();
3838
const { planId } = useParams();
3939
const { plan, planComposedStatus } = usePlan(planId);
40+
const isPurchasable = usePlanIsPurchasable(planId);
4041
const { value: titleValue } = useModule('title'); // to use the current changed title value (also if plan is not saved) in delete modal
4142
const { addToast } = useToast();
4243
const { handleSubmit } = useSubmit(planId || '');
@@ -108,7 +109,7 @@ export const Controls = () => {
108109

109110
{isRequestQuotationModalOpen && (
110111
<SendRequestModal
111-
isPurchasable={plan.isPurchasable}
112+
isPurchasable={isPurchasable}
112113
onQuit={() => setRequestQuotationModalOpen(false)}
113114
/>
114115
)}

src/pages/Plan/context/planContext.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ export const PlanProvider = ({ children }: { children: ReactNode }) => {
9595
}
9696
} catch (error) {
9797
setIsPaymentInProgress(false);
98-
console.error(`Error while checkout process: ${error}`);
9998
}
10099
};
101100

0 commit comments

Comments
 (0)