Initial commit
This commit is contained in:
commit
7878e653a0
253 changed files with 24552 additions and 0 deletions
49
src/bootstrap/hooks/useInitializeTourPrompt.ts
Normal file
49
src/bootstrap/hooks/useInitializeTourPrompt.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { useContext, useEffect } from 'react';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import NotificationsActions from '../../providers/notifications/notifications.actions';
|
||||
import { NotificationsDispatchContext } from '../../providers/notifications/notifications.provider';
|
||||
import TourActions from '../../providers/tour/tour.actions';
|
||||
import { TourDispatchContext } from '../../providers/tour/tour.provider';
|
||||
import { internalPropertiesSet } from '../../redux/actions/internal-properties';
|
||||
import State from '../../redux/state';
|
||||
|
||||
function useInitializeTourPrompt() {
|
||||
const dispatch = useDispatch();
|
||||
const notificationsDispatch = useContext(NotificationsDispatchContext);
|
||||
const tourDispatch = useContext(TourDispatchContext);
|
||||
const hasShownTourPrompt = useSelector<State, boolean>(
|
||||
(state) => state.internalProperties.HasShownTourPrompt.value,
|
||||
);
|
||||
|
||||
useEffect(
|
||||
() => {
|
||||
if (!hasShownTourPrompt) {
|
||||
notificationsDispatch({
|
||||
type: NotificationsActions.Push,
|
||||
payload: {
|
||||
title: 'Welcome!',
|
||||
body: 'WebSocket King is a client for developing, testing and debugging WebSocket connections. Would you like to learn the basics?',
|
||||
actions: [
|
||||
{
|
||||
label: 'No thanks',
|
||||
},
|
||||
{
|
||||
label: 'Take tour',
|
||||
theme: 'primary',
|
||||
onClick: () => tourDispatch!({
|
||||
type: TourActions.Open,
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
dispatch(
|
||||
internalPropertiesSet('HasShownTourPrompt', true),
|
||||
);
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
}
|
||||
|
||||
export default useInitializeTourPrompt;
|
Loading…
Add table
Add a link
Reference in a new issue