Skip to content

Commit d0fc7ef

Browse files
feat: Added TextArea for specifying other cancellation reason
1 parent b5073a0 commit d0fc7ef

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

apps/web/components/UpgradePlan/Plans/PlanCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const mapToSubOSPlan = (plan: Plan, cycle: BillingCycle): any => {
4040
export function PlanCard({ plan, isYearly }: PlanCardProps) {
4141
const { classes } = useStyles();
4242
const { selectPlan, subscription } = useSubOSIntegration();
43-
console.log(subscription);
4443

4544
return (
4645
<Card

apps/web/components/home/PlanDetails/CancelSubscriptionModal.tsx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react';
2-
import { Checkbox, Flex, Text, Center, Stack } from '@mantine/core';
2+
import { Checkbox, Flex, Text, Center, Stack, Textarea } from '@mantine/core';
33
import { Button } from '@ui/button';
44
import { Controller } from 'react-hook-form';
55

66
import { PlanCancelIllustration } from './illustrations/PlanCancelIllustration';
77

88
import { colors, MEMBERSHIP_CANCELLATION_REASONS } from '@config';
9+
import { AutoHeightComponent } from '@ui/auto-height-component';
910

1011
interface CancelSubscriptionModalProps {
1112
control: any;
@@ -69,6 +70,44 @@ export function CancelSubscriptionModal({
6970
</>
7071
)}
7172
/>
73+
<Controller
74+
name="reasons"
75+
control={control}
76+
render={({ field: { value } }) => {
77+
const isSomethingElseSelected = Array.isArray(value) && value.includes('Something else');
78+
79+
return (
80+
<AutoHeightComponent isVisible={isSomethingElseSelected}>
81+
{isSomethingElseSelected && (
82+
<Controller
83+
name="cancellationReason"
84+
control={control}
85+
rules={{
86+
validate: (val: string) => {
87+
if (isSomethingElseSelected && (!val || val.trim() === '')) {
88+
return 'Please specify your other reason for cancellation';
89+
}
90+
91+
return true;
92+
},
93+
}}
94+
render={({ field, fieldState }) => (
95+
<Textarea
96+
{...field}
97+
placeholder="Please specify your other reason for cancellation"
98+
label="Reason for cancellation"
99+
withAsterisk
100+
minRows={3}
101+
maxRows={6}
102+
error={fieldState.error?.message}
103+
/>
104+
)}
105+
/>
106+
)}
107+
</AutoHeightComponent>
108+
);
109+
}}
110+
/>
72111
</Flex>
73112

74113
<Flex mt="sm" gap="md">

apps/web/hooks/useSubOSIntegration.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export const useSubOSIntegration = () => {
153153
const cancelSubscription = useCallback(
154154
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
155155
async ({ reasons }: CancelSubscriptionParams) => {
156-
// Validation
157156
if (!subOSApis?.subscriptionApi || !isConfigured || !profileInfo?.email) {
158157
throw new Error('SubOS API not properly configured or email not available');
159158
}

0 commit comments

Comments
 (0)