Commit 140cc372b5d8a8f11257ee4ba7bbd09e9b8c3964

Authored by Vu Bui
1 parent aa0b9131f9
Exists in master

update

Showing 1 changed file with 50 additions and 40 deletions Side-by-side Diff

... ... @@ -18,12 +18,11 @@ function BookingWizard(props) {
18 18 const [step, setStep] = useState('step-login')
19 19 const commonStore = useCommonState()
20 20 const dispatch = useCommonDispatch()
21   -
  21 +
22 22 const [cookies, setCookie, removeCookie] = useCookies('patient-dashboard')
23   - let { accessToken } = cookies
  23 + let { accessToken } = cookies
24 24  
25 25 useEffect(() => {
26   - console.log("check access token", accessToken)
27 26 if (accessToken) {
28 27 if (!localStorage.getItem('activeStep') || localStorage.getItem('activeStep') === null) {
29 28 dispatch({ type: 'BW_ACTIVE_STEP', payload: 'step-confirm-service' })
... ... @@ -31,17 +30,30 @@ function BookingWizard(props) {
31 30 dispatch({ type: 'BW_ACTIVE_STEP', payload: localStorage.getItem('activeStep') })
32 31 }
33 32 }
  33 + if (localStorage.getItem('userProfile')) {
  34 + let profile = JSON.parse(localStorage.getItem('userProfile'))
  35 + dispatch({ type: 'USER_PROFILE', payload: profile })
  36 + console.log("check access token", profile)
  37 + }
  38 + // set data Case obj
  39 + if(localStorage.getItem('caseObj')) {
  40 + dispatch({ type: 'BW_CASE', payload: JSON.parse(localStorage.getItem('caseObj')) })
  41 + }
  42 +
34 43 }, [])
  44 + useEffect(() => {
  45 +
  46 + }, [commonStore.showBookingModal])
35 47  
36 48 useEffect(() => {
37   - if(accessToken ===null ) {
  49 + if (accessToken === null) {
38 50 localStorage.removeItem('bwSteps') // remove steps
39 51 localStorage.removeItem('bwDataBooking') // remove data booking
40   - localStorage.setItem('activeStep','step-login') // remove active step
  52 + localStorage.setItem('activeStep', 'step-login') // remove active step
41 53 }
42   - },[accessToken])
43   -
44   -
  54 + }, [accessToken])
  55 +
  56 +
45 57  
46 58 useEffect(() => {
47 59 if (commonStore.activeStep !== null) {
... ... @@ -50,14 +62,16 @@ function BookingWizard(props) {
50 62 }, [commonStore.activeStep])
51 63  
52 64 useEffect(() => {
  65 +
53 66 setShow(commonStore?.showBookingModal)
54 67 }, [commonStore.showBookingModal])
55 68  
56 69 const handleCloseModal = () => {
57 70 dispatch({ type: 'BW_SHOW_BOOKING_MODAL', payload: false })
  71 + dispatch({ type: 'BW_CLICK_BOOKING_BTN', payload: false })
58 72 }
59 73  
60   -
  74 +
61 75 const renderStep = (step) => {
62 76 switch (step) {
63 77 case 'step-login':
... ... @@ -71,8 +85,8 @@ function BookingWizard(props) {
71 85 <div className="bw-booking-modal-header">
72 86 <div className="bw-row">
73 87 <div className="bw-col-left">
74   - {process.env.REACT_APP_NAME ==='rce' && <i className="bw-icon-health-care"></i>}
75   - {process.env.REACT_APP_NAME ==='mm' && <i className="bw-icon-leaf"></i>}
  88 + {process.env.REACT_APP_NAME === 'rce' && <i className="bw-icon-health-care"></i>}
  89 + {process.env.REACT_APP_NAME === 'mm' && <i className="bw-icon-leaf"></i>}
76 90 <span>Confirm your services</span>
77 91 </div>
78 92 <div className="bw-col-right">
... ... @@ -129,7 +143,7 @@ function BookingWizard(props) {
129 143 </div>
130 144 <div className="bw-booking-modal-content">
131 145 <div className="bw-booking-modal-inner">
132   - <PickDoctor/>
  146 + <PickDoctor />
133 147 </div>
134 148 </div>
135 149 </>
... ... @@ -151,7 +165,7 @@ function BookingWizard(props) {
151 165 </div>
152 166 <div className="bw-booking-modal-content">
153 167 <div className="bw-booking-modal-inner">
154   - <Payment/>
  168 + <Payment />
155 169 </div>
156 170 </div>
157 171 </>
... ... @@ -170,8 +184,8 @@ function BookingWizard(props) {
170 184  
171 185 return (<>
172 186 {process.env.NODE_ENV === 'development' ?
173   - <Portal id="bwBookingWizardID">
174   - <>
  187 + // <Portal id="bwBookingWizardID">
  188 + <>
175 189 {show && <div className="bw-backdrop" onClick={() => handleCloseModal()}></div>}
176 190 {show && <div className="bw-booking-popup-wraper">
177 191 <div className="bw-booking-modal">
... ... @@ -187,32 +201,28 @@ function BookingWizard(props) {
187 201 />
188 202 </div>
189 203 </div>}
190   -
191   - </>
192   - </Portal> :
193   - <Portal id="bwBookingWizardID">
194   - <root.div>
195   - <style type="text/css">
196   - {`@import "${process.env.REACT_APP_FIREBASE_URL}/static/css/main-app.chunk.css";`}
197   - </style>
198   - {show && <div className="bw-backdrop" onClick={() => handleCloseModal()}></div>}
199   - {show && <div className="bw-booking-popup-wraper">
200   - <div className="bw-booking-modal">
201   - <button className="bw-btn-close" onClick={() => handleCloseModal()}><i className="bw-icon-close"></i></button>
202   - <div className="bw-booking-modal-body">
203   - {renderStep(step)}
204   - </div>
205   - </div>
206   - <div className={`bw-booking-step-wrapper ${step === 'step-login' ? 'require-login' : ''}`}>
207   - <BookingWizardStep
208   - activeStep={step}
209   - />
  204 +
  205 + </>
  206 + // </Portal>
  207 + :<root.div>
  208 + <style type="text/css">
  209 + {`@import "${process.env.REACT_APP_FIREBASE_URL}/static/css/main-app.chunk.css";`}
  210 + </style>
  211 + {show && <div className="bw-backdrop" onClick={() => handleCloseModal()}></div>}
  212 + {show && <div className="bw-booking-popup-wraper">
  213 + <div className="bw-booking-modal">
  214 + <button className="bw-btn-close" onClick={() => handleCloseModal()}><i className="bw-icon-close"></i></button>
  215 + <div className="bw-booking-modal-body">
  216 + {renderStep(step)}
210 217 </div>
211   - </div>}
212   -
213   - </root.div>
214   -
215   - </Portal>
  218 + </div>
  219 + <div className={`bw-booking-step-wrapper ${step === 'step-login' ? 'require-login' : ''}`}>
  220 + <BookingWizardStep
  221 + activeStep={step}
  222 + />
  223 + </div>
  224 + </div>}
  225 + </root.div>
216 226 }
217 227 </>
218 228 )