Skip to content

Commit

Permalink
add logic to dont render siderbar when user is logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
arthursvpb committed Sep 3, 2022
1 parent 71d4537 commit cadd27e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 31 deletions.
16 changes: 12 additions & 4 deletions web/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import { Route, Routes } from 'react-router-dom';
import { useState } from 'react';

import { Navigate, Route, Routes } from 'react-router-dom';
import { Page } from './components/Page';

import { Dashboard } from './pages/dahsboard';
import { Login } from './pages/login';
import { Patients } from './pages/patients';
import { Sessions } from './pages/sessions';
import { Signup } from './pages/signup';

export const App = () => {
// Logic to set the user currently logged in
const [user, setUser] = useState(false);

return (
<Page>
<Page user={user}>
<Routes>
<Route exact path="/" element={<Dashboard />} />
<Route exact path="/login" element={<Login />} />
<Route exact path="/signup" element={<Signup />} />

<Route exact path="/" element={<Dashboard />} />
<Route exact path="/patients" element={<Patients />} />
<Route exact path="/sessions" element={<Sessions />} />
{/* <Route path="*" element={<Navigate to="/" />} /> */}
<Route path="*" element={<Navigate to="/" />} />
</Routes>
</Page>
);
Expand Down
6 changes: 5 additions & 1 deletion web/src/components/FormRegisterSession/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export const FormRegisterSession = () => {
return (
<>
<Form.Item>
<Input placeholder="Full Name" />
<Select placeholder="Patient">
<Select.Option value="patient1">Patient1</Select.Option>
<Select.Option value="patient2">Patient2</Select.Option>
<Select.Option value="patient3">Patient3</Select.Option>
</Select>
</Form.Item>
<Form.Item>
<div style={{ display: 'flex', gap: '10px' }}>
Expand Down
54 changes: 28 additions & 26 deletions web/src/components/Page/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,38 @@ const { Content } = Layout;

import { Sidebar } from '../Sidebar';

export function Page({ children }) {
export function Page({ children, user }) {
return (
<Layout
style={{
minHeight: '100vh',
}}
>
<Sidebar />
<Layout className="site-layout">
<Content
style={{
margin: '0 16px',
}}
>
<Breadcrumb
<>
<Layout
style={{
minHeight: '100vh',
}}
>
{user && <Sidebar />}
<Layout className="site-layout">
<Content
style={{
margin: '16px 0',
}}
/>
<div
className="site-layout-background"
style={{
padding: 24,
minHeight: 360,
margin: '0 16px',
}}
>
{children}
</div>
</Content>
<Breadcrumb
style={{
margin: '16px 0',
}}
/>
<div
className="site-layout-background"
style={{
padding: 24,
minHeight: 360,
}}
>
{children}
</div>
</Content>
</Layout>
</Layout>
</Layout>
</>
);
}
3 changes: 3 additions & 0 deletions web/src/pages/signup/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const Signup = () => {
return <h1>Signup</h1>;
};

0 comments on commit cadd27e

Please sign in to comment.