-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added link to universe tab from fleet movements
- Loading branch information
Showing
6 changed files
with
90 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { createContext, useContext, useState, ReactNode } from 'react'; | ||
|
||
// Create a context | ||
type DestinationContextType = { | ||
selectedDestination: number | null; | ||
handleDestinationClick: (destinationId: number) => void; | ||
}; | ||
|
||
// Create a context with a default value | ||
const DestinationContext = createContext<DestinationContextType>({ | ||
selectedDestination: null, | ||
handleDestinationClick: () => {}, | ||
}); | ||
|
||
// Create a provider component | ||
export const DestinationProvider = ({ children }: { children: ReactNode }) => { | ||
const [selectedDestination, setSelectedDestination] = useState<number | null>( | ||
null | ||
); | ||
|
||
const handleDestinationClick = (destinationId: number) => { | ||
setSelectedDestination(destinationId); | ||
}; | ||
|
||
return ( | ||
<DestinationContext.Provider | ||
value={{ selectedDestination, handleDestinationClick }} | ||
> | ||
{children} | ||
</DestinationContext.Provider> | ||
); | ||
}; | ||
|
||
// Hook for easy access to the context | ||
export const useDestination = () => useContext(DestinationContext); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters