-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tracking): add context menu button to detail page
and several tweaks
- Loading branch information
Showing
12 changed files
with
276 additions
and
96 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,48 @@ | ||
'use client'; | ||
|
||
import { | ||
createContext, | ||
useContext, | ||
useState, | ||
type PropsWithChildren, | ||
} from 'react'; | ||
|
||
type State = Readonly<{ | ||
isFavorited: boolean; | ||
isWatchlisted: boolean; | ||
}>; | ||
|
||
const ActionButtonsContext = createContext< | ||
[State, (action: State | ((prevState: State) => State)) => void] | null | ||
>(null); | ||
|
||
export const ActionButtonsProvider = ({ | ||
children, | ||
isFavorited, | ||
isWatchlisted, | ||
}: PropsWithChildren & State) => { | ||
const state = useState<State>({ | ||
isFavorited, | ||
isWatchlisted, | ||
}); | ||
|
||
return ( | ||
<ActionButtonsContext.Provider value={state}> | ||
{children} | ||
</ActionButtonsContext.Provider> | ||
); | ||
}; | ||
|
||
export const useActionButtons = () => { | ||
const context = useContext(ActionButtonsContext); | ||
|
||
if (!context) { | ||
throw new Error( | ||
`useActionButtons must be used within <ActionButtonsProvider />`, | ||
); | ||
} | ||
|
||
return context; | ||
}; | ||
|
||
export default ActionButtonsProvider; |
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
Oops, something went wrong.