@@ -45,7 +45,17 @@ export const TourProvider: React.FC = ({ children }) => {
45
45
const organizationId = organization ?. id || null
46
46
const organizationType = organization ?. type || null
47
47
48
- const [ getTourSteps , { refetch : refetchSteps } ] = useGetTourStepsLazyQuery ( )
48
+ const [ getTourSteps , {
49
+ refetch : refetchSteps ,
50
+ } ] = useGetTourStepsLazyQuery ( {
51
+ variables : {
52
+ where : {
53
+ organization : {
54
+ id : organizationId ,
55
+ } ,
56
+ } ,
57
+ } ,
58
+ } )
49
59
50
60
const [ updateTourStep ] = useUpdateTourStepMutation ( )
51
61
@@ -57,11 +67,11 @@ export const TourProvider: React.FC = ({ children }) => {
57
67
sender : getClientSideSenderInfo ( ) ,
58
68
} ,
59
69
} ,
60
- onCompleted : async ( ) => await getTourSteps ( {
61
- variables : {
62
- where : { organization : { id : organizationId } } ,
63
- } ,
64
- } ) ,
70
+ onCompleted : async ( ) => {
71
+ if ( organizationId ) {
72
+ await refetchSteps ( )
73
+ }
74
+ } ,
65
75
} )
66
76
67
77
useEffect ( ( ) => {
@@ -100,15 +110,17 @@ export const TourProvider: React.FC = ({ children }) => {
100
110
const updateStepIfNotCompleted = useCallback ( async ( type : TourStepTypeType , nextRoute ?: string ) => {
101
111
if ( organizationType !== MANAGING_COMPANY_TYPE ) return
102
112
103
- const { data : fetchResult } = await getTourSteps ( {
113
+ const {
114
+ data : tourStepData ,
115
+ } = await getTourSteps ( {
104
116
variables : {
105
117
where : {
106
118
organization : { id : organizationId } ,
107
119
type,
108
120
} ,
109
121
} ,
110
122
} )
111
- const tourStep = fetchResult ?. tourSteps . filter ( Boolean ) [ 0 ] || null
123
+ const tourStep = tourStepData ?. tourSteps . filter ( Boolean ) [ 0 ] || null
112
124
113
125
if ( ! tourStep ) return
114
126
@@ -151,7 +163,7 @@ export const TourProvider: React.FC = ({ children }) => {
151
163
}
152
164
153
165
case 'updateProperty' : {
154
- if ( data ?. obj ?. map ) return
166
+ if ( ! data ?. obj ?. map ) return
155
167
156
168
await updateStepIfNotCompleted ( TourStepTypeType . CreatePropertyMap )
157
169
break
0 commit comments