mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Migrate Writefull AI consent to shared tutorial system GitOrigin-RevId: c9298a177c9f1aa1a941c96599d6d854591f8a76
33 lines
875 B
TypeScript
33 lines
875 B
TypeScript
import React, {
|
|
type FC,
|
|
type PropsWithChildren,
|
|
useCallback,
|
|
useState,
|
|
} from 'react'
|
|
import { TutorialContext } from '@/shared/context/tutorial-context'
|
|
|
|
export const makeTutorialProvider = (opts?: {
|
|
inactiveTutorials: string[]
|
|
}) => {
|
|
const TutorialProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
const [inactiveTutorials, setInactiveTutorials] = useState<string[]>(
|
|
opts?.inactiveTutorials ?? []
|
|
)
|
|
const deactivateTutorial = useCallback((key: string) => {
|
|
setInactiveTutorials(prev => (prev.includes(key) ? prev : [...prev, key]))
|
|
}, [])
|
|
const value = {
|
|
deactivateTutorial,
|
|
inactiveTutorials,
|
|
currentPopup: null,
|
|
setCurrentPopup: () => {},
|
|
}
|
|
return (
|
|
<TutorialContext.Provider value={value}>
|
|
{children}
|
|
</TutorialContext.Provider>
|
|
)
|
|
}
|
|
return TutorialProvider
|
|
}
|