|
|
|
@ -18,6 +18,8 @@ import { pageProgressMessage } from '../../stores/page'; |
|
|
|
|
import { MemberProgressModalHeader } from './MemberProgressModalHeader'; |
|
|
|
|
import { replaceChildren } from '../../lib/dom.ts'; |
|
|
|
|
import { XIcon } from 'lucide-react'; |
|
|
|
|
import type { PageType } from '../CommandMenu/CommandMenu.tsx'; |
|
|
|
|
import { renderFlowJSON } from '../../../editor/renderer/renderer.ts'; |
|
|
|
|
|
|
|
|
|
export type ProgressMapProps = { |
|
|
|
|
member: TeamMember; |
|
|
|
@ -88,14 +90,41 @@ export function MemberProgressModal(props: ProgressMapProps) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function renderResource(jsonUrl: string) { |
|
|
|
|
const { error, response } = await httpGet<PageType[]>(`/pages.json`); |
|
|
|
|
if (error || !response) { |
|
|
|
|
toast.error(error?.message || 'Resource not found'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const page = response.find((page) => { |
|
|
|
|
if (resourceType === 'roadmap') { |
|
|
|
|
return page.url === `/${resourceId}`; |
|
|
|
|
} else if (resourceType === 'best-practice') { |
|
|
|
|
return page.url === `/best-practices/${resourceId}`; |
|
|
|
|
} else if (resourceType === 'question') { |
|
|
|
|
return page.url === `/questions/${resourceId}`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (!page) { |
|
|
|
|
toast.error('Resource not found'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const renderer = page.renderer || 'balsamiq'; |
|
|
|
|
|
|
|
|
|
const res = await fetch(jsonUrl, {}); |
|
|
|
|
const json = await res.json(); |
|
|
|
|
const svg: SVGElement | null = await wireframeJSONToSVG(json, { |
|
|
|
|
fontURL: '/fonts/balsamiq.woff2', |
|
|
|
|
}); |
|
|
|
|
const svg = |
|
|
|
|
renderer === 'editor' |
|
|
|
|
? await renderFlowJSON(json as any) |
|
|
|
|
: await wireframeJSONToSVG(json, { |
|
|
|
|
fontURL: '/fonts/balsamiq.woff2', |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
replaceChildren(containerEl.current!, svg); |
|
|
|
|
// containerEl.current?.replaceChildren(svg);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
useKeydown('Escape', () => { |
|
|
|
@ -136,10 +165,10 @@ export function MemberProgressModal(props: ProgressMapProps) { |
|
|
|
|
skipped = [], |
|
|
|
|
} = memberProgress; |
|
|
|
|
|
|
|
|
|
done.forEach((id: string) => renderTopicProgress(id, 'done')); |
|
|
|
|
learning.forEach((id: string) => renderTopicProgress(id, 'learning')); |
|
|
|
|
skipped.forEach((id: string) => renderTopicProgress(id, 'skipped')); |
|
|
|
|
removed.forEach((id: string) => renderTopicProgress(id, 'removed')); |
|
|
|
|
done.forEach((id) => renderTopicProgress(id, 'done')); |
|
|
|
|
learning.forEach((id) => renderTopicProgress(id, 'learning')); |
|
|
|
|
skipped.forEach((id) => renderTopicProgress(id, 'skipped')); |
|
|
|
|
removed.forEach((id) => renderTopicProgress(id, 'removed')); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
console.error(err); |
|
|
|
|