1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-03 06:12:53 +02:00

wip: resource progress

This commit is contained in:
Arik Chakma
2025-05-21 23:09:31 +06:00
parent 845c869d8d
commit 4e53d1bf28
2 changed files with 50 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ import { RoadmapAIChatCard } from './RoadmapAIChatCard';
import { UserProgressList } from './UserProgressList';
import { UserProgressActionList } from './UserProgressActionList';
import { RoadmapTopicList } from './RoadmapTopicList';
import { ShareResourceLink } from './ShareResourceLink';
export type RoamdapAIChatHistoryType = {
role: AllowedAIChatRole;
@@ -153,6 +154,9 @@ export function RoadmapAIChat(props: RoadmapAIChatProps) {
'roadmap-topics': (options) => {
return <RoadmapTopicList roadmapId={roadmapId} {...options} />;
},
'resource-progress-link': () => {
return <ShareResourceLink roadmapId={roadmapId} />;
},
};
}, [roadmapId]);

View File

@@ -0,0 +1,46 @@
import { ShareIcon } from 'lucide-react';
import { useAuth } from '../../hooks/use-auth';
import { useCopyText } from '../../hooks/use-copy-text';
import { CheckIcon } from '../ReactIcons/CheckIcon';
import { cn } from '../../lib/classname';
type ShareResourceLinkProps = {
roadmapId: string;
};
export function ShareResourceLink(props: ShareResourceLinkProps) {
const { roadmapId } = props;
const user = useAuth();
const { copyText, isCopied } = useCopyText();
const handleShareResourceLink = () => {
const url = `${import.meta.env.PUBLIC_APP_URL}/${roadmapId}?s=${user?.id}`;
copyText(url);
};
return (
<div className="relative my-6 flex flex-wrap gap-1 first:mt-0 last:mb-0">
<button
className={cn(
'flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white p-1 px-1.5 text-left text-sm',
isCopied && 'text-green-500',
)}
onClick={handleShareResourceLink}
>
{!isCopied && (
<>
<ShareIcon className="h-4 w-4" />
Share Progress
</>
)}
{isCopied && (
<>
<CheckIcon additionalClasses="h-4 w-4" />
Copied
</>
)}
</button>
</div>
);
}