1- "use client"
1+ "use client" ;
22
33import {
44 Box ,
@@ -7,26 +7,33 @@ import {
77 ListItemButton ,
88 Skeleton as MuiSkeleton ,
99 Stack ,
10- Typography
11- } from "@mui/material"
12- import MenuItemHover from "@/common/ui/MenuItemHover"
13- import { Project } from "@/features/projects/domain"
14- import { useProjectSelection } from "@/features/projects/data"
15- import ProjectAvatar , { Squircle as ProjectAvatarSquircle } from "./ProjectAvatar"
16- import { useCloseSidebarOnSelection } from "@/features/sidebar/data"
10+ Typography ,
11+ } from "@mui/material" ;
12+ import MenuItemHover from "@/common/ui/MenuItemHover" ;
13+ import { Project } from "@/features/projects/domain" ;
14+ import { useProjectSelection } from "@/features/projects/data" ;
15+ import { useContext } from "react" ;
16+ import { ProjectsContext } from "@/common" ;
17+ import ProjectAvatar , {
18+ Squircle as ProjectAvatarSquircle ,
19+ } from "./ProjectAvatar" ;
20+ import { useCloseSidebarOnSelection } from "@/features/sidebar/data" ;
1721
18- const AVATAR_SIZE = { width : 40 , height : 40 }
22+ const AVATAR_SIZE = { width : 40 , height : 40 } ;
1923
2024const ProjectListItem = ( { project } : { project : Project } ) => {
21- const { project : selectedProject , selectProject } = useProjectSelection ( )
22- const selected = project . id === selectedProject ?. id
23- const { closeSidebarIfNeeded } = useCloseSidebarOnSelection ( )
25+ const { project : selectedProject , selectProject } = useProjectSelection ( ) ;
26+ const { refreshProjects } = useContext ( ProjectsContext ) ;
27+ const selected = project . id === selectedProject ?. id ;
28+ const { closeSidebarIfNeeded } = useCloseSidebarOnSelection ( ) ;
29+
2430 return (
2531 < Template
2632 selected = { selected }
2733 onSelect = { ( ) => {
28- closeSidebarIfNeeded ( )
29- selectProject ( project )
34+ closeSidebarIfNeeded ( ) ;
35+ selectProject ( project ) ;
36+ refreshProjects ( ) ;
3037 } }
3138 avatar = {
3239 < ProjectAvatar
@@ -37,55 +44,55 @@ const ProjectListItem = ({ project }: { project: Project }) => {
3744 }
3845 title = { project . displayName }
3946 />
40- )
41- }
47+ ) ;
48+ } ;
4249
43- export default ProjectListItem
50+ export default ProjectListItem ;
4451
4552export const Skeleton = ( ) => {
4653 return (
47- < Template disabled avatar = {
48- < ProjectAvatarSquircle width = { AVATAR_SIZE . width } height = { AVATAR_SIZE . height } >
49- < MuiSkeleton
50- variant = "rectangular"
51- animation = "wave"
52- sx = { { width : "100%" , height : "100%" } }
53- />
54- </ ProjectAvatarSquircle >
55- } >
54+ < Template
55+ disabled
56+ avatar = {
57+ < ProjectAvatarSquircle
58+ width = { AVATAR_SIZE . width }
59+ height = { AVATAR_SIZE . height }
60+ >
61+ < MuiSkeleton
62+ variant = "rectangular"
63+ animation = "wave"
64+ sx = { { width : "100%" , height : "100%" } }
65+ />
66+ </ ProjectAvatarSquircle >
67+ }
68+ >
5669 < MuiSkeleton variant = "text" animation = "wave" width = { 100 } />
5770 </ Template >
58- )
59- }
71+ ) ;
72+ } ;
6073
6174export const Template = ( {
6275 disabled,
6376 selected,
6477 onSelect,
6578 avatar,
6679 title,
67- children
80+ children,
6881} : {
69- disabled ?: boolean
70- selected ?: boolean
71- onSelect ?: ( ) => void
72- avatar : React . ReactNode
73- title ?: string
74- children ?: React . ReactNode
82+ disabled ?: boolean ;
83+ selected ?: boolean ;
84+ onSelect ?: ( ) => void ;
85+ avatar : React . ReactNode ;
86+ title ?: string ;
87+ children ?: React . ReactNode ;
7588} ) => {
7689 return (
7790 < ListItem disablePadding >
78- < Button
79- disabled = { disabled }
80- selected = { selected }
81- onSelect = { onSelect }
82- >
91+ < Button disabled = { disabled } selected = { selected } onSelect = { onSelect } >
8392 < MenuItemHover disabled = { disabled } >
8493 < Stack direction = "row" alignItems = "center" spacing = { 1.5 } >
85- < Box sx = { { width : 40 , height : 40 } } >
86- { avatar }
87- </ Box >
88- { title &&
94+ < Box sx = { { width : 40 , height : 40 } } > { avatar } </ Box >
95+ { title && (
8996 < ListItemText
9097 primary = {
9198 < Typography
@@ -95,37 +102,37 @@ export const Template = ({
95102 letterSpacing : 0.1 ,
96103 whiteSpace : "nowrap" ,
97104 overflow : "hidden" ,
98- textOverflow : "ellipsis"
105+ textOverflow : "ellipsis" ,
99106 } }
100107 >
101108 { title }
102109 </ Typography >
103110 }
104111 />
105- }
112+ ) }
106113 { children }
107114 </ Stack >
108115 </ MenuItemHover >
109116 </ Button >
110117 </ ListItem >
111- )
112- }
118+ ) ;
119+ } ;
113120
114121const Button = ( {
115122 disabled,
116123 selected,
117124 onSelect,
118- children
125+ children,
119126} : {
120- disabled ?: boolean
121- selected ?: boolean
122- onSelect ?: ( ) => void
123- children ?: React . ReactNode
127+ disabled ?: boolean ;
128+ selected ?: boolean ;
129+ onSelect ?: ( ) => void ;
130+ children ?: React . ReactNode ;
124131} ) => {
125132 return (
126133 < >
127134 { disabled && children }
128- { ! disabled &&
135+ { ! disabled && (
129136 < ListItemButton
130137 disabled = { disabled }
131138 onClick = { onSelect }
@@ -135,7 +142,7 @@ const Button = ({
135142 >
136143 { children }
137144 </ ListItemButton >
138- }
145+ ) }
139146 </ >
140- )
141- }
147+ ) ;
148+ } ;
0 commit comments