1- import React , { useState , useMemo , useCallback } from 'react' ;
1+ import React , { useState , useMemo } from 'react' ;
22import localforage from 'localforage' ;
33import { Router } from 'react-router-dom' ;
4- import { init , ErrorBoundary , setUser as setUserOnSentry , withProfiler } from '@sentry/react' ;
4+ import { init , ErrorBoundary , withProfiler } from '@sentry/react' ;
55import { unique , _cs } from '@togglecorp/fujs' ;
66import {
77 AlertContainer ,
@@ -20,17 +20,10 @@ import 'mapbox-gl/dist/mapbox-gl.css';
2020import Init from '#base/components/Init' ;
2121import browserHistory from '#base/configs/history' ;
2222import sentryConfig from '#base/configs/sentry' ;
23- import { UserContext , UserContextInterface } from '#base/context/UserContext' ;
24- import {
25- openZendeskFeedback ,
26- setUserOnZendesk ,
27- } from '#base/utils/zendesk' ;
2823import { NavbarContext , NavbarContextInterface } from '#base/context/NavbarContext' ;
2924import AuthPopup from '#base/components/AuthPopup' ;
30- import { sync } from '#base/hooks/useAuthSync' ;
3125import Navbar from '#base/components/Navbar' ;
3226import Routes from '#base/components/Routes' ;
33- import { User } from '#base/types/user' ;
3427import {
3528 processDeepUrls ,
3629 processDeepOptions ,
@@ -72,52 +65,13 @@ if (trackingId) {
7265}
7366
7467function Base ( ) {
75- const [ user , setUser ] = useState < User | undefined > ( ) ;
68+ const [ mondayFormVisible , setMondayFormVisible ] = useState ( false ) ;
7669
7770 const [ navbarState , setNavbarState ] = useState < {
7871 path : string ;
7972 visibility : boolean ;
8073 } [ ] > ( [ ] ) ;
8174
82- const authenticated = ! ! user ;
83-
84- const setUserWithSentryAndZendesk : typeof setUser = useCallback (
85- ( u ) => {
86- if ( typeof u === 'function' ) {
87- setUser ( ( oldUser ) => {
88- const newUser = u ( oldUser ) ;
89-
90- const sanitizedUser = newUser ;
91- sync ( ! ! sanitizedUser , sanitizedUser ?. id ) ;
92- setUserOnSentry ( sanitizedUser ?? null ) ;
93- setUserOnZendesk ( sanitizedUser ?? null ) ;
94-
95- return newUser ;
96- } ) ;
97- } else {
98- const sanitizedUser = u ;
99- sync ( ! ! sanitizedUser , sanitizedUser ?. id ) ;
100- setUserOnSentry ( sanitizedUser ?? null ) ;
101- setUserOnZendesk ( sanitizedUser ?? null ) ;
102- setUser ( u ) ;
103- }
104- } ,
105- [ setUser ] ,
106- ) ;
107-
108- const userContext : UserContextInterface = useMemo (
109- ( ) => ( {
110- authenticated,
111- user,
112- setUser : setUserWithSentryAndZendesk ,
113- } ) ,
114- [
115- authenticated ,
116- user ,
117- setUserWithSentryAndZendesk ,
118- ] ,
119- ) ;
120-
12175 const navbarContext : NavbarContextInterface = useMemo (
12276 ( ) => ( {
12377 navbarState,
@@ -219,6 +173,10 @@ function Base() {
219173
220174 const navbarShown = currentNavbarState ?. visibility ;
221175
176+ const openMondayFeedback = ( ) => {
177+ setMondayFormVisible ( ( prev ) => ! prev ) ;
178+ } ;
179+
222180 return (
223181 < div className = { styles . base } >
224182 < ErrorBoundary
@@ -233,42 +191,54 @@ function Base() {
233191 >
234192 < RequestContext . Provider value = { requestContextValue } >
235193 < ApolloProvider client = { apolloClient } >
236- < UserContext . Provider value = { userContext } >
237- < NavbarContext . Provider value = { navbarContext } >
238- < AlertContext . Provider value = { alertContext } >
239- < AuthPopup />
240- < AlertContainer className = { styles . alertContainer } />
241- < Router history = { browserHistory } >
242- < Init
243- className = { styles . init }
244- >
245- < Navbar
246- className = { _cs (
247- styles . navbar ,
248- ! navbarShown && styles . hidden ,
249- ) }
250- disabled = { ! navbarShown }
251- />
252- < Routes
253- className = { styles . view }
254- />
255- </ Init >
256- </ Router >
257- </ AlertContext . Provider >
258- </ NavbarContext . Provider >
259- </ UserContext . Provider >
194+ < NavbarContext . Provider value = { navbarContext } >
195+ < AlertContext . Provider value = { alertContext } >
196+ < AuthPopup />
197+ < AlertContainer className = { styles . alertContainer } />
198+ < Router history = { browserHistory } >
199+ < Init
200+ className = { styles . init }
201+ >
202+ < Navbar
203+ className = { _cs (
204+ styles . navbar ,
205+ ! navbarShown && styles . hidden ,
206+ ) }
207+ disabled = { ! navbarShown }
208+ />
209+ < Routes
210+ className = { styles . view }
211+ />
212+ </ Init >
213+ </ Router >
214+ </ AlertContext . Provider >
215+ </ NavbarContext . Provider >
260216 </ ApolloProvider >
261217 </ RequestContext . Provider >
262218 </ ErrorBoundary >
263219 < Button
264220 name = { undefined }
265- title = " Bug/Feedback?"
221+ title = { mondayFormVisible ? 'Close Bug/Feedback?' : 'Bug/Feedback?' }
266222 variant = "action"
267- className = { styles . zendeskHelpButton }
268- onClick = { openZendeskFeedback }
223+ className = { styles . mondayHelpButton }
224+ onClick = { openMondayFeedback }
225+ type = "button"
269226 >
270- Bug / Feedback?
227+ { mondayFormVisible ? 'Close Bug / Feedback?' : 'Bug / Feedback?' }
271228 </ Button >
229+
230+ { mondayFormVisible && (
231+ < div className = { styles . formOverlay } >
232+ < div className = { styles . formContent } >
233+ < iframe
234+ src = "https://forms.monday.com/forms/embed/6438474a471702280d54bd27e87f5855?r=apse2"
235+ width = "100%"
236+ height = "100%"
237+ title = "Bug / Feedback Form"
238+ />
239+ </ div >
240+ </ div >
241+ ) }
272242 </ div >
273243 ) ;
274244}
0 commit comments