From 52f13e1bdb8d8b236f31d435d04ebc89f3a2c44b Mon Sep 17 00:00:00 2001 From: faisalEsMagico Date: Mon, 18 Dec 2023 12:31:15 +0530 Subject: [PATCH] feat(changes): competency data schema change --- src/app/3cp/marketplace/page.tsx | 14 +++++++++++--- src/components/3cp/Competency.tsx | 23 ++++++++++++----------- src/components/3cp/SingleCompetency.tsx | 20 ++++++++++++-------- src/components/3cp/SingleCourse.tsx | 18 +++++++++++------- 4 files changed, 46 insertions(+), 29 deletions(-) diff --git a/src/app/3cp/marketplace/page.tsx b/src/app/3cp/marketplace/page.tsx index cbe3bbd..5d996c3 100644 --- a/src/app/3cp/marketplace/page.tsx +++ b/src/app/3cp/marketplace/page.tsx @@ -9,15 +9,23 @@ import ProfileNavbar from '@/components/wpcasOverView/ProfileNavbar'; import { getAllCourses } from '@/services/marketPlaceServices'; -type competencyType = { - [key: string]: string[]; +export type LevelsType = { + id: string; + levelNumber: number; + name: string; +}; + +type CompetencyType = { + id: string; + name: string; + levels: LevelsType[]; }; export type CourseType = { courseId: string; title: string; providerLogo: string; - competency: competencyType; + competency: CompetencyType[]; providerName: string; author: string; language: string[]; diff --git a/src/components/3cp/Competency.tsx b/src/components/3cp/Competency.tsx index 9d499c9..b0bdc15 100644 --- a/src/components/3cp/Competency.tsx +++ b/src/components/3cp/Competency.tsx @@ -5,17 +5,18 @@ import { CourseType } from '@/app/3cp/marketplace/page'; const Competencies = ({ courseDetails }: { courseDetails: CourseType }) => { return (
- {Object.keys(courseDetails?.competency).map((key, index) => { - return ( - - ); - })} + {courseDetails?.competency?.length > 0 && + courseDetails?.competency?.map((competency) => { + return ( + + ); + })}
); }; diff --git a/src/components/3cp/SingleCompetency.tsx b/src/components/3cp/SingleCompetency.tsx index fcff277..02f1ed5 100644 --- a/src/components/3cp/SingleCompetency.tsx +++ b/src/components/3cp/SingleCompetency.tsx @@ -4,12 +4,15 @@ import { MdKeyboardArrowDown, MdKeyboardArrowUp } from 'react-icons/md'; import { outfit, poppins } from '@/components/FontFamily'; +import { LevelsType } from '@/app/3cp/marketplace/page'; + type CompetencyType = { name: string; - levels: string[]; + levels: LevelsType[]; }; const SingleCompetency = ({ competency }: { competency: CompetencyType }) => { const [open, setOpen] = useState(false); + return (
@@ -34,13 +37,14 @@ const SingleCompetency = ({ competency }: { competency: CompetencyType }) => {

)} diff --git a/src/components/3cp/SingleCourse.tsx b/src/components/3cp/SingleCourse.tsx index 90876e9..5cb05e8 100644 --- a/src/components/3cp/SingleCourse.tsx +++ b/src/components/3cp/SingleCourse.tsx @@ -71,13 +71,17 @@ const SingleCourse = ({

    - {Object.keys(course?.competency ?? {})?.map((key) => { - return ( -
  1. - {key} ( {course?.competency[key]?.join(', ')} ) -
  2. - ); - })} + {course?.competency?.length > 0 && + course?.competency?.map((competency) => { + return ( +
  3. + {competency?.name}{' '} + {competency?.levels?.map((level) => { + return `L${level?.levelNumber},`; + })} +
  4. + ); + })}