From 023815c23a83a71d897e235a0d7fbe5aab353803 Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Tue, 18 Jun 2024 17:09:53 +0530 Subject: [PATCH 1/3] Issue #PS-000 chore: Modified route names as per next js standard --- src/components/MenuDrawer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MenuDrawer.tsx b/src/components/MenuDrawer.tsx index fe2a296b..09ba0aca 100644 --- a/src/components/MenuDrawer.tsx +++ b/src/components/MenuDrawer.tsx @@ -56,7 +56,7 @@ const MenuDrawer: React.FC = ({ }; const isDashboard = router.pathname === '/dashboard'; - const isTeacherCenter = router.pathname === '/teachingCenters'; + const isTeacherCenter = router.pathname === '/teaching-centers'; return ( = ({ }} startIcon={} onClick={() => { - router.push(`/teachingCenters`); // Check route + router.push(`/teaching-centers`); // Check route }} > {t('DASHBOARD.MY_TEACHING_CENTERS')} From 64dd0a6529918982cf3fe487f4b225f0abf94907 Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Tue, 18 Jun 2024 18:04:24 +0530 Subject: [PATCH 2/3] Issue #PS-793 chore: Implemented dynamic routing for the center and center details page --- src/components/MenuDrawer.tsx | 4 +-- .../[cohortId].tsx} | 10 ++++++ .../index.tsx} | 5 +-- src/services/MyClassDetailsService.ts | 34 +++++++++---------- 4 files changed, 32 insertions(+), 21 deletions(-) rename src/pages/{teaching-center-details.tsx => centers/[cohortId].tsx} (91%) rename src/pages/{teaching-centers.tsx => centers/index.tsx} (96%) diff --git a/src/components/MenuDrawer.tsx b/src/components/MenuDrawer.tsx index 09ba0aca..b413c237 100644 --- a/src/components/MenuDrawer.tsx +++ b/src/components/MenuDrawer.tsx @@ -56,7 +56,7 @@ const MenuDrawer: React.FC = ({ }; const isDashboard = router.pathname === '/dashboard'; - const isTeacherCenter = router.pathname === '/teaching-centers'; + const isTeacherCenter = router.pathname === '/centers'; return ( = ({ }} startIcon={} onClick={() => { - router.push(`/teaching-centers`); // Check route + router.push(`/centers`); // Check route }} > {t('DASHBOARD.MY_TEACHING_CENTERS')} diff --git a/src/pages/teaching-center-details.tsx b/src/pages/centers/[cohortId].tsx similarity index 91% rename from src/pages/teaching-center-details.tsx rename to src/pages/centers/[cohortId].tsx index 72598f43..391c7255 100644 --- a/src/pages/teaching-center-details.tsx +++ b/src/pages/centers/[cohortId].tsx @@ -12,9 +12,13 @@ import Tabs from '@mui/material/Tabs'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; +import { useRouter } from 'next/router'; +import { GetStaticPaths } from 'next'; const TeachingCenterDetails = () => { const [value, setValue] = React.useState(1); + const router = useRouter(); + const { cohortId }: any = router.query; const handleChange = (event: React.SyntheticEvent, newValue: number) => { setValue(newValue); @@ -141,5 +145,11 @@ export async function getStaticProps({ locale }: any) { }, }; } +export const getStaticPaths: GetStaticPaths<{ slug: string }> = async () => { + return { + paths: [], //indicates that no page needs be created at build time + fallback: 'blocking', //indicates the type of fallback + }; + }; export default TeachingCenterDetails; diff --git a/src/pages/teaching-centers.tsx b/src/pages/centers/index.tsx similarity index 96% rename from src/pages/teaching-centers.tsx rename to src/pages/centers/index.tsx index 25279d54..283fb40f 100644 --- a/src/pages/teaching-centers.tsx +++ b/src/pages/centers/index.tsx @@ -5,7 +5,7 @@ import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'; import Header from '@/components/Header'; import Image from 'next/image'; -import building from '../assets/images/apartment.png'; +import building from '../../assets/images/apartment.png'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { useRouter } from 'next/router'; import { useTheme } from '@mui/material/styles'; @@ -54,7 +54,8 @@ const TeachingCenters = () => { > { - router.push(`/teachingCenterDetails`); // Check route + // router.push(`/centers/${cohortId}`); // Check route + router.push(`/centers/12345`) }} sx={{ cursor: 'pointer' }} > diff --git a/src/services/MyClassDetailsService.ts b/src/services/MyClassDetailsService.ts index 26cac006..14b33350 100644 --- a/src/services/MyClassDetailsService.ts +++ b/src/services/MyClassDetailsService.ts @@ -22,20 +22,20 @@ export const getMyCohortMemberList = async ({ } }; -export const updateCohortMemberStatus = async ({ - memberStatus, - statusReason -}: updateCohortMemberStatusParams): Promise => { - const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/cohortmember/update/${userId}`; - try { - const response = await put(apiUrl, { - memberStatus, - statusReason - }); - console.log('data', response?.data); - return response?.data; - } catch (error) { - console.error('error in attendance report api ', error); - // throw error; - } -}; +// export const updateCohortMemberStatus = async ({ +// memberStatus, +// statusReason +// }: updateCohortMemberStatusParams): Promise => { +// const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/cohortmember/update/${userId}`; +// try { +// const response = await put(apiUrl, { +// memberStatus, +// statusReason +// }); +// console.log('data', response?.data); +// return response?.data; +// } catch (error) { +// console.error('error in attendance report api ', error); +// // throw error; +// } +// }; From 13f48f3184713cd80b626becf7e3a355c9c6eb32 Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Tue, 18 Jun 2024 18:08:14 +0530 Subject: [PATCH 3/3] Issue #000 chore: Added comment to replace path name --- src/pages/centers/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/centers/index.tsx b/src/pages/centers/index.tsx index 283fb40f..5fc96dd0 100644 --- a/src/pages/centers/index.tsx +++ b/src/pages/centers/index.tsx @@ -55,7 +55,7 @@ const TeachingCenters = () => { { // router.push(`/centers/${cohortId}`); // Check route - router.push(`/centers/12345`) + router.push(`/centers/12345`) //TODO: Replace 12345 with cohortId }} sx={{ cursor: 'pointer' }} >