Skip to content

Commit

Permalink
chore(ui): reformat via prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
iamKunalGupta committed Jan 8, 2024
1 parent 2ab5d1e commit d5c7eef
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 98 deletions.
6 changes: 1 addition & 5 deletions ui/app/alert-config/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@ import { Layout } from '@/lib/Layout';
import { PropsWithChildren } from 'react';

export default function PageLayout({ children }: PropsWithChildren) {
return (
<Layout sidebar={<SidebarComponent />}>
{children}
</Layout>
);
return <Layout sidebar={<SidebarComponent />}>{children}</Layout>;
}
4 changes: 1 addition & 3 deletions ui/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import NextAuth from 'next-auth';
import { authOptions } from '@/app/auth/options';

import NextAuth from 'next-auth';

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };
4 changes: 2 additions & 2 deletions ui/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export var Configuration = {
PEERDB_PASSWORD: process.env.PEERDB_PASSWORD,
// Set this in production to a static value
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
}
}
},
};
6 changes: 1 addition & 5 deletions ui/app/mirrors/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@ import { Layout } from '@/lib/Layout';
import { PropsWithChildren } from 'react';

export default function PageLayout({ children }: PropsWithChildren) {
return (
<Layout sidebar={<SidebarComponent />}>
{children}
</Layout>
);
return <Layout sidebar={<SidebarComponent />}>{children}</Layout>;
}
6 changes: 1 addition & 5 deletions ui/app/peers/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@ import { Layout } from '@/lib/Layout';
import { PropsWithChildren } from 'react';

export default function PageLayout({ children }: PropsWithChildren) {
return (
<Layout sidebar={<SidebarComponent />}>
{children}
</Layout>
);
return <Layout sidebar={<SidebarComponent />}>{children}</Layout>;
}
7 changes: 5 additions & 2 deletions ui/components/Logout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
'use client';
import { Button } from '@/lib/Button';
import { useRouter } from 'next/navigation';
import { useSession } from 'next-auth/react';
import { useRouter } from 'next/navigation';

export default function Logout() {
const { data: session } = useSession();
const router = useRouter();
if (session) {
return (
<Button
style={{ backgroundColor: 'white', border: '1px solid rgba(0,0,0,0.15)' }}
style={{
backgroundColor: 'white',
border: '1px solid rgba(0,0,0,0.15)',
}}
onClick={() => router.push('/api/auth/signout')}
>
Log out
Expand Down
144 changes: 72 additions & 72 deletions ui/components/SidebarComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Icon } from '@/lib/Icon';
import { Label } from '@/lib/Label';
import { RowWithSelect } from '@/lib/Layout';
import { Sidebar, SidebarItem } from '@/lib/Sidebar';
import { SessionProvider } from 'next-auth/react';
import Link from 'next/link';
import useSWR from 'swr';
import { useLocalStorage } from 'usehooks-ts';
import { SessionProvider } from 'next-auth/react';

const centerFlexStyle = {
display: 'flex',
Expand All @@ -21,7 +21,7 @@ const centerFlexStyle = {
marginBottom: '0.5rem',
};

export default function SidebarComponent(props: { }) {
export default function SidebarComponent(props: {}) {
const timezones = ['UTC', 'Local', 'Relative'];
const [zone, setZone] = useLocalStorage('timezone-ui', '');

Expand All @@ -36,79 +36,79 @@ export default function SidebarComponent(props: { }) {

return (
<SessionProvider>
<Sidebar
topTitle={
<Label as={Link} href='/'>
<div className='cursor-pointer'>
<BrandLogo />
</div>
</Label>
}
bottomRow={
<>
<div style={centerFlexStyle}>
<div style={{ width: '80%' }}>
<RowWithSelect
label={<Label>Timezone:</Label>}
action={
<select
style={{
borderRadius: '0.5rem',
padding: '0.2rem',
backgroundColor: 'transparent',
boxShadow: '0px 2px 4px rgba(0,0,0,0.1)',
}}
value={zone}
id='timeselect'
onChange={(e) => setZone(e.target.value)}
>
{timezones.map((tz, id) => {
return (
<option key={id} value={tz}>
{tz}
</option>
);
})}
</select>
}
/>
<Sidebar
topTitle={
<Label as={Link} href='/'>
<div className='cursor-pointer'>
<BrandLogo />
</div>
</div>
<Logout />
</>
}
bottomLabel={
<div style={centerFlexStyle}>
<Label as='label' style={{ textAlign: 'center', fontSize: 15 }}>
{' '}
<b>Version: </b>
{isLoading ? 'Loading...' : version?.version}
</Label>
</div>
}
>
<SidebarItem
as={Link}
href={'/peers'}
leadingIcon={<Icon name='cable' />}
>
Peers
</SidebarItem>
<SidebarItem
as={Link}
href={'/mirrors'}
leadingIcon={<Icon name='compare_arrows' />}
>
Mirrors
</SidebarItem>
<SidebarItem
as={Link}
href={'/alert-config'}
leadingIcon={<Icon name='notifications' />}
}
bottomRow={
<>
<div style={centerFlexStyle}>
<div style={{ width: '80%' }}>
<RowWithSelect
label={<Label>Timezone:</Label>}
action={
<select
style={{
borderRadius: '0.5rem',
padding: '0.2rem',
backgroundColor: 'transparent',
boxShadow: '0px 2px 4px rgba(0,0,0,0.1)',
}}
value={zone}
id='timeselect'
onChange={(e) => setZone(e.target.value)}
>
{timezones.map((tz, id) => {
return (
<option key={id} value={tz}>
{tz}
</option>
);
})}
</select>
}
/>
</div>
</div>
<Logout />
</>
}
bottomLabel={
<div style={centerFlexStyle}>
<Label as='label' style={{ textAlign: 'center', fontSize: 15 }}>
{' '}
<b>Version: </b>
{isLoading ? 'Loading...' : version?.version}
</Label>
</div>
}
>
Alert Configuration
</SidebarItem>
</Sidebar>
<SidebarItem
as={Link}
href={'/peers'}
leadingIcon={<Icon name='cable' />}
>
Peers
</SidebarItem>
<SidebarItem
as={Link}
href={'/mirrors'}
leadingIcon={<Icon name='compare_arrows' />}
>
Mirrors
</SidebarItem>
<SidebarItem
as={Link}
href={'/alert-config'}
leadingIcon={<Icon name='notifications' />}
>
Alert Configuration
</SidebarItem>
</Sidebar>
</SessionProvider>
);
}
6 changes: 2 additions & 4 deletions ui/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { NextRequest, NextResponse } from 'next/server';
import { withAuth } from 'next-auth/middleware';
import { Configuration } from '@/app/config/config';
import { withAuth } from 'next-auth/middleware';
import { NextRequest, NextResponse } from 'next/server';

const authMiddleware = withAuth({});


export default async function middleware(req: NextRequest, resp: NextResponse) {
if (Configuration.authentication.PEERDB_PASSWORD) {
return (authMiddleware as any)(req);
}
}


export const config = {
matcher: [
// Match everything other than static assets
Expand Down

0 comments on commit d5c7eef

Please sign in to comment.