Skip to content

Commit

Permalink
dashboard: created page.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
zeim839 committed Dec 20, 2023
1 parent ea1d72d commit 5abd504
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 20 deletions.
18 changes: 18 additions & 0 deletions dashboard/APIController/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ export const GetUser = (jwt : string) => {
})
}

export const UpdateUser = (firstName : string, lastName : string,
jwt : string) => {
return new Promise((resolve: Function, reject: Function) => {
axios.put('/user', { first_name: firstName, last_name: lastName },
{ headers: { 'Authorization': `Bearer ${jwt}` }})
.then((res : AxiosResponse) => {
resolve(res.data)
})
.catch((err : AxiosError) => {
if (err.response && IsAPIFailure(err.response.data)) {
resolve(err.response.data)
return
}
reject(err)
})
})
}

export function IsAPISuccess(obj : any): obj is APIResponse {
return typeof (obj as APIResponse).message !== 'undefined'
}
Expand Down
15 changes: 0 additions & 15 deletions dashboard/app/account/page.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions dashboard/app/authorize/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ export default function Page() {
return (<SignupForm setView={setView} />)
}

// No URL parameters and user is already signed in, redirect to account page.
// No URL parameters and user is already signed in, redirect to dashboard.
if (typeof jwt !== "undefined" && client.response_type === null) {
redirect("/account")
redirect("/")
return null
}

Expand Down
9 changes: 9 additions & 0 deletions dashboard/app/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@
letter-spacing: 0;
color: #161616;
}

.account {
height: calc(100vh - 48px - 32px - 32px);
width: calc(100vw - 32px - 32px);
}

.account--tablist {
margin-top: 20px;
}
38 changes: 38 additions & 0 deletions dashboard/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use client'

import { redirect } from 'next/navigation'
import { useCookies } from 'next-client-cookies'
import MyAccount from '@/components/MyAccount/MyAccount'
import { Heading, Tabs, TabList, Tab, TabPanels, TabPanel } from '@carbon/react'

export default function Page() {
const cookies = useCookies()
const jwt = cookies.get('ows-jwt')
if (typeof jwt === "undefined") {
redirect("/authorize")
}

return (
<div className="account">
<Heading> Dashboard </Heading>
<Tabs>
<TabList contained className="account--tablist">
<Tab>Analytics</Tab>
<Tab>Clients</Tab>
<Tab>Users</Tab>
<Tab disabled>DNS</Tab>
<Tab disabled>CDN</Tab>
<Tab>My Account</Tab>
</TabList>
<TabPanels>
<TabPanel> Tab Panel 1 </TabPanel>
<TabPanel> Tab Panel 2 </TabPanel>
<TabPanel> Tab Panel 3 </TabPanel>
<TabPanel> Tab Panel 4 </TabPanel>
<TabPanel> Tab Panel 5 </TabPanel>
<TabPanel><MyAccount /></TabPanel>
</TabPanels>
</Tabs>
</div>
)
}
3 changes: 0 additions & 3 deletions dashboard/components/NavHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ const NavHeader = (props : { setTheme: Function }) => {
{
(typeof jwt !== "undefined") ? (
<>
<HeaderGlobalAction aria-label="Account" tooltipAlignment="center">
<UserAvatar size={20} onClick={() => location.replace("/account")}/>
</HeaderGlobalAction>
<HeaderGlobalAction aria-label="Logout" tooltipAlignment="center"
onClick={onSignout}>
<Logout size={20} />
Expand Down

0 comments on commit 5abd504

Please sign in to comment.