From 7d5c9c6a2fc8da8b6b90f3b9df1c0b079a612117 Mon Sep 17 00:00:00 2001 From: jerensl <54782057+jerensl@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:35:15 +0800 Subject: [PATCH] refactor: make the link tag optional on learning card Signed-off-by: jerensl <54782057+jerensl@users.noreply.github.com> --- src/custom/LearningCard/LearningCard.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/custom/LearningCard/LearningCard.tsx b/src/custom/LearningCard/LearningCard.tsx index 9ef01a1c..0797c6cc 100644 --- a/src/custom/LearningCard/LearningCard.tsx +++ b/src/custom/LearningCard/LearningCard.tsx @@ -25,11 +25,19 @@ interface Tutorial { interface Props { tutorial: Tutorial; - path: string; + path?: string; courseCount: number; courseType: string; } +const OptionalLink: React.PropsWithChildren<{path?: string}> = ({ path, children }) => { + if (!path) { + return <>{children}> + } + + return {children} +} + const LearningCard: React.FC = ({ tutorial, path, courseCount, courseType }) => { return ( @@ -57,7 +65,7 @@ const LearningCard: React.FC = ({ tutorial, path, courseCount, courseType ) : ( - + @@ -88,7 +96,7 @@ const LearningCard: React.FC = ({ tutorial, path, courseCount, courseType - + )} );