Skip to content

Commit fe27672

Browse files
authored
fix: subscription should be protected for non org members (#977)
1 parent 3bcd674 commit fe27672

File tree

3 files changed

+53
-58
lines changed

3 files changed

+53
-58
lines changed

src/components/Organization/NoOrganizations.tsx

+41-36
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,47 @@ import empty from '/assets/illustrations/9.png'
77

88
export const NoOrganizations = () => {
99
return (
10-
<Card variant='no-elections' minH='100%' maxW='650' m='80px auto'>
11-
<CardBody>
12-
<Flex justifyContent={'center'}>
13-
<Img src={empty} />
14-
</Flex>
15-
<Box>
16-
<Text fontWeight='600' fontSize='lg' m='20px 0px'>
17-
<Trans i18nKey='organization.no_organization_title'>You don't belong to any organization yet!</Trans>
18-
</Text>
19-
<Text mb='20px'>
20-
<Trans i18nKey='new_organization.description1' components={{ span: <Text as='span' fontWeight='600' /> }}>
21-
Set up your{' '}
22-
<Text as='span' fontWeight='bold'>
23-
organization for free
24-
</Text>{' '}
25-
and start creating voting processes to engage with your community.
26-
</Trans>
27-
</Text>
28-
<Text mb='20px'>
29-
<Trans i18nKey='create_org.already_profile'>
30-
If your organization already have a profile, ask the admin to invite you to your organization.
31-
</Trans>
32-
</Text>
33-
</Box>
34-
<Button
35-
mt='40px'
36-
w='100%'
37-
variant='primary'
38-
as={ReactRouterLink}
39-
to={Routes.dashboard.organizationCreate}
40-
colorScheme='gradient'
41-
>
42-
<Trans i18nKey='create_org.title'>Create your organization</Trans>
43-
</Button>
44-
</CardBody>
45-
</Card>
10+
<Flex flexDirection={'column'}>
11+
<Button as={ReactRouterLink} to={Routes.plans} alignSelf='end'>
12+
<Trans i18nKey='view_plans_and_pricing'>View Plans & Pricing</Trans>
13+
</Button>
14+
<Card variant='no-elections' minH='100%' maxW='650' m='80px auto'>
15+
<CardBody>
16+
<Flex justifyContent={'center'}>
17+
<Img src={empty} />
18+
</Flex>
19+
<Box>
20+
<Text fontWeight='600' fontSize='lg' m='20px 0px'>
21+
<Trans i18nKey='organization.no_organization_title'>You don't belong to any organization yet!</Trans>
22+
</Text>
23+
<Text mb='20px'>
24+
<Trans i18nKey='new_organization.description1' components={{ span: <Text as='span' fontWeight='600' /> }}>
25+
Set up your{' '}
26+
<Text as='span' fontWeight='bold'>
27+
organization for free
28+
</Text>{' '}
29+
and start creating voting processes to engage with your community.
30+
</Trans>
31+
</Text>
32+
<Text mb='20px'>
33+
<Trans i18nKey='create_org.already_profile'>
34+
If your organization already have a profile, ask the admin to invite you to your organization.
35+
</Trans>
36+
</Text>
37+
</Box>
38+
<Button
39+
mt='40px'
40+
w='100%'
41+
variant='primary'
42+
as={ReactRouterLink}
43+
to={Routes.dashboard.organizationCreate}
44+
colorScheme='gradient'
45+
>
46+
<Trans i18nKey='create_org.title'>Create your organization</Trans>
47+
</Button>
48+
</CardBody>
49+
</Card>
50+
</Flex>
4651
)
4752
}
4853

src/components/Organization/Subscription.tsx

+4-14
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const Subscription = () => {
3737

3838
return (
3939
<VStack gap={4} w='full'>
40-
<Button as={RouterLink} to={Routes.plans} alignSelf='end'>
40+
<Button onClick={() => openModal('subscription')} alignSelf='end'>
4141
<Trans i18nKey='view_plans_and_pricing'>View Plans & Pricing</Trans>
4242
</Button>
4343
<SubscriptionList />
@@ -85,7 +85,6 @@ export const SubscriptionList = () => {
8585
})
8686

8787
const isFree = subscription.plan.id === PlanId.Free
88-
const { openModal } = usePricingModal()
8988

9089
return (
9190
<VStack gap={4} w='full' mt='8'>
@@ -107,7 +106,7 @@ export const SubscriptionList = () => {
107106
</Alert>
108107
)}
109108
<TableContainer w='full'>
110-
<Table size='sm' variant={'subscription'}>
109+
<Table size='sm'>
111110
<Thead>
112111
<Tr>
113112
<Th>
@@ -119,12 +118,9 @@ export const SubscriptionList = () => {
119118
<Th>
120119
<Trans i18nKey='subscription.since'>Since</Trans>
121120
</Th>
122-
<Th>
121+
<Th colSpan={isFree ? 1 : 2}>
123122
<Trans i18nKey='subscription.next_billing'>Next Billing</Trans>
124123
</Th>
125-
<Th>
126-
<Trans i18nKey='subscription.action'>Action</Trans>
127-
</Th>
128124
</Tr>
129125
</Thead>
130126
<Tbody>
@@ -144,13 +140,7 @@ export const SubscriptionList = () => {
144140
<Td>
145141
<Tag>{new Date(subscription.subscriptionDetails.renewalDate).toLocaleDateString()}</Tag>
146142
</Td>
147-
{isFree ? (
148-
<Td>
149-
<Button variant='primary' size='sm' isLoading={isLoading} onClick={() => openModal('subscription')}>
150-
<Trans i18nKey='upgrade'>Upgrade</Trans>
151-
</Button>
152-
</Td>
153-
) : (
143+
{!isFree && (
154144
<Td>
155145
<Button variant='outline' size='sm' isLoading={isLoading} onClick={() => handleChangeClick()}>
156146
<Trans i18nKey='subscription.change_plan_button'>Change</Trans>

src/router/routes/dashboard.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,16 @@ export const useDashboardRoutes = () => {
110110
</SuspenseLoader>
111111
),
112112
},
113+
{
114+
path: Routes.dashboard.subscription,
115+
element: (
116+
<SuspenseLoader>
117+
<SubscriptionPage />
118+
</SuspenseLoader>
119+
),
120+
},
113121
],
114122
},
115-
{
116-
path: Routes.dashboard.subscription,
117-
element: (
118-
<SuspenseLoader>
119-
<SubscriptionPage />
120-
</SuspenseLoader>
121-
),
122-
},
123123
],
124124
},
125125
],

0 commit comments

Comments
 (0)