Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#426 FEAT: Add admin routes #431

Merged
merged 7 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/apiFunctions.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { IEntry } from '@/app/league/[leagueId]/entry/Entries.interface';
import { IEntry } from '@/app/(main)/league/[leagueId]/entry/Entries.interface';

export interface IAccountData {
email: string;
Expand Down
2 changes: 1 addition & 1 deletion api/apiFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Query } from 'appwrite';
import {
IEntry,
IEntryProps,
} from '@/app/league/[leagueId]/entry/Entries.interface';
} from '@/app/(main)/league/[leagueId]/entry/Entries.interface';

/**
* Register a new account
Expand Down
14 changes: 14 additions & 0 deletions app/(admin)/admin/leagues/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { JSX } from 'react';

/**
* Renders the admin page.
* @returns {JSX.Element} - The rendered login page.
*/
const AdminLeagues = (): JSX.Element => {
return <div>Admin Leagues</div>;
};

export default AdminLeagues;
14 changes: 14 additions & 0 deletions app/(admin)/admin/notifications/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { JSX } from 'react';

/**
* Renders the admin page.
* @returns {JSX.Element} - The rendered login page.
*/
const AdminNotifications = (): JSX.Element => {
return <div>Admin Notifications</div>;
};

export default AdminNotifications;
14 changes: 14 additions & 0 deletions app/(admin)/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { JSX } from 'react';

/**
* Renders the admin page.
* @returns {JSX.Element} - The rendered login page.
*/
const AdminHome = (): JSX.Element => {
return <div>Admin Home</div>;
};

export default AdminHome;
14 changes: 14 additions & 0 deletions app/(admin)/admin/players/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { JSX } from 'react';

/**
* Renders the admin page.
* @returns {JSX.Element} - The rendered login page.
*/
const AdminPlayers = (): JSX.Element => {
return <div>Admin Players</div>;
};

export default AdminPlayers;
46 changes: 46 additions & 0 deletions app/(admin)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import React, { JSX } from 'react';
import { GeistSans } from 'geist/font/sans';
import '../globals.css';
import { AuthContextProvider } from '@/context/AuthContextProvider';
import ErrorBoundary from '../error';
import { Toaster } from 'react-hot-toast';

const defaultUrl = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: 'http://localhost:3000';

export const metadata = {
metadataBase: new URL(defaultUrl),
title: 'GridIron Survivor',
description: 'Fantasy Football Survivor Pool',
};

/**
* The root layout for the application.
* @param props - The props
* @param props.children - The children
* @returns The rendered root layout.
*/
const RootLayout = ({
children,
}: {
children: React.ReactNode;
}): JSX.Element => {
return (
<html lang="en" className={GeistSans.className}>
<body className="dark:dark bg-background pb-8 px-4 text-foreground xl:pb-0">
<ErrorBoundary>
<AuthContextProvider>
<main>{children}</main>
<Toaster />
</AuthContextProvider>
</ErrorBoundary>
</body>
</html>
);
};

export default RootLayout;
4 changes: 2 additions & 2 deletions app/layout.tsx → app/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import React, { JSX } from 'react';
import { GeistSans } from 'geist/font/sans';
import './globals.css';
import '../globals.css';
import Nav from '@/components/Nav/Nav';
import { AuthContextProvider } from '@/context/AuthContextProvider';
import ErrorBoundary from './error';
import ErrorBoundary from '../error';
import { Toaster } from 'react-hot-toast';

const defaultUrl = process.env.VERCEL_URL
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/login/page.tsx → app/(main)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
FormField,
FormItem,
FormMessage,
} from '../../components/Form/Form';
} from '../../../components/Form/Form';

const LoginUserSchema = z.object({
email: z
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/register/page.tsx → app/(main)/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
FormField,
FormItem,
FormMessage,
} from '../../components/Form/Form';
} from '../../../components/Form/Form';
import { toast } from 'react-hot-toast';
import Alert from '@/components/AlertNotification/AlertNotification';
import { AlertVariants } from '@/components/AlertNotification/Alerts.enum';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ const alertVariants = cva(
const Alert = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
>(({ variant, children }) => (
>(({ variant, children }, ref) => (
<div
role="alert"
className={alertVariants({ variant })}
ref={ref}
>{children}</div>
));
Alert.displayName = 'Alert';
Expand Down
3 changes: 2 additions & 1 deletion components/LeagueCard/LeagueCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ const LeagueCard = React.forwardRef<HTMLAnchorElement, ILeagueCardProps>(
survivors,
title,
totalPlayers,
}) => (
}, ref) => (
<Link
data-testid="LeagueCard"
href={href}
className={cn(
'LeagueCard flex max-h-32 place-items-center gap-6 rounded-lg border bg-card p-4 text-card-foreground shadow-sm dark:border-zinc-800 hover:bg-zinc-800 transition',
)}
ref={ref}
>
<Image
alt="League Logo"
Expand Down
2 changes: 1 addition & 1 deletion components/Nav/Nav.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import Nav from './Nav';
import Login from '@/app/login/page';
import Login from '@/app/(main)/login/page';

const mockPush = jest.fn();
const mockUsePathname = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IUser,
IWeeklyPicks,
} from '@/api/apiFunctions.interface';
import { IEntry } from '@/app/league/[leagueId]/entry/Entries.interface';
import { IEntry } from '@/app/(main)/league/[leagueId]/entry/Entries.interface';

export interface IGetGameData {
userId: IUser['id'];
Expand Down
4 changes: 2 additions & 2 deletions utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
IGetUserPick,
} from './utils.interface';
import { ILeague } from '@/api/apiFunctions.interface';
import { IEntry } from '@/app/league/[leagueId]/entry/Entries.interface';
import { IEntry } from '@/app/(main)/league/[leagueId]/entry/Entries.interface';

/**
* Combine class names
Expand Down Expand Up @@ -143,4 +143,4 @@ export const getUserLeagues = async (
*/
export const getUserEntries = async (userId: IUser['id'], leagueId: ILeague['leagueId']): Promise<IEntry[]> => {
return await getCurrentUserEntries(userId, leagueId);
}
}
Loading