1+ import { useStore } from '@nanostores/react' ;
12import { useEffect , useState } from 'react' ;
2- import { httpGet } from '../../lib/http' ;
3+ import { cn } from '../../../editor/utils/classname' ;
4+ import { useParams } from '../../hooks/use-params' ;
35import { useToast } from '../../hooks/use-toast' ;
4- import { useStore } from '@nanostores/react' ;
6+ import { httpGet } from '../../lib/http' ;
7+ import { getUser } from '../../lib/jwt' ;
58import { $teamList } from '../../stores/team' ;
69import type { TeamListResponse } from '../TeamDropdown/TeamDropdown' ;
7- import { DashboardTab } from './DashboardTab ' ;
10+ import { DashboardTabButton } from './DashboardTabButton ' ;
811import { PersonalDashboard , type BuiltInRoadmap } from './PersonalDashboard' ;
912import { TeamDashboard } from './TeamDashboard' ;
10- import { getUser } from '../../lib/jwt' ;
11- import { useParams } from '../../hooks/use-params' ;
13+ import type { QuestionGroupType } from '../../lib/question-group' ;
14+ import type { GuideFileType } from '../../lib/guide' ;
15+ import type { VideoFileType } from '../../lib/video' ;
1216
1317type DashboardPageProps = {
1418 builtInRoleRoadmaps ?: BuiltInRoadmap [ ] ;
1519 builtInSkillRoadmaps ?: BuiltInRoadmap [ ] ;
1620 builtInBestPractices ?: BuiltInRoadmap [ ] ;
1721 isTeamPage ?: boolean ;
22+ questionGroups ?: QuestionGroupType [ ] ;
23+ guides ?: GuideFileType [ ] ;
24+ videos ?: VideoFileType [ ] ;
1825} ;
1926
2027export function DashboardPage ( props : DashboardPageProps ) {
@@ -23,6 +30,9 @@ export function DashboardPage(props: DashboardPageProps) {
2330 builtInBestPractices,
2431 builtInSkillRoadmaps,
2532 isTeamPage = false ,
33+ questionGroups,
34+ guides,
35+ videos,
2636 } = props ;
2737
2838 const currentUser = getUser ( ) ;
@@ -66,78 +76,80 @@ export function DashboardPage(props: DashboardPageProps) {
6676 : '/images/default-avatar.png' ;
6777
6878 return (
69- < div className = "min-h-screen bg-gray-50 pb-20 pt-8" >
70- < div className = "container" >
71- < div className = "mb-6 flex flex-wrap items-center gap-1.5 sm:mb-8" >
72- < DashboardTab
73- label = "Personal"
74- isActive = { ! selectedTeamId && ! isTeamPage }
75- href = "/dashboard"
76- avatar = { userAvatar }
77- />
78-
79- { isLoading && (
80- < >
81- < DashboardTabSkeleton />
82- < DashboardTabSkeleton />
83- </ >
84- ) }
85-
86- { ! isLoading && (
87- < >
88- { teamList . map ( ( team ) => {
89- const { avatar } = team ;
90- const avatarUrl = avatar
91- ? `${ import . meta. env . PUBLIC_AVATAR_BASE_URL } /${ avatar } `
92- : '/images/default-avatar.png' ;
93- return (
94- < DashboardTab
95- key = { team . _id }
96- label = { team . name }
97- isActive = { team . _id === selectedTeamId }
98- { ...( team . status === 'invited'
99- ? {
100- href : `/respond-invite?i=${ team . memberId } ` ,
101- }
102- : {
103- href : `/team?t=${ team . _id } ` ,
104- } ) }
105- avatar = { avatarUrl }
106- />
107- ) ;
108- } ) }
109- < DashboardTab
110- label = "+ Create Team"
111- isActive = { false }
112- href = "/team/new"
113- className = "border border-dashed border-gray-300 bg-transparent px-3 text-[13px] text-sm text-gray-500 hover:border-gray-600 hover:text-black"
114- />
115- </ >
116- ) }
79+ < >
80+ < div
81+ className = { cn ( 'bg-slate-900' , {
82+ 'striped-loader-slate' : isLoading ,
83+ } ) }
84+ >
85+ < div className = "bg-slate-800/30 py-5" >
86+ < div className = "container flex flex-wrap items-center gap-1.5" >
87+ < DashboardTabButton
88+ label = "Personal"
89+ isActive = { ! selectedTeamId && ! isTeamPage }
90+ href = "/dashboard"
91+ avatar = { userAvatar }
92+ />
93+
94+ { ! isLoading && (
95+ < >
96+ { teamList . map ( ( team ) => {
97+ const { avatar } = team ;
98+ const avatarUrl = avatar
99+ ? `${ import . meta. env . PUBLIC_AVATAR_BASE_URL } /${ avatar } `
100+ : '/images/default-avatar.png' ;
101+ return (
102+ < DashboardTabButton
103+ key = { team . _id }
104+ label = { team . name }
105+ isActive = { team . _id === selectedTeamId }
106+ { ...( team . status === 'invited'
107+ ? {
108+ href : `/respond-invite?i=${ team . memberId } ` ,
109+ }
110+ : {
111+ href : `/team?t=${ team . _id } ` ,
112+ } ) }
113+ avatar = { avatarUrl }
114+ />
115+ ) ;
116+ } ) }
117+ < DashboardTabButton
118+ label = "+ Create Team"
119+ isActive = { false }
120+ href = "/team/new"
121+ className = "border border-dashed border-slate-700 bg-transparent px-3 text-[13px] text-sm text-gray-500 hover:border-solid hover:border-slate-700 hover:text-gray-400"
122+ />
123+ </ >
124+ ) }
125+ </ div >
117126 </ div >
127+ </ div >
118128
129+ < div className = "" >
119130 { ! selectedTeamId && ! isTeamPage && (
120- < PersonalDashboard
121- builtInRoleRoadmaps = { builtInRoleRoadmaps }
122- builtInSkillRoadmaps = { builtInSkillRoadmaps }
123- builtInBestPractices = { builtInBestPractices }
124- />
131+ < div className = "bg-slate-900" >
132+ < PersonalDashboard
133+ builtInRoleRoadmaps = { builtInRoleRoadmaps }
134+ builtInSkillRoadmaps = { builtInSkillRoadmaps }
135+ builtInBestPractices = { builtInBestPractices }
136+ questionGroups = { questionGroups }
137+ guides = { guides }
138+ videos = { videos }
139+ />
140+ </ div >
125141 ) }
126142
127143 { ( selectedTeamId || isTeamPage ) && (
128- < TeamDashboard
129- builtInRoleRoadmaps = { builtInRoleRoadmaps ! }
130- builtInSkillRoadmaps = { builtInSkillRoadmaps ! }
131- teamId = { selectedTeamId ! }
132- />
144+ < div className = "container" >
145+ < TeamDashboard
146+ builtInRoleRoadmaps = { builtInRoleRoadmaps ! }
147+ builtInSkillRoadmaps = { builtInSkillRoadmaps ! }
148+ teamId = { selectedTeamId ! }
149+ />
150+ </ div >
133151 ) }
134152 </ div >
135- </ div >
136- ) ;
137- }
138-
139- function DashboardTabSkeleton ( ) {
140- return (
141- < div className = "h-[30px] w-[114px] animate-pulse rounded-md border bg-white" > </ div >
153+ </ >
142154 ) ;
143155}
0 commit comments