From d9806da049029be8ea9b172ae73f976b33981cb7 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Wed, 15 May 2024 00:26:44 +0530 Subject: [PATCH] fix: better errors for platform (#14987) ## What does this PR do? - Fixes #14977 ## Mandatory Tasks (DO NOT REMOVE) - [ ] I have self-reviewed the code (A decent size PR without self-review might be rejected) - [ ] I have added a Docs issue [here](https://github.com/calcom/docs/issues/new) if this PR makes changes that would require a [documentation change](https://docs.cal.com) - [ ] I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested) ## How should this be tested? - Are there environment variables that should be set? - What are the minimal test data to have? - What is expected (happy path) to have (input and output)? - Any other important info that could help to test that PR ## Checklist - I haven't read the [contributing guide](https://github.com/calcom/cal.com/blob/main/CONTRIBUTING.md) - My code doesn't follow the style guidelines of this project - I haven't commented my code, particularly in hard-to-understand areas - I haven't checked if my changes generate no new warnings --- .../settings/platform/pricing/platform-pricing/index.tsx | 3 ++- .../settings/platform/oauth-clients/[clientId]/edit/index.tsx | 3 ++- apps/web/pages/settings/platform/oauth-clients/create.tsx | 3 ++- apps/web/public/static/locales/en/common.json | 3 +++ packages/lib/errorCodes.ts | 3 +++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx b/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx index 11514a3762..9e10216e46 100644 --- a/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx +++ b/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx @@ -1,5 +1,6 @@ import { useRouter } from "next/navigation"; +import { ErrorCode } from "@calcom/lib/errorCodes"; import { showToast } from "@calcom/ui"; import { useSubscribeTeamToStripe } from "@lib/hooks/settings/platform/oauth-clients/usePersistOAuthClient"; @@ -16,7 +17,7 @@ export const PlatformPricing = ({ teamId }: PlatformPricingProps) => { router.push(redirectUrl); }, onError: () => { - showToast("Internal server error, please try again later", "error"); + showToast(ErrorCode.UnableToSubscribeToThePlatform, "error"); }, teamId, }); diff --git a/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/index.tsx b/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/index.tsx index f5bca77992..5633dc8fc4 100644 --- a/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/index.tsx +++ b/apps/web/pages/settings/platform/oauth-clients/[clientId]/edit/index.tsx @@ -2,6 +2,7 @@ import { useParams } from "next/navigation"; import { useRouter } from "next/navigation"; import Shell from "@calcom/features/shell/Shell"; +import { ErrorCode } from "@calcom/lib/errorCodes"; import { PERMISSIONS_GROUPED_MAP } from "@calcom/platform-constants"; import { showToast } from "@calcom/ui"; @@ -41,7 +42,7 @@ export default function EditOAuthClient() { router.push("/settings/platform/"); }, onError: () => { - showToast("Internal server error, please try again later", "error"); + showToast(ErrorCode.UpdatingOauthClientError, "error"); }, clientId, }); diff --git a/apps/web/pages/settings/platform/oauth-clients/create.tsx b/apps/web/pages/settings/platform/oauth-clients/create.tsx index d049c05f1f..5968be5084 100644 --- a/apps/web/pages/settings/platform/oauth-clients/create.tsx +++ b/apps/web/pages/settings/platform/oauth-clients/create.tsx @@ -1,6 +1,7 @@ import { useRouter } from "next/navigation"; import Shell from "@calcom/features/shell/Shell"; +import { ErrorCode } from "@calcom/lib/errorCodes"; import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; import { PERMISSIONS_GROUPED_MAP } from "@calcom/platform-constants/permissions"; import { showToast } from "@calcom/ui"; @@ -25,7 +26,7 @@ export default function CreateOAuthClient() { router.push("/settings/platform/"); }, onError: () => { - showToast("Internal server error, please try again later", "error"); + showToast(ErrorCode.CreatingOauthClientError, "error"); }, }); diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 6d351a0de5..7ff76a6fd1 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -2441,5 +2441,8 @@ "csat_score": "CSAT Score", "lockedSMS": "Locked SMS", "signing_up_terms": "By proceeding, you agree to our <1>Terms and <2>Privacy Policy.", + "unable_to_subscribe_to_the_platform": "An error occurred while trying to subscribe to the platform plan, please try again later", + "updating_oauth_client_error": "An error occurred while updating the OAuth client, please try again later", + "creating_oauth_client_error": "An error occurred while creating the OAuth client, please try again later", "ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑" } diff --git a/packages/lib/errorCodes.ts b/packages/lib/errorCodes.ts index 3148da1557..8a36c61e5b 100644 --- a/packages/lib/errorCodes.ts +++ b/packages/lib/errorCodes.ts @@ -13,4 +13,7 @@ export enum ErrorCode { NotEnoughAvailableSeats = "not_enough_available_seats_error", AvailabilityNotFoundInSchedule = "availability_not_found_in_schedule_error", CancelledBookingsCannotBeRescheduled = "cancelled_bookings_cannot_be_rescheduled", + UnableToSubscribeToThePlatform = "unable_to_subscribe_to_the_platform", + UpdatingOauthClientError = "updating_oauth_client_error", + CreatingOauthClientError = "creating_oauth_client_error", }