@@ -3,7 +3,12 @@ import React, { useCallback, useEffect, Suspense } from 'react';
33import { useState } from 'react' ;
44import SubscribeButton from '../../atoms/SubscribeButton/SubscribeButton' ;
55import { useTranslations } from 'next-intl' ;
6- import { usePathname , useRouter , useSearchParams } from 'next/navigation' ;
6+ import {
7+ useParams ,
8+ usePathname ,
9+ useRouter ,
10+ useSearchParams ,
11+ } from 'next/navigation' ;
712import { WebinarState } from '@/helpers/webinar.helpers' ;
813import { subscribeToWebinar , unsubscribeToWebinar } from '@/lib/webinarApi' ;
914import { useUser } from '@/helpers/user.helper' ;
@@ -31,6 +36,7 @@ const SubscribeToWebinarContent = ({
3136 const router = useRouter ( ) ;
3237 const pathname = usePathname ( ) ;
3338 const searchParams = useSearchParams ( ) ;
39+ const { locale } = useParams < { locale : string } > ( ) ;
3440 const action = searchParams . get ( 'action' ) ;
3541 const isSubscribeAction = action === 'subscribe' ;
3642
@@ -56,9 +62,9 @@ const SubscribeToWebinarContent = ({
5662 subscribeToWebinar ( webinarSlug , username )
5763 . then ( ( ) => {
5864 reloadUser ( ) . then ( ( ) => setIsLoading ( false ) ) ;
59- if ( ! pathname . includes ( `/webinars/${ webinarSlug } ` ) ) {
65+ if ( ! pathname . includes ( `/${ locale } / webinars/${ webinarSlug } ` ) ) {
6066 // eslint-disable-next-line functional/immutable-data
61- router . push ( `/webinars/${ webinarSlug } ` ) ;
67+ router . push ( `/${ locale } / webinars/${ webinarSlug } ` ) ;
6268 }
6369 } )
6470 . catch ( ( error ) => {
@@ -74,12 +80,13 @@ const SubscribeToWebinarContent = ({
7480 pathname ,
7581 reloadUser ,
7682 router ,
83+ locale ,
7784 ] ) ;
7885
7986 const onSubscribeWithoutUser = ( ) => {
8087 setIsLoading ( true ) ;
81- const finalPath = ! pathname . includes ( `/webinars/${ webinarSlug } ` )
82- ? `/webinars/${ webinarSlug } ?action=subscribe`
88+ const finalPath = ! pathname . includes ( `/${ locale } / webinars/${ webinarSlug } ` )
89+ ? `/${ locale } / webinars/${ webinarSlug } ?action=subscribe`
8390 : `${ pathname } ?action=subscribe` ;
8491
8592 // eslint-disable-next-line functional/immutable-data
0 commit comments