Skip to content

Commit 01cfc9e

Browse files
authored
Merge pull request #24 from cobuildlab/features/main/clean-code
[feat][main] Clean code
2 parents 1123393 + 59e952c commit 01cfc9e

File tree

16 files changed

+57
-312
lines changed

16 files changed

+57
-312
lines changed

pages/_app.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { PropsWithChildren } from 'react';
12
import { AppProps } from 'next/app';
23
import { UserProvider } from '@auth0/nextjs-auth0';
34
import CssBaseline from '@mui/material/CssBaseline';
45
import { ThemeProvider } from '@mui/material/styles';
56

67
import { ApolloProvider } from '../src/shared/apollo/provider';
78
import { theme } from '../src/shared/styles/theme';
9+
import { NextPageWithLayout } from '../src/shared/types';
810
import '../src/shared/styles/globals.css';
911

1012
/**
@@ -15,19 +17,22 @@ import '../src/shared/styles/globals.css';
1517
* @returns {JSX.Element} - Main app component.
1618
*/
1719
function App({ Component, pageProps }: AppProps):JSX.Element {
20+
const Layout = (Component as NextPageWithLayout).layout || ((props: PropsWithChildren) => <>{props.children}</>)
21+
1822
return (
1923
<>
2024
<CssBaseline />
2125
<UserProvider>
2226
<ApolloProvider>
2327
<ThemeProvider theme={theme}>
24-
<Component {...pageProps} />
28+
<Layout>
29+
<Component {...pageProps} />
30+
</Layout>
2531
</ThemeProvider>
2632
</ApolloProvider>
2733
</UserProvider>
2834
</>
2935
);
3036
}
3137

32-
// eslint-disable-next-line import/no-default-export
3338
export default App;

pages/dashboard.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Link from 'next/link';
2+
import { useUser, withPageAuthRequired } from '@auth0/nextjs-auth0';
3+
4+
import { DashboardLayout } from '../src/shared/components/ui/layouts/DashboardLayout';
5+
import { NextPageWithLayout } from '../src/shared/types';
6+
7+
8+
const DashboardPage: NextPageWithLayout = () => {
9+
10+
const { user } = useUser();
11+
12+
if (user) {
13+
return (
14+
<>
15+
Dashboard
16+
</>
17+
);
18+
}
19+
20+
return null;
21+
}
22+
23+
DashboardPage.layout = DashboardLayout;
24+
25+
export const getServerSideProps = withPageAuthRequired();
26+
27+
export default DashboardPage

pages/index.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
import type { NextPage } from 'next'
1+
import { NextPage } from 'next';
22
import Link from 'next/link';
33
import { useUser } from '@auth0/nextjs-auth0';
44

5+
import { Loader } from '../src/shared/components/ui/components/Loader';
6+
7+
8+
const HomePage: NextPage = () => {
59

6-
const App: NextPage = () => {
710
const { user, error, isLoading } = useUser();
811

9-
if (isLoading) return <div>Loading...</div>;
12+
if (isLoading) return <Loader fullPage />;
1013
if (error) return <div>{error.message}</div>;
1114

1215
if (user) {
1316
return (
14-
<div>
17+
<>
1518
Welcome {user.name}! <Link href="/api/auth/logout">Logout</Link>
16-
</div>
19+
</>
1720
);
1821
}
1922

20-
return <Link href="/api/auth/login">Login</Link>;
23+
return <Link href='/api/auth/login'>Login</Link>
2124
}
2225

23-
export default App;
26+
export default HomePage;

src/modules/auth/auth-hooks.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/modules/auth/auth-queries.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/modules/auth/auth-types.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/modules/auth/tests/hooks.test.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/modules/dashboard/DashboardView.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/modules/home/HomeView.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/modules/position/components/TablePosition.tsx

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)