Add Creator details

pull/4530/head
Arik Chakma 1 year ago
parent 3b5e3c44f9
commit 9ebe2f5de7
  1. 15
      src/components/CustomRoadmap/CustomRoadmap.tsx
  2. 19
      src/components/CustomRoadmap/RoadmapHeader.tsx
  3. 4
      src/stores/roadmap.ts

@ -40,6 +40,17 @@ export interface RoadmapContentDocument {
}[]; }[];
} }
export type CreatorType = {
id: string;
name: string;
avatar: string;
};
export type GetRoadmapResponse = RoadmapDocument & {
canManage: boolean;
creator?: CreatorType;
};
export function hideRoadmapLoader() { export function hideRoadmapLoader() {
const loaderEl = document.querySelector( const loaderEl = document.querySelector(
'[data-roadmap-loader]' '[data-roadmap-loader]'
@ -53,7 +64,7 @@ export function CustomRoadmap() {
const { id, secret } = getUrlParams() as { id: string; secret: string }; const { id, secret } = getUrlParams() as { id: string; secret: string };
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [roadmap, setRoadmap] = useState<RoadmapDocument | null>(null); const [roadmap, setRoadmap] = useState<GetRoadmapResponse | null>(null);
const [error, setError] = useState<AppError | FetchError | undefined>(); const [error, setError] = useState<AppError | FetchError | undefined>();
async function getRoadmap() { async function getRoadmap() {
@ -66,7 +77,7 @@ export function CustomRoadmap() {
roadmapUrl.searchParams.set('secret', secret); roadmapUrl.searchParams.set('secret', secret);
} }
const { response, error } = await httpGet<RoadmapDocument>( const { response, error } = await httpGet<GetRoadmapResponse>(
roadmapUrl.toString() roadmapUrl.toString()
); );

@ -15,7 +15,12 @@ export function RoadmapHeader(props: RoadmapHeaderProps) {
const $canManageCurrentRoadmap = useStore(canManageCurrentRoadmap); const $canManageCurrentRoadmap = useStore(canManageCurrentRoadmap);
const $currentRoadmap = useStore(currentRoadmap); const $currentRoadmap = useStore(currentRoadmap);
const { title, description, _id: roadmapId } = useStore(currentRoadmap) || {}; const {
title,
description,
_id: roadmapId,
creator,
} = useStore(currentRoadmap) || {};
const [isSharing, setIsSharing] = useState(false); const [isSharing, setIsSharing] = useState(false);
const toast = useToast(); const toast = useToast();
@ -54,10 +59,20 @@ export function RoadmapHeader(props: RoadmapHeaderProps) {
} }
} }
const avatarUrl = creator?.avatar
? `${import.meta.env.PUBLIC_AVATAR_BASE_URL}/${creator?.avatar}`
: '/images/default-avatar.png';
return ( return (
<div className="border-b"> <div className="border-b">
<div className="container relative py-5 sm:py-12"> <div className="container relative py-5 sm:py-12">
<div className="mb-3 mt-0 sm:mb-4"> <div className="flex items-center gap-1.5">
<img src={avatarUrl} className="h-5 w-5 rounded-full" />
<h3 className="text-sm font-medium">
{creator?.name || 'Anonymous'}
</h3>
</div>
<div className="mb-3 mt-0 mt-4 sm:mb-4">
<h1 className="text-2xl font-bold sm:mb-2 sm:text-4xl">{title}</h1> <h1 className="text-2xl font-bold sm:mb-2 sm:text-4xl">{title}</h1>
<p className="mt-0.5 text-sm text-gray-500 sm:text-lg"> <p className="mt-0.5 text-sm text-gray-500 sm:text-lg">
{description} {description}

@ -1,7 +1,7 @@
import { atom, computed } from 'nanostores'; import { atom, computed } from 'nanostores';
import { type RoadmapDocument } from '../components/CustomRoadmap/CreateRoadmap/CreateRoadmapModal'; import type { GetRoadmapResponse } from '../components/CustomRoadmap/CustomRoadmap';
export const currentRoadmap = atom<RoadmapDocument | undefined>(undefined); export const currentRoadmap = atom<GetRoadmapResponse | undefined>(undefined);
export const isCurrentRoadmapPersonal = computed( export const isCurrentRoadmapPersonal = computed(
currentRoadmap, currentRoadmap,
(roadmap) => !roadmap?.teamId (roadmap) => !roadmap?.teamId

Loading…
Cancel
Save