Skip to content

Commit

Permalink
fix(server error): 'course updated to empty array'
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitmlesmagico committed Apr 12, 2024
1 parent f273552 commit 165b13c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 32 deletions.
31 changes: 17 additions & 14 deletions src/components/Course/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,23 @@ const CourseCard = ({ courseDetails }: { courseDetails: CourseType }) => {
<div
className={`w-[211px] ${outfit.className} text-[13px] font-normal text-neutral-500`}
>
{courseDetails?.competency?.map((item, index) => {
if (index < 2) {
return (
<li className='font-semibold' key={item.id}>
{item.name} (
{item?.levels
.map((level) => `L${level.levelNumber}`)
.join(', ')}
){index == 1 && '....'}
</li>
);
}
return null; // Skip rendering for keys beyond the first two and the ellipsis
})}
{courseDetails &&
courseDetails.competency &&
Array.isArray(courseDetails.competency) &&
courseDetails.competency.map((item, index) => {
if (index < 2) {
return (
<li className='font-semibold' key={item.id}>
{item.name} (
{item.levels
.map((level) => `L${level.levelNumber}`)
.join(', ')}
){index === 1 && '....'}
</li>
);
}
return null; // Skip rendering for keys beyond the first two and the ellipsis
})}
</div>
</div>
{/* Icon and language list */}
Expand Down
80 changes: 62 additions & 18 deletions src/redux/marketplace/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,75 @@ type marketplaceActionTypes = {
};
};

// export const getSavedCourse = async (userId: string) => {
// const data = await axios.get(
// `${marketBackendUrl}/api/consumer/${userId}/course/saved`
// );
// return data.data.data.consumerCourses;
// };
// export const getOngoingCourses = async (userId: string) => {
// const data = await axios.get(
// `${marketBackendUrl}/api/consumer/${userId}/course/ongoing`
// );
// return data.data.data.consumerCourses;
// };
// export const getMostPopularCourses = async () => {
// // api is not correct for now
// const data = await axios.get(
// `${marketBackendUrl}/api/consumer/course/popular?limit=10&offset=0`
// );
// return data.data.data.response;
// };
// export const getRecommendedCourses = async (userId: string) => {
// // api is not correct for now
// const data = await axios.get(
// `${marketBackendUrl}/api/consumer/${userId}/course/recommended`
// );
// return data.data.data.response;
// };

export const getSavedCourse = async (userId: string) => {
const data = await axios.get(
`${marketBackendUrl}/api/consumer/${userId}/course/saved`
);
return data.data.data.consumerCourses;
try {
const data = await axios.get(
`${marketBackendUrl}/api/consumer/${userId}/course/saved`
);
return data.data.data.consumerCourses;
} catch (error) {
return [];
}
};

export const getOngoingCourses = async (userId: string) => {
const data = await axios.get(
`${marketBackendUrl}/api/consumer/${userId}/course/ongoing`
);
return data.data.data.consumerCourses;
try {
const data = await axios.get(
`${marketBackendUrl}/api/consumer/${userId}/course/ongoing`
);
return data.data.data.consumerCourses;
} catch (error) {
return [];
}
};

export const getMostPopularCourses = async () => {
// api is not correct for now
const data = await axios.get(
`${marketBackendUrl}/api/consumer/course/popular?limit=10&offset=0`
);
return data.data.data.response;
try {
const data = await axios.get(
`${marketBackendUrl}/api/consumer/course/popular?limit=10&offset=0`
);
return data.data.data.response;
} catch (error) {
return [];
}
};

export const getRecommendedCourses = async (userId: string) => {
// api is not correct for now
const data = await axios.get(
`${marketBackendUrl}/api/consumer/${userId}/course/recommended`
);
return data.data.data.response;
try {
const data = await axios.get(
`${marketBackendUrl}/api/consumer/${userId}/course/recommended`
);
return data.data.data.response;
} catch (error) {
return [];
}
};

export const getMarketplaceCourses = (userId: string) => {
Expand Down

0 comments on commit 165b13c

Please sign in to comment.