mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-09-03 06:12:53 +02:00
Fix wrong count of topics
This commit is contained in:
@@ -229,10 +229,24 @@ export function RoadmapAIChat(props: RoadmapAIChatProps) {
|
||||
[roadmapId, deviceType],
|
||||
);
|
||||
|
||||
const totalTopicCount = useMemo(() => {
|
||||
const allowedTypes = ['topic', 'subtopic', 'todo'];
|
||||
return (
|
||||
roadmapDetail?.json?.nodes.filter((node) =>
|
||||
allowedTypes.includes(node.type || ''),
|
||||
).length ?? 0
|
||||
);
|
||||
}, [roadmapDetail]);
|
||||
|
||||
const renderer: Record<string, MessagePartRenderer> = useMemo(() => {
|
||||
return {
|
||||
'user-progress': () => {
|
||||
return <UserProgressList roadmapId={roadmapId} />;
|
||||
return (
|
||||
<UserProgressList
|
||||
totalTopicCount={totalTopicCount}
|
||||
roadmapId={roadmapId}
|
||||
/>
|
||||
);
|
||||
},
|
||||
'update-progress': (options) => {
|
||||
return <UserProgressActionList roadmapId={roadmapId} {...options} />;
|
||||
@@ -260,7 +274,7 @@ export function RoadmapAIChat(props: RoadmapAIChatProps) {
|
||||
return <RoadmapRecommendations roadmapId={roadmapId} {...options} />;
|
||||
},
|
||||
};
|
||||
}, [roadmapId, handleSelectTopic]);
|
||||
}, [roadmapId, handleSelectTopic, totalTopicCount]);
|
||||
|
||||
const completeAITutorChat = async (
|
||||
messages: RoamdapAIChatHistoryType[],
|
||||
|
@@ -4,18 +4,18 @@ import { userResourceProgressOptions } from '../../queries/resource-progress';
|
||||
import { getPercentage } from '../../lib/number';
|
||||
|
||||
type UserProgressListProps = {
|
||||
totalTopicCount: number;
|
||||
roadmapId: string;
|
||||
};
|
||||
|
||||
export function UserProgressList(props: UserProgressListProps) {
|
||||
const { roadmapId } = props;
|
||||
const { totalTopicCount, roadmapId } = props;
|
||||
|
||||
const { data: userResourceProgressData } = useQuery(
|
||||
userResourceProgressOptions('roadmap', roadmapId),
|
||||
queryClient,
|
||||
);
|
||||
|
||||
const totalTopicCount = userResourceProgressData?.totalTopicCount ?? 0;
|
||||
const doneCount = userResourceProgressData?.done?.length ?? 0;
|
||||
const skippedCount = userResourceProgressData?.skipped?.length ?? 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ export function UserProgressList(props: UserProgressListProps) {
|
||||
{progressPercentage}%
|
||||
</span>
|
||||
</div>
|
||||
<span className="text-sm hidden md:block font-medium text-gray-600">
|
||||
<span className="hidden text-sm font-medium text-gray-600 md:block">
|
||||
{totalFinished} / {totalTopicCount} topics
|
||||
</span>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user