Skip to content

Commit

Permalink
improving code
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocostadev committed Oct 16, 2023
1 parent 53d6ab0 commit a86f99b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 56 deletions.
8 changes: 6 additions & 2 deletions apps/meteor/app/api/server/v1/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,13 @@ API.v1.addRoute(
},
{
async get() {
await syncWorkspace();
try {
await syncWorkspace();

return API.v1.success();
return API.v1.success({ success: true });
} catch (error) {
return API.v1.failure('Error during workspace sync');
}
},
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const ManageSubscriptionPage = () => {
!syncLicenseUpdate.isInitialLoading &&
!syncLicenseUpdate.isRefetching &&
!syncLicenseUpdate.isError &&
syncLicenseUpdate?.data &&
syncLicenseUpdate?.data?.success
) {
refetchLicense();
Expand All @@ -109,56 +108,62 @@ const ManageSubscriptionPage = () => {
{t('Sync_license_update_Callout')}
</Callout>
)}
<Box marginBlock='none' marginInline='auto' width='full' color='default'>
<Grid m={0}>
{!isLicenseLoading || licensesData ? (
<>
<Grid.Item lg={4} xs={4} p={8}>
<PlanCard isEnterprise={isEnterprise} license={license} />
</Grid.Item>
<Grid.Item lg={8} xs={4} p={8}>
<FeaturesCard plan={plan} />
</Grid.Item>
</>
) : (
<>
<Grid.Item lg={4} xs={4} p={8}>
<Skeleton variant='rect' width='full' height={240} />
</Grid.Item>
<Grid.Item lg={8} xs={4} p={8}>
<Skeleton variant='rect' width='full' height={240} />
</Grid.Item>
</>
)}

{plan !== PlanName.COMMUNITY ? (
<>
<Grid.Item lg={6} xs={4} p={8}>
<SeatsCard plan={plan} />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<MACCard plan={plan} monthlyActiveContactsLimit={monthlyActiveContactsLimit} />
</Grid.Item>
</>
) : (
<>
<Grid.Item lg={6} xs={4} p={8}>
<CountSeatsCard />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<CountMACCard />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<ActiveSessionsCard />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<AppsUsageCard privateAppsLimit={privateAppsLimit} marketplaceAppsLimit={marketplaceAppsLimit} />
</Grid.Item>
</>
)}
</Grid>
{plan !== PlanName.ENTERPRISE && plan !== PlanName.ENTERPRISE_TRIAL && <GetMoreWithEnterprise />}
</Box>
{!isLicenseLoading && plan ? (
<Box marginBlock='none' marginInline='auto' width='full' color='default'>
<Grid m={0}>
<Grid.Item lg={4} xs={4} p={8}>
<PlanCard isEnterprise={isEnterprise} license={license} />
</Grid.Item>
<Grid.Item lg={8} xs={4} p={8}>
<FeaturesCard plan={plan} />
</Grid.Item>

{plan === PlanName.COMMUNITY ? (
<>
<Grid.Item lg={6} xs={4} p={8}>
<CountSeatsCard />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<CountMACCard />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<ActiveSessionsCard />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<AppsUsageCard privateAppsLimit={privateAppsLimit} marketplaceAppsLimit={marketplaceAppsLimit} />
</Grid.Item>
</>
) : (
<>
<Grid.Item lg={6} xs={4} p={8}>
<SeatsCard plan={plan} />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<MACCard plan={plan} monthlyActiveContactsLimit={monthlyActiveContactsLimit} />
</Grid.Item>
</>
)}
</Grid>
{plan !== PlanName.ENTERPRISE && plan !== PlanName.ENTERPRISE_TRIAL && <GetMoreWithEnterprise />}
</Box>
) : (
<Box marginBlock='none' marginInline='auto' width='full' color='default'>
<Grid m={0}>
<Grid.Item lg={4} xs={4} p={8}>
<Skeleton variant='rect' width='full' height={240} />
</Grid.Item>
<Grid.Item lg={8} xs={4} p={8}>
<Skeleton variant='rect' width='full' height={240} />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<Skeleton variant='rect' width='full' height={650} />
</Grid.Item>
<Grid.Item lg={6} xs={4} p={8}>
<Skeleton variant='rect' width='full' height={650} />
</Grid.Item>
</Grid>
</Box>
)}
</Page.ScrollableContentWithShadow>
</Page>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const FeaturesCard = ({ plan }: FeaturesCardProps): ReactElement => {
return CE_FEATURES;
}

if (plan === PlanName.ENTERPRISE) {
if (plan === PlanName.ENTERPRISE || plan === PlanName.ENTERPRISE_TRIAL) {
return ENTERPRISE_FEATURES;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -6107,7 +6107,7 @@
"Self_managed_hosting": "Self-managed hosting",
"Cloud_hosting": "Rocket.Chat cloud hosting",
"free_per_month_user": "$0 per month/user",
"Trial_active_active": "Trial active",
"Trial_active": "Trial active",
"Contact_sales_renew_date": "<0>Contact sales</0> to check plan renew date",
"Renews_DATE": "Renews {{date}}",
"Learn_more_about_enterprise": "Learn more about enterprise",
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-typings/src/v1/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ export type CloudEndpoints = {
GET: () => { registrationStatus: CloudRegistrationStatus };
};
'/v1/cloud.syncWorkspace': {
GET: () => void;
GET: () => { success: boolean };
};
};

0 comments on commit a86f99b

Please sign in to comment.