1
1
import type { FC , PropsWithChildren } from "hono/jsx" ;
2
- import { User } from "lucia" ;
2
+ import type { User } from "lucia" ;
3
3
4
4
export interface AppContainerProps {
5
5
user : User ;
6
6
workspace : string ;
7
7
mainClass ?: string ;
8
8
}
9
9
10
- export const AppContainer : FC < PropsWithChildren < AppContainerProps > > = ( props ) => {
11
- const { user, children, mainClass } = props ;
12
-
10
+ export const AppContainer : FC < PropsWithChildren < AppContainerProps > > = ( { user, children, mainClass, workspace } ) => {
13
11
return (
14
12
< div class = "flex flex-col md:grid md:grid-cols-4 lg:grid-cols-5 min-h-full" >
15
13
< aside class = "h-[250px] border-b flex flex-col bg-gray-100 dark:bg-gray-800 md:h-auto md:col-span-1 md:border-r md:border-b-0" >
16
14
< div class = "flex-grow p-2" >
17
15
< p class = "pb-2" > Hello { user . username } !</ p >
18
16
< p class = "pb-2 border-b" > Your organizations</ p >
19
- < SidebarFetcher { ... props } />
17
+ < SidebarFetcher workspace = { workspace } />
20
18
< span class = "border-t" />
21
19
</ div >
22
20
< div class = "p-2" >
@@ -28,11 +26,10 @@ export const AppContainer: FC<PropsWithChildren<AppContainerProps>> = (props) =>
28
26
) ;
29
27
} ;
30
28
31
- const SidebarFetcher : FC < Pick < AppContainerProps , "user" | "workspace" > > = ( { user, workspace } ) => {
32
- return (
33
- < div
34
- hx-trigger = "load"
35
- hx-get = { [ "/app/hx/sidebar-organizations" , workspace . length > 0 ? `?current_workspace=${ workspace } ` : "" ] . join ( "" ) }
36
- > </ div >
37
- ) ;
29
+ const SidebarFetcher : FC < { workspace : string } > = ( { workspace } ) => {
30
+ const params = new URLSearchParams ( ) ;
31
+ params . append ( "style_current_workspace" , workspace ) ;
32
+
33
+ const getUrl = `/app/hx/sidebar-organizations?${ params . toString ( ) } ` ;
34
+ return < div hx-get = { getUrl } hx-trigger = "load" hx-swap = "innerHTML transition:true" /> ;
38
35
} ;
0 commit comments