Skip to content

Commit

Permalink
[Dashboard] - Refactor dashboard and API integration (#29)
Browse files Browse the repository at this point in the history
## Draft

- [x] Refactor code
- [ ] Fix #15 
- [ ] Add suggestion here ...

## Please describe the changes this PR makes and why it should be
merged:

- Only refactor and auth integration for now, there's still very long
way to go to fix #15 and better to merge the current work as it is now
and proceed with other thing like updating the doc, too many changes can
easily conflict with new PR

## Status and versioning classification:

- Code changes have been tested against the Discord API, or there are no
code changes
- I know how to update typings and have done so, or typings don't need
updating
- This PR changes the library's interface (methods or parameters added)
  • Loading branch information
brianferri authored Jul 30, 2023
2 parents 80e655f + 4ceb6a4 commit 396d824
Show file tree
Hide file tree
Showing 76 changed files with 1,701 additions and 408 deletions.
4 changes: 4 additions & 0 deletions dashboard/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# if you ever want to host it elsewhere separated from your bot

NEXT_PUBLIC_API_URL=https://www.somedomain.com
NEXT_PUBLIC_API_VERSION=v1
31 changes: 0 additions & 31 deletions dashboard/components/navbar.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions dashboard/components/server.tsx

This file was deleted.

8 changes: 3 additions & 5 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
"lint": "npm i && next lint",
"build": "npm i && next build",
"start": "npm i && next start",
"export": "npm i && next export"
"export": "npm i && next export",
"build-and-start": "npm i && next build && next start"
},
"dependencies": {
"@nextui-org/react": "1.0.0-beta.13",

"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",

"@mui/material": "^5.13.6",
"@mui/icons-material": "^5.11.16",


"@tanstack/react-query": "^4.32.0",
"next": "13.4.12",
"axios": "^1.4.0",
"react": "18.2.0",
Expand Down
13 changes: 0 additions & 13 deletions dashboard/pages/_app.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions dashboard/pages/_document.tsx

This file was deleted.

41 changes: 0 additions & 41 deletions dashboard/pages/dashboard.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions dashboard/pages/login.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions dashboard/pages/logout.tsx

This file was deleted.

36 changes: 0 additions & 36 deletions dashboard/pages/servers.tsx

This file was deleted.

58 changes: 0 additions & 58 deletions dashboard/pages/servers/[id].tsx

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
21 changes: 21 additions & 0 deletions dashboard/src/components/ProcessData.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useProcessData } from '@/hooks/useProcessData';
import { IBaseApiResponse, IUseProcessDataOptions } from '@/interfaces/api';

interface IProcessDataProps<T> extends IUseProcessDataOptions {
data: IBaseApiResponse<T> | undefined;
isLoading: boolean;
children: React.ReactNode;
}

export default function ProcessData<T>({
data,
isLoading,
children,
...props
}: IProcessDataProps<T>) {
const processData = useProcessData(data, isLoading, {
...props,
});

return processData(children);
}
File renamed without changes.
File renamed without changes.
65 changes: 65 additions & 0 deletions dashboard/src/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Button, Link, Spacer } from '@nextui-org/react';
import { useRouter } from 'next/router';

export default function Navbar() {
const router = useRouter();

const pathIs = (path: string) => router.pathname === path;

return (
<div
style={{
height: '100%',
width: '250px',
minWidth: '250px',
backgroundColor: '#16181A',
display: 'flex',
alignItems: 'center',
flexDirection: 'column',
paddingTop: '50px',
position: 'sticky',
top: 0,
}}
>
<Link
css={{
fontSize: '$xl2',
fontWeight: 'bold',
marginBottom: '30px',
color: '#fff',
}}
onClick={() => router.push('/')}
>
Discord Music Bot
</Link>
<Button
css={{
background: pathIs('/dashboard') ? '$primary' : '$gray100',
}}
onPress={() => router.push('/dashboard')}
style={{ marginBottom: '10px' }}
>
Dashboard
</Button>
<Button
css={{
background: pathIs('/servers') ? '$primary' : '$gray100',
}}
color="default"
onPress={() => router.push('/servers')}
style={{ marginBottom: '10px' }}
>
Servers
</Button>
<Spacer />
<Button
color="error"
flat
onPress={() => router.push('/logout')}
style={{ marginBottom: '10px' }}
>
Logout
</Button>
</div>
);
}
Loading

0 comments on commit 396d824

Please sign in to comment.