From 875a7c4c6282c5c8a5f62a955009f2ed55497229 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 30 Jul 2024 02:41:14 +0100 Subject: [PATCH] Button changes on the custom roadmap page --- .../CustomRoadmap/CustomRoadmapRatings.tsx | 31 +++++++++++++------ .../CustomRoadmap/RateRoadmapForm.tsx | 8 ++++- .../CustomRoadmap/RoadmapActionButton.tsx | 20 ++++++------ .../CustomRoadmap/RoadmapHeader.tsx | 19 ++++-------- src/components/Rating/Rating.tsx | 4 +-- 5 files changed, 46 insertions(+), 36 deletions(-) diff --git a/src/components/CustomRoadmap/CustomRoadmapRatings.tsx b/src/components/CustomRoadmap/CustomRoadmapRatings.tsx index 9cf4f1160..e1d7caebe 100644 --- a/src/components/CustomRoadmap/CustomRoadmapRatings.tsx +++ b/src/components/CustomRoadmap/CustomRoadmapRatings.tsx @@ -35,16 +35,27 @@ export function CustomRoadmapRatings(props: CustomRoadmapRatingsProps) { /> )} {average === 0 && ( - + <> + {!canManage && ( + + )} + {canManage && ( + + + No ratings yet + Rate + + )} + )} {average > 0 && ( diff --git a/src/components/CustomRoadmap/RateRoadmapForm.tsx b/src/components/CustomRoadmap/RateRoadmapForm.tsx index cdf21b7cd..68363d667 100644 --- a/src/components/CustomRoadmap/RateRoadmapForm.tsx +++ b/src/components/CustomRoadmap/RateRoadmapForm.tsx @@ -46,6 +46,12 @@ export function RateRoadmapForm(props: RateRoadmapFormProps) { const [userFeedback, setUserFeedback] = useState(''); const loadMyRoadmapRating = async () => { + // user can't have the rating for their own roadmap + if (canManage) { + setIsLoading(false); + return; + } + const { response, error } = await httpGet( `${import.meta.env.PUBLIC_API_URL}/v1-get-my-roadmap-rating/${roadmapSlug}`, ); @@ -127,7 +133,7 @@ export function RateRoadmapForm(props: RateRoadmapFormProps) { )} - + {percentage}% diff --git a/src/components/CustomRoadmap/RoadmapActionButton.tsx b/src/components/CustomRoadmap/RoadmapActionButton.tsx index b6a6b3f3c..59a65e8be 100644 --- a/src/components/CustomRoadmap/RoadmapActionButton.tsx +++ b/src/components/CustomRoadmap/RoadmapActionButton.tsx @@ -1,6 +1,6 @@ import { useRef, useState } from 'react'; import { useOutsideClick } from '../../hooks/use-outside-click'; -import { Lock, MoreVertical, Shapes, Trash2 } from 'lucide-react'; +import { Lock, MoreVertical, PenSquare, Shapes, Trash2 } from 'lucide-react'; type RoadmapActionButtonProps = { onDelete?: () => void; @@ -32,34 +32,34 @@ export function RoadmapActionButton(props: RoadmapActionButtonProps) { {isOpen && (
    - {onUpdateSharing && ( + {onCustomize && (
  • )} - {onCustomize && ( + {onUpdateSharing && (
  • )} diff --git a/src/components/CustomRoadmap/RoadmapHeader.tsx b/src/components/CustomRoadmap/RoadmapHeader.tsx index 6cc1dd52d..69e30e3cb 100644 --- a/src/components/CustomRoadmap/RoadmapHeader.tsx +++ b/src/components/CustomRoadmap/RoadmapHeader.tsx @@ -115,7 +115,7 @@ export function RoadmapHeader(props: RoadmapHeaderProps) { aria-label="Back to All Roadmaps" > ← -  Community Roadmaps +  Discover More )} - - - Edit - Edit - - setIsSharing(true)} + onCustomize={() => { + window.location.href = `${ + import.meta.env.PUBLIC_EDITOR_APP_URL + }/${$currentRoadmap?._id}`; + }} onDelete={() => { const confirmation = window.confirm( 'Are you sure you want to delete this roadmap?', diff --git a/src/components/Rating/Rating.tsx b/src/components/Rating/Rating.tsx index 5a880fef4..c04f07281 100644 --- a/src/components/Rating/Rating.tsx +++ b/src/components/Rating/Rating.tsx @@ -44,9 +44,9 @@ export function Rating(props: RatingProps) { /> ); })} - {props.total && ( + {(props.total || 0) > 0 && ( - ({Intl.NumberFormat('en-US').format(props.total)}) + ({Intl.NumberFormat('en-US').format(props.total!)}) )}