Skip to content

Commit 2f1aec3

Browse files
committed
fix: migrate to free plan
1 parent b8d3f04 commit 2f1aec3

File tree

7 files changed

+100
-150
lines changed

7 files changed

+100
-150
lines changed

src/components/userPlanAndBillings/UpgradePlanNavigationItem.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export const UpgradePlanNavigationItem = () => {
2323
channelId: walletAddress,
2424
});
2525

26-
useMigrateToFreePlan({
27-
pricingPlanStatus,
28-
isLoading: isPricingPlanStatusLoading,
29-
refetch: refetchPricingPlanStatus,
30-
});
26+
// useMigrateToFreePlan({
27+
// pricingPlanStatus,
28+
// isLoading: isPricingPlanStatusLoading,
29+
// refetch: refetchPricingPlanStatus,
30+
// });
3131

3232
const selectedPlan = pricingInfoList?.find(
3333
(planItem: { id: number }) =>
@@ -51,8 +51,6 @@ export const UpgradePlanNavigationItem = () => {
5151
navigate('/pricing');
5252
};
5353

54-
console.log(pricingPlanStatus, 'plan status');
55-
5654
return (
5755
<Skeleton isLoading={isPricingPlanStatusLoading}>
5856
<Box
@@ -77,7 +75,7 @@ export const UpgradePlanNavigationItem = () => {
7775
color="text-primary"
7876
variant="h6-bold"
7977
>
80-
{(pricingPlanStatus && `Push ${selectedPlan?.name}`) || 'Free Plan'}
78+
{(pricingPlanStatus && !isUserOnFreePlan && `Push ${selectedPlan?.name}`) || 'Free Plan'}
8179
</Text>
8280
{pricingPlanStatus?.pricing_plan_id !== '3' && (
8381
<Button

src/components/userPlanAndBillings/UserPlanAndBillings.tsx

Lines changed: 65 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,27 @@ const UserPlanAndBillings = () => {
4949
navigate('/pricing');
5050
};
5151

52+
const pricingListDescriptions = [
53+
{
54+
id: 1,
55+
description: 'For casual degens',
56+
},
57+
{
58+
id: 2,
59+
description: 'For individuals',
60+
},
61+
{
62+
id: 3,
63+
description: 'For growing apps',
64+
},
65+
{
66+
id: 4,
67+
description: 'For advanced solutions',
68+
},
69+
];
70+
71+
// console.log(selectedPlan, 'check check');
72+
5273
return (
5374
<Box width="100%">
5475
<Text
@@ -58,123 +79,73 @@ const UserPlanAndBillings = () => {
5879
Take full control of your Push Notification plan, manage and stay up to date with your plan usage
5980
</Text>
6081

61-
{pricingPlanStatus?.pricing_plan_id ? (
82+
<Box
83+
backgroundColor="surface-secondary"
84+
margin="spacing-lg spacing-none spacing-none spacing-none"
85+
padding="spacing-md"
86+
borderRadius="radius-md"
87+
>
6288
<Box
63-
backgroundColor="surface-secondary"
64-
margin="spacing-lg spacing-none spacing-none spacing-none"
65-
padding="spacing-md"
66-
borderRadius="radius-md"
89+
display="flex"
90+
width="100%"
91+
flexDirection="row"
92+
justifyContent="space-between"
6793
>
68-
<Box
69-
display="flex"
70-
width="100%"
71-
flexDirection="row"
72-
justifyContent="space-between"
94+
<Text
95+
variant="h2-semibold"
96+
color="text-primary"
7397
>
74-
<Text
75-
variant="h2-semibold"
76-
color="text-primary"
77-
>
78-
{selectedPlan?.name} Plan
79-
</Text>
98+
{(pricingPlanStatus && !isUserOnFreePlan && `Push ${selectedPlan?.name}`) || 'Free Plan'}
99+
</Text>
100+
{!isUserOnFreePlan && (
80101
<Text
81102
variant="h2-semibold"
82103
color="text-primary"
83104
>
84105
${selectedPlan?.value}/mo
85106
</Text>
86-
</Box>
107+
)}
108+
</Box>
87109

88-
<Box
89-
display="flex"
90-
width="100%"
91-
flexDirection="row"
92-
justifyContent="space-between"
110+
<Box
111+
display="flex"
112+
width="100%"
113+
flexDirection="row"
114+
justifyContent="space-between"
115+
>
116+
<Text
117+
variant="bm-regular"
118+
color="text-tertiary"
93119
>
94-
<Text
95-
variant="bm-regular"
96-
color="text-tertiary"
97-
>
98-
For individuals
99-
</Text>
120+
{pricingListDescriptions?.find((desc) => desc.id === selectedPlan?.id)?.description}
121+
</Text>
122+
{!isUserOnFreePlan && (
100123
<Text
101124
variant="bm-regular"
102125
color="text-tertiary"
103126
>
104127
billed yearly
105128
</Text>
106-
</Box>
107-
108-
<Box
109-
margin="spacing-lg spacing-none spacing-none spacing-none"
110-
display="flex"
111-
width="100%"
112-
flexDirection="row"
113-
justifyContent="space-between"
114-
alignItems="center"
115-
>
116-
<Button
117-
variant="tertiary"
118-
size="small"
119-
onClick={navigateToPricing}
120-
>
121-
Upgrade Plan
122-
</Button>
123-
</Box>
129+
)}
124130
</Box>
125-
) : (
131+
126132
<Box
127-
backgroundColor="surface-secondary"
128133
margin="spacing-lg spacing-none spacing-none spacing-none"
129-
padding="spacing-md"
130-
borderRadius="radius-md"
134+
display="flex"
135+
width="100%"
136+
flexDirection="row"
137+
justifyContent="space-between"
138+
alignItems="center"
131139
>
132-
<Box
133-
display="flex"
134-
width="100%"
135-
flexDirection="row"
136-
justifyContent="space-between"
137-
>
138-
<Text
139-
variant="h2-semibold"
140-
color="text-primary"
141-
>
142-
Free Plan
143-
</Text>
144-
</Box>
145-
146-
<Box
147-
display="flex"
148-
width="100%"
149-
flexDirection="row"
150-
justifyContent="space-between"
151-
>
152-
<Text
153-
variant="bm-regular"
154-
color="text-tertiary"
155-
>
156-
For individuals
157-
</Text>
158-
</Box>
159-
160-
<Box
161-
margin="spacing-lg spacing-none spacing-none spacing-none"
162-
display="flex"
163-
width="100%"
164-
flexDirection="row"
165-
justifyContent="space-between"
166-
alignItems="center"
140+
<Button
141+
variant={!isUserOnFreePlan ? 'tertiary' : 'primary'}
142+
size="small"
143+
onClick={navigateToPricing}
167144
>
168-
<Button
169-
variant="primary"
170-
size="small"
171-
onClick={navigateToPricing}
172-
>
173-
Upgrade Plan
174-
</Button>
175-
</Box>
145+
Upgrade Plan
146+
</Button>
176147
</Box>
177-
)}
148+
</Box>
178149

179150
<Box margin="spacing-xl spacing-none spacing-none spacing-none">
180151
<Text

src/components/userPlanAndBillings/hooks/useMigrateToFreePlan.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const useMigrateToFreePlan = ({ pricingPlanStatus, isLoading, refetch }:
1616
const { mutate: handleInitatePayment } = useInitiatePaymentInfo();
1717

1818
const handleMigrateToFreePlan = () => {
19+
console.log('handlemigrate');
1920
handleInitatePayment(
2021
{
2122
channel: walletAddress,

src/components/userSettings/UserSettings.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import PushSnapSettings from 'components/PushSnap/PushSnapSettings';
2222
import UserPlanAndBillings from 'components/userPlanAndBillings/UserPlanAndBillings';
2323
import UserProfileSocialSettings from 'components/UserProfileSettings/UserProfileSocialSettings';
2424
import { convertAddressToAddrCaip } from 'helpers/CaipHelper';
25-
import { useGetPricingPlanStatus } from 'queries';
25+
import { useGetPricingInfo, useGetPricingPlanStatus } from 'queries';
2626
import { calculateExpirationDetails } from './utils';
27-
27+
import { toNumber } from 'lodash';
2828

2929
interface ChannelListItem {
3030
channel: string;
@@ -56,10 +56,18 @@ function UserSettings() {
5656

5757
const dispatch = useDispatch();
5858

59+
const { data: pricingInfoList } = useGetPricingInfo();
5960
const { data: pricingPlanStatus } = useGetPricingPlanStatus({
6061
channelId: walletAddress,
6162
});
6263

64+
const selectedPlan = pricingInfoList?.find(
65+
(planItem: { id: number }) =>
66+
planItem?.id == toNumber(pricingPlanStatus?.pricing_plan_id ? pricingPlanStatus?.pricing_plan_id : '1'),
67+
);
68+
69+
const isUserOnFreePlan = selectedPlan?.id == 1;
70+
6371
const expirationDetails = calculateExpirationDetails(pricingPlanStatus ?? null);
6472

6573
const navigateToPricing = () => {
@@ -123,7 +131,6 @@ function UserSettings() {
123131
label: 'My Profile',
124132
title: 'Your Profile',
125133
section: 'top',
126-
127134
},
128135
{
129136
value: 1,
@@ -210,7 +217,7 @@ function UserSettings() {
210217
</>
211218
)}
212219

213-
{selectedOption === 3 && pricingPlanStatus == null && (
220+
{selectedOption === 3 && isUserOnFreePlan && (
214221
<Alert
215222
showIcon={false}
216223
heading="Go Pro for $11.99/mo and unlock access to more features"
@@ -220,7 +227,7 @@ function UserSettings() {
220227
/>
221228
)}
222229

223-
{selectedOption === 3 && pricingPlanStatus != null && !expirationDetails?.isExpired && (
230+
{selectedOption === 3 && !isUserOnFreePlan && !expirationDetails?.isExpired && (
224231
<Alert
225232
showIcon={true}
226233
heading={`Your Pro plan is active until ${expirationDetails?.expirationDate}`}
@@ -234,7 +241,6 @@ function UserSettings() {
234241
<SectionTitle bottomSpacing={selectedOption == 2 ? false : true}>
235242
{selectOptions[selectedOption]?.title}
236243
</SectionTitle>
237-
238244
)}
239245

240246
{selectedOption === 0 && (
@@ -248,7 +254,6 @@ function UserSettings() {
248254
{selectedOption === 1 && <ChannelListSettings />}
249255
{selectedOption === 2 && <PushSnapSettings />}
250256
{selectedOption === 3 && <UserPlanAndBillings />}
251-
252257
</ChannelContainer>
253258
</ChannelWrapper>
254259

src/modules/channelDashboard/ChannelDashboard.tsx

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,10 @@ const ChannelDashboard = () => {
4040
(planItem: { id: number }) =>
4141
planItem?.id == parseInt(pricingPlanStatus?.pricing_plan_id ? pricingPlanStatus?.pricing_plan_id : '1'),
4242
);
43+
44+
const isUserOnFreePlan = selectedPlan?.id == 1;
45+
4346
const { data: paymentDetails } = useGetPaymentDetails({ paymentId: paymentId! });
44-
// const pricingPlanStatus = {
45-
// id: 1,
46-
// channel: 'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681',
47-
// email_quota_used: 0,
48-
// telegram_quota_used: 0,
49-
// discord_quota_used: 0,
50-
// pricing_plan_id: '2',
51-
// email_total_quota: 2000,
52-
// telegram_total_quota: 2000,
53-
// discord_total_quota: 0,
54-
// expirationTimestamp: 1767961517282,
55-
// expirationTimestamp: 1715515200000,
56-
// expirationTimestamp: 1739152965000,
57-
// };
58-
59-
// const paymentDetails = {
60-
// id: 6,
61-
// channel: 'eip155:11155111:0xd8634c39bbfd4033c0d3289c4515275102423681',
62-
// payment_id: '3idbuzrWTW8w13XwJDQK72',
63-
// pricing_plan_id: '2',
64-
// amount: 1,
65-
// currency: 'USDC',
66-
// created_at: 1736856636,
67-
// payment_network: '11155111',
68-
// payment_status: 'SUCCESS',
69-
// transaction_hash: '0xe1134ad134ccb9247ee9dd4c1b47fad4d9e814bc848fd8a25829d8e17a97a978',
70-
// expires_at: 1736863836,
71-
// message: '',
72-
// durationInMonths: 12,
73-
// };
7447

7548
const { channelDetails, loadingChannelDetails, refetchChannelDetails } = useFetchChannelDetails();
7649
useGetChannelCategories();
@@ -106,7 +79,7 @@ const ChannelDashboard = () => {
10679
)}
10780

10881
{/* Expiry notice alert after plan has expired */}
109-
{pricingPlanStatus && expiryDetails?.isExpired && (
82+
{pricingPlanStatus && !isUserOnFreePlan && expiryDetails?.isExpired && (
11083
<PurchasePlanAlert
11184
variant="expired"
11285
purchasedPlan={{ planName: selectedPlan?.name! }}
@@ -117,7 +90,7 @@ const ChannelDashboard = () => {
11790
)}
11891

11992
{/* Expiry notice alert when expiry is less than 7 days */}
120-
{pricingPlanStatus && parseInt(expiryDetails?.timeRemaining!) < 7 && (
93+
{pricingPlanStatus && !isUserOnFreePlan && parseInt(expiryDetails?.timeRemaining!) < 7 && (
12194
<PurchasePlanAlert
12295
variant="renewalReminder"
12396
purchasedPlan={{ planName: selectedPlan?.name!, daysRemaining: parseInt(expiryDetails?.timeRemaining!) }}
@@ -128,7 +101,7 @@ const ChannelDashboard = () => {
128101
)}
129102

130103
{/* Alert when user is on free plan, and notification limit is already reached */}
131-
{pricingPlanStatus?.pricing_plan_id == '1' && totalQuota - totalQuotaUsed < 100 && (
104+
{isUserOnFreePlan && totalQuota - totalQuotaUsed < 100 && (
132105
<PurchasePlanAlert
133106
variant="notificationLimit"
134107
onAction={() => {

0 commit comments

Comments
 (0)