File size: 852 Bytes
5f40163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from "react";

export interface NavigationOptions {
  replace?: boolean;
}

export interface NavigationContextValue {
  currentPath: string;
  conversationId: string | null;
  isNavigating: boolean;
  navigate: (to: string, options?: NavigationOptions) => void;
}

const noop = () => {};

const NavigationContext = React.createContext<NavigationContextValue>({
  currentPath: "/",
  conversationId: null,
  isNavigating: false,
  navigate: noop,
});

interface NavigationProviderProps {
  value: NavigationContextValue;
  children: React.ReactNode;
}

export function NavigationProvider({
  value,
  children,
}: NavigationProviderProps) {
  return (
    <NavigationContext.Provider value={value}>
      {children}
    </NavigationContext.Provider>
  );
}

export function useNavigation() {
  return React.useContext(NavigationContext);
}