Connect, collaborate, and grow with a community of TypeScript developers
fix(tracks): prompt for user login before track enrollment (#915)
Aakash772c04297cf6
diff --git a/apps/web/src/app/[locale]/tracks/_components/enroll-button.tsx b/apps/web/src/app/[locale]/tracks/_components/enroll-button.tsxindex cc2382f9..c394132f 100644--- a/apps/web/src/app/[locale]/tracks/_components/enroll-button.tsx+++ b/apps/web/src/app/[locale]/tracks/_components/enroll-button.tsx@@ -21,14 +21,27 @@ export function ActionButton({ action, text, trackId }: EnrollButtonProps) {variant: 'success',description: <p>You're now successfully {text.toLowerCase()}ed the track.</p>,});- } catch {- toast({- title: 'Error',- variant: 'destructive',- description: (- <p>There was an error trying to {text.toLowerCase()} you from the track.</p>- ),- });+ } catch (error) {+ error instanceof Error && error.message === 'User is not logged in'+ ? toast({+ title: `Please Login to continue`,+ variant: 'destructive',+ description: (+ <p>+ You must be logged in to enroll in a track.{' '}+ <a href="/login" className="font-bold underline">+ Login+ </a>+ </p>+ ),+ })+ : toast({+ title: `Error`,+ variant: 'destructive',+ description: (+ <p>There was an error trying to {text.toLowerCase()} you from the track.</p>+ ),+ });}}}>