From 955d04e532fab7427a43898c58a8f6b49033f7dd Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Wed, 14 Jun 2023 20:58:15 +0100 Subject: [PATCH] UI changes on road cards --- src/components/RoadCard/RoadCardPage.tsx | 10 ++--- src/components/RoadCard/RoadmapSelect.tsx | 53 +++++++++++------------ src/pages/account/road-card.astro | 2 +- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/components/RoadCard/RoadCardPage.tsx b/src/components/RoadCard/RoadCardPage.tsx index d1afe3f48..51cef87d4 100644 --- a/src/components/RoadCard/RoadCardPage.tsx +++ b/src/components/RoadCard/RoadCardPage.tsx @@ -44,12 +44,12 @@ export function RoadCardPage() { return ( <> -
+
-
+
-
+
@@ -85,7 +85,7 @@ export function RoadCardPage() {
-
+
@@ -111,7 +111,7 @@ export function RoadCardPage() {
-
+
diff --git a/src/components/RoadCard/RoadmapSelect.tsx b/src/components/RoadCard/RoadmapSelect.tsx index 6207b6218..45d29e856 100644 --- a/src/components/RoadCard/RoadmapSelect.tsx +++ b/src/components/RoadCard/RoadmapSelect.tsx @@ -33,37 +33,36 @@ export function RoadmapSelect(props: RoadmapSelectProps) { }, []); const canSelectMore = selectedRoadmaps.length < 4; + const allProgress = progressList?.filter( + (progress) => progress.resourceType === 'roadmap' + ) || []; return (
- {progressList - ?.filter((progress) => progress.resourceType === 'roadmap') - .map((progress) => { - const isSelected = selectedRoadmaps.includes(progress.resourceId); - const canSelect = isSelected || canSelectMore; + {allProgress?.length === 0 &&

No progress tracked so far.

} + {allProgress?.map((progress) => { + const isSelected = selectedRoadmaps.includes(progress.resourceId); + const canSelect = isSelected || canSelectMore; - return ( - { - if (isSelected) { - setSelectedRoadmaps( - selectedRoadmaps.filter( - (roadmap) => roadmap !== progress.resourceId - ) - ); - } else if (selectedRoadmaps.length < 4) { - setSelectedRoadmaps([ - ...selectedRoadmaps, - progress.resourceId, - ]); - } - }} - /> - ); - })} + return ( + { + if (isSelected) { + setSelectedRoadmaps( + selectedRoadmaps.filter( + (roadmap) => roadmap !== progress.resourceId + ) + ); + } else if (selectedRoadmaps.length < 4) { + setSelectedRoadmaps([...selectedRoadmaps, progress.resourceId]); + } + }} + /> + ); + })}
); } diff --git a/src/pages/account/road-card.astro b/src/pages/account/road-card.astro index 0d411c1f3..657278254 100644 --- a/src/pages/account/road-card.astro +++ b/src/pages/account/road-card.astro @@ -7,7 +7,7 @@ import { RoadCardPage } from '../../components/RoadCard/RoadCardPage';