Created
December 7, 2021 08:12
-
-
Save hieptl/b5e922aa31673ddf3f7d0ebcb69364a6 to your computer and use it in GitHub Desktop.
home.js - Zocdoc Clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useContext } from 'react'; | |
| import Doctors from './Doctors'; | |
| import Appointments from './Appointments'; | |
| import Context from '../context'; | |
| const Home = (props) => { | |
| const { navigation } = props; | |
| const { user } = useContext(Context); | |
| const renderBody = () => { | |
| if (user.role === 'Patient') { | |
| return <Doctors navigation={navigation} />; | |
| } else if (user.role === 'Doctor') { | |
| return <Appointments navigation={navigation} />; | |
| } | |
| return <></>; | |
| } | |
| if (!user) { | |
| return <></>; | |
| } | |
| return ( | |
| <> | |
| {renderBody()} | |
| </> | |
| ); | |
| }; | |
| export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment