{
- setPlaygroundInfo( info );
- } }
- />
- );
+ const previewFront = ;
const previewAdmin = (
-
+
);
const showTabBar = ! isPlaygroundLoading;
diff --git a/src/ui/session/SessionProvider.ts b/src/ui/session/SessionProvider.ts
new file mode 100644
index 00000000..5043c75a
--- /dev/null
+++ b/src/ui/session/SessionProvider.ts
@@ -0,0 +1,22 @@
+import { createContext, useContext } from 'react';
+import { Session } from '@/storage/session';
+import { ApiClient } from '@/api/ApiClient';
+
+export interface SessionContext {
+ session: Session;
+ apiClient?: ApiClient;
+}
+
+const sessionContext = createContext< SessionContext >( {
+ session: {
+ id: '',
+ url: '',
+ title: '',
+ },
+} );
+
+export const SessionProvider = sessionContext.Provider;
+
+export function useSessionContext() {
+ return useContext( sessionContext );
+}
diff --git a/src/ui/session/ViewSession.tsx b/src/ui/session/ViewSession.tsx
index a9718fff..4f6a1597 100644
--- a/src/ui/session/ViewSession.tsx
+++ b/src/ui/session/ViewSession.tsx
@@ -1,11 +1,32 @@
-import { useOutletContext } from 'react-router-dom';
-import { Session } from '@/storage/session';
+import { useSessionContext } from '@/ui/session/SessionProvider';
+import { Post } from '@/api/ApiClient';
+import { useEffect, useState } from 'react';
export function ViewSession() {
- const session = useOutletContext() as Session;
+ const { session, apiClient } = useSessionContext();
+
+ const [ posts, setPosts ] = useState< Post[] >( [] );
+ useEffect( () => {
+ if ( ! apiClient ) {
+ return;
+ }
+ const getPosts = async () => {
+ setPosts( await apiClient.getPosts() );
+ };
+ void getPosts();
+ }, [ apiClient?.siteUrl ] );
+
return (
<>
- { `view session: ${ session.id }` }
+ view session: { session.id }
+ { apiClient?.siteUrl ? (
+ url: { apiClient.siteUrl }
+ ) : null }
+
+ { posts.map( ( post ) => {
+ return - { post.title }
;
+ } ) }
+
>
);
}