diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..bffb357
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,3 @@
+{
+ "extends": "next/core-web-vitals"
+}
diff --git a/@/components/ui/alert.js b/@/components/ui/alert.js
index 03140eb..470455c 100644
--- a/@/components/ui/alert.js
+++ b/@/components/ui/alert.js
@@ -1,10 +1,5 @@
-import * as React from "react"
-export function Alert({
- children,
- className,
- variant,
- ...props
-}) {
+import * as React from "react";
+export function Alert({ children, className, variant, ...props }) {
return (
(
-
-));
-ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
-
-const toastVariants = cva(
- "group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
- {
- variants: {
- variant: {
- default: "border bg-background text-foreground",
- destructive:
- "destructive group border-destructive bg-destructive text-destructive-foreground",
- },
- },
- defaultVariants: {
- variant: "default",
- },
- },
-);
-
-const Toast = React.forwardRef(({ className, variant, ...props }, ref) => {
- return (
-
- );
-});
-Toast.displayName = ToastPrimitives.Root.displayName;
-
-const ToastAction = React.forwardRef(({ className, ...props }, ref) => (
-
-));
-ToastAction.displayName = ToastPrimitives.Action.displayName;
-
-const ToastClose = React.forwardRef(({ className, ...props }, ref) => (
-
-
-
-));
-ToastClose.displayName = ToastPrimitives.Close.displayName;
-
-const ToastTitle = React.forwardRef(({ className, ...props }, ref) => (
-
-));
-ToastTitle.displayName = ToastPrimitives.Title.displayName;
-
-const ToastDescription = React.forwardRef(({ className, ...props }, ref) => (
-
-));
-ToastDescription.displayName = ToastPrimitives.Description.displayName;
-
-export {
- ToastProvider,
- ToastViewport,
- Toast,
- ToastTitle,
- ToastDescription,
- ToastClose,
- ToastAction,
-};
diff --git a/@/components/ui/toaster.jsx b/@/components/ui/toaster.jsx
deleted file mode 100644
index d38613a..0000000
--- a/@/components/ui/toaster.jsx
+++ /dev/null
@@ -1,35 +0,0 @@
-"use client";
-
-import {
- Toast,
- ToastClose,
- ToastDescription,
- ToastProvider,
- ToastTitle,
- ToastViewport,
-} from "./toast";
-import { useToast } from "./use-toast";
-
-export function Toaster() {
- const { toasts } = useToast();
-
- return (
-
- {toasts.map(function ({ id, title, description, action, ...props }) {
- return (
-
-
- {title && {title}}
- {description && (
- {description}
- )}
-
- {action}
-
-
- );
- })}
-
-
- );
-}
diff --git a/@/components/ui/use-toast.js b/@/components/ui/use-toast.js
deleted file mode 100644
index b203b7e..0000000
--- a/@/components/ui/use-toast.js
+++ /dev/null
@@ -1,155 +0,0 @@
-"use client";
-// Inspired by react-hot-toast library
-import * as React from "react";
-
-const TOAST_LIMIT = 1;
-const TOAST_REMOVE_DELAY = 1000000;
-
-const actionTypes = {
- ADD_TOAST: "ADD_TOAST",
- UPDATE_TOAST: "UPDATE_TOAST",
- DISMISS_TOAST: "DISMISS_TOAST",
- REMOVE_TOAST: "REMOVE_TOAST",
-};
-
-let count = 0;
-
-function genId() {
- count = (count + 1) % Number.MAX_SAFE_INTEGER;
- return count.toString();
-}
-
-const toastTimeouts = new Map();
-
-const addToRemoveQueue = (toastId) => {
- if (toastTimeouts.has(toastId)) {
- return;
- }
-
- const timeout = setTimeout(() => {
- toastTimeouts.delete(toastId);
- dispatch({
- type: "REMOVE_TOAST",
- toastId: toastId,
- });
- }, TOAST_REMOVE_DELAY);
-
- toastTimeouts.set(toastId, timeout);
-};
-
-export const reducer = (state, action) => {
- switch (action.type) {
- case "ADD_TOAST":
- return {
- ...state,
- toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
- };
-
- case "UPDATE_TOAST":
- return {
- ...state,
- toasts: state.toasts.map((t) =>
- t.id === action.toast.id ? { ...t, ...action.toast } : t,
- ),
- };
-
- case "DISMISS_TOAST": {
- const { toastId } = action;
-
- // ! Side effects ! - This could be extracted into a dismissToast() action,
- // but I'll keep it here for simplicity
- if (toastId) {
- addToRemoveQueue(toastId);
- } else {
- state.toasts.forEach((toast) => {
- addToRemoveQueue(toast.id);
- });
- }
-
- return {
- ...state,
- toasts: state.toasts.map((t) =>
- t.id === toastId || toastId === undefined
- ? {
- ...t,
- open: false,
- }
- : t,
- ),
- };
- }
- case "REMOVE_TOAST":
- if (action.toastId === undefined) {
- return {
- ...state,
- toasts: [],
- };
- }
- return {
- ...state,
- toasts: state.toasts.filter((t) => t.id !== action.toastId),
- };
- }
-};
-
-const listeners = [];
-
-let memoryState = { toasts: [] };
-
-function dispatch(action) {
- memoryState = reducer(memoryState, action);
- listeners.forEach((listener) => {
- listener(memoryState);
- });
-}
-
-function toast({ ...props }) {
- const id = genId();
-
- const update = (props) =>
- dispatch({
- type: "UPDATE_TOAST",
- toast: { ...props, id },
- });
- const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
-
- dispatch({
- type: "ADD_TOAST",
- toast: {
- ...props,
- id,
- open: true,
- onOpenChange: (open) => {
- if (!open) dismiss();
- },
- },
- });
-
- return {
- id: id,
- dismiss,
- update,
- };
-}
-
-function useToast() {
- const [state, setState] = React.useState(memoryState);
-
- React.useEffect(() => {
- listeners.push(setState);
- return () => {
- const index = listeners.indexOf(setState);
- if (index > -1) {
- listeners.splice(index, 1);
- }
- };
- }, [state]);
-
- return {
- ...state,
- toast,
- dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId }),
- };
-}
-
-export { useToast, toast };
diff --git a/app/action/sendContactEmail.js b/app/action/sendContactEmail.js
new file mode 100644
index 0000000..719e867
--- /dev/null
+++ b/app/action/sendContactEmail.js
@@ -0,0 +1,26 @@
+"use server";
+import { resend } from "../../lib/resend";
+import ContactEmailTemplate from "../../components/Contatct/Contatc-email-format";
+
+export async function sendContactEmail(username, fromEmail, message, subject) {
+ try {
+ const res = await resend.emails.send({
+ from: "Acme
",
+ to: "kashyap25ankit@gmail.com",
+ subject: subject,
+ html: ContactEmailTemplate({ username, message, fromEmail }),
+ });
+
+ if (!res.data) throw new Error(res.error.name);
+
+ return {
+ status: 200,
+ message: "Sent successfully",
+ };
+ } catch (error) {
+ return {
+ status: 400,
+ message: error.message,
+ };
+ }
+}
diff --git a/app/api/brackets/[id]/mockBrackets.js b/app/api/brackets/[id]/mockBrackets.js
index f9bfe11..c81cc17 100644
--- a/app/api/brackets/[id]/mockBrackets.js
+++ b/app/api/brackets/[id]/mockBrackets.js
@@ -97,99 +97,97 @@ export default {
},
},
],
-
+
group: [
{
id: 0,
stage_id: 0,
- number: 1
- }
+ number: 1,
+ },
],
-
+
round: [
{ id: 0, number: 1, stage_id: 0, group_id: 0 },
{ id: 1, number: 2, stage_id: 0, group_id: 0 },
{ id: 2, number: 3, stage_id: 0, group_id: 0 },
- { id: 3, number: 4, stage_id: 0, group_id: 0 }
+ { id: 3, number: 4, stage_id: 0, group_id: 0 },
+ ],
+
+ match: [
+ {
+ id: 0,
+ number: 1,
+ stage_id: 0,
+ group_id: 0,
+ round_id: 0,
+ child_count: 0,
+ status: 4,
+ opponent1: { id: 0, position: 1, score: 1, result: "win" },
+ opponent2: { id: 15, position: 16, score: 0, result: "loss" },
+ },
+ {
+ id: 1,
+ number: 2,
+ stage_id: 0,
+ group_id: 0,
+ round_id: 0,
+ child_count: 0,
+ status: 2,
+ opponent1: { id: 7, position: 8 },
+ opponent2: { id: 8, position: 9 },
+ },
+ {
+ id: 2,
+ number: 3,
+ stage_id: 0,
+ group_id: 0,
+ round_id: 0,
+ child_count: 0,
+ status: 2,
+ opponent1: { id: 3, position: 4 },
+ opponent2: { id: 12, position: 13 },
+ },
+ {
+ id: 3,
+ number: 4,
+ stage_id: 0,
+ group_id: 0,
+ round_id: 0,
+ child_count: 0,
+ status: 2,
+ opponent1: { id: 4, position: 5 },
+ opponent2: { id: 11, position: 12 },
+ },
+ {
+ id: 4,
+ number: 5,
+ stage_id: 0,
+ group_id: 0,
+ round_id: 0,
+ child_count: 0,
+ status: 2,
+ opponent1: { id: 1, position: 2 },
+ opponent2: { id: null },
+ },
+ {
+ id: 5,
+ number: 6,
+ stage_id: 0,
+ group_id: 0,
+ round_id: 0,
+ child_count: 0,
+ status: "pending",
+ opponent1: {
+ id: "6",
+ position: "7",
+ },
+ opponent2: {
+ id: "9",
+ position: "10",
+ },
+ },
+ // Continue adding matches as per the structure above
],
-
- match:[
- {
- id :0,
- number :1,
- stage_id :0,
- group_id :0,
- round_id :0,
- child_count :0,
- status :4,
- opponent1 :{id :0 , position :1 , score :1 , result :"win"},
- opponent2 :{id :15 , position :16 , score :0 , result :"loss"}
- },
- {
- id :1,
- number :2,
- stage_id :0,
- group_id :0,
- round_id :0,
- child_count :0,
- status :2,
- opponent1 :{id :7 , position :8},
- opponent2 :{id :8 , position :9}
- },
- {
- id :2,
- number :3,
- stage_id :0,
- group_id :0,
- round_id :0,
- child_count :0,
- status :2,
- opponent1 :{id :3 , position :4},
- opponent2 :{id :12 , position :13}
- },
- {
- id :3,
- number :4,
- stage_id :0,
- group_id :0,
- round_id :0,
- child_count :0,
- status :2,
- opponent1:{id :4 , position :5},
- opponent2:{id :11 , position :12}
- },
- {
- id :4,
- number :5,
- stage_id :0,
- group_id :0,
- round_id :0,
- child_count :0,
- status :2,
- opponent1:{id :1 , position :2},
- opponent2:{id:null}
- },
- {
- id :5,
- number :6,
- stage_id :0,
- group_id :0,
- round_id :0,
- child_count :0,
- status :"pending",
- opponent1 :
- {
- id :"6",
- position :"7"
- },
- opponent2 :
- {
- id :"9",
- position :"10"
- }
- }
- // Continue adding matches as per the structure above
- ],
-
- match_game:[]
-}
+
+ match_game: [],
+};
diff --git a/app/api/brackets/route.js b/app/api/brackets/route.js
index 8b8fa4b..2464ad6 100644
--- a/app/api/brackets/route.js
+++ b/app/api/brackets/route.js
@@ -17,15 +17,16 @@ export async function POST(request) {
await dbConnect();
const body = await request.json();
- const validation = bracketSchema.safeParse(body)
+ const validation = bracketSchema.safeParse(body);
if (!validation.success) {
- return NextResponse.json(validation.error.format(), { status: 400 })
+ return NextResponse.json(validation.error.format(), { status: 400 });
}
- console.log(validation.data)
+ console.log(validation.data);
- const { tournament_name, format, consolationFinal, grandFinalType, teams } = validation.data;
+ const { tournament_name, format, consolationFinal, grandFinalType, teams } =
+ validation.data;
const newBracket = new Bracket({
tournamentName: tournament_name,
@@ -33,24 +34,29 @@ export async function POST(request) {
BracketSize: teams.length,
consolationFinal,
grandFinalType,
- teams
+ teams,
});
await newBracket.save();
- return NextResponse.json({
- message: 'Bracket created successfully',
- id: newBracket._id
- }, { status: 201 });
+ return NextResponse.json(
+ {
+ message: "Bracket created successfully",
+ id: newBracket._id,
+ },
+ { status: 201 },
+ );
} catch (error) {
- console.error('Error creating bracket:', error);
- return NextResponse.json({
- error: 'Internal Server Error',
- details: error.message
- }, { status: 500 });
-
- }
-};
+ console.error("Error creating bracket:", error);
+ return NextResponse.json(
+ {
+ error: "Internal Server Error",
+ details: error.message,
+ },
+ { status: 500 },
+ );
+ }
+}
export async function GET() {
try {
diff --git a/app/api/games/route.js b/app/api/games/route.js
index 6121fea..3d6e111 100644
--- a/app/api/games/route.js
+++ b/app/api/games/route.js
@@ -1,4 +1,3 @@
-
import { NextResponse } from "next/server";
import dbConnect from "../../../lib/dbConnect";
import Games from "../../../model/Games";
diff --git a/app/api/sign-up/route.ts b/app/api/sign-up/route.ts
index 046a332..38928ac 100644
--- a/app/api/sign-up/route.ts
+++ b/app/api/sign-up/route.ts
@@ -4,7 +4,7 @@ import UserModel from "../../../model/User";
import bcrypt from "bcryptjs";
import crypto from "crypto";
-export async function POST(request:Request) {
+export async function POST(request: Request) {
await dbConnect();
try {
@@ -99,4 +99,4 @@ export async function POST(request:Request) {
{ status: 500 },
);
}
-}
\ No newline at end of file
+}
diff --git a/app/auth/error/page.js b/app/auth/error/page.js
index 0044224..b42e31e 100644
--- a/app/auth/error/page.js
+++ b/app/auth/error/page.js
@@ -2,7 +2,11 @@
import { useSearchParams } from "next/navigation";
import { Suspense } from "react";
-import { Alert, AlertDescription, AlertTitle } from "../../../@/components/ui/alert";
+import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
+} from "../../../@/components/ui/alert";
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
function ErrorContent() {
@@ -20,22 +24,22 @@ function ErrorContent() {
return errorMessages[errorCode] || errorMessages.Default;
};
- return (
-
-
-
- Authentication Error
-
- {getErrorMessage(error)}
- {error && (
-
- Error code: {error}
-
- )}
-
-
-
- );
+ return (
+
+
+
+ Authentication Error
+
+ {getErrorMessage(error)}
+ {error && (
+
+ Error code: {error}
+
+ )}
+
+
+
+ );
}
export default function ErrorPage() {
diff --git a/app/bracket/[id]/page.js b/app/bracket/[id]/page.js
index 327098a..866455b 100644
--- a/app/bracket/[id]/page.js
+++ b/app/bracket/[id]/page.js
@@ -1,19 +1,47 @@
"use client";
import { useParams } from "next/navigation";
+import { useEffect, useState } from "react";
import Bracket from "../../../components/Brackets";
-const BracketTemplate = async () => {
- const params = useParams();
- const { id } = params;
+const BracketTemplate = () => {
+ const { id } = useParams();
+ const [bracket, setBracket] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
- const bracket = await fetch(`/api/brackets/${id}`);
+ useEffect(() => {
+ const fetchBracket = async () => {
+ try {
+ const response = await fetch(`/api/brackets/${id}`);
+ if (!response.ok) {
+ throw new Error("Error fetching bracket");
+ }
+ const data = await response.json();
+ setBracket(data);
+ } catch (err) {
+ setError(err.message);
+ } finally {
+ setLoading(false);
+ }
+ };
- if (!bracket.ok) {
- return Error fetching bracket
;
+ if (id) {
+ fetchBracket();
+ }
+ }, [id]);
+
+ if (loading) {
+ return Loading...
;
+ }
+
+ if (error) {
+ return {error}
;
}
- const { tournamentName, format, consolationFinal, grandFinalType, teams } = await bracket.json();
+ // Destructure the bracket data once it's loaded
+ const { tournamentName, format, consolationFinal, grandFinalType, teams } =
+ bracket;
return (
@@ -23,30 +51,16 @@ const BracketTemplate = async () => {
{teams.length} Teams{" "}
- ({format === "single_elimination" ? "Single Elimination" : format === "double_elimination" ? "Double Elimination" : "Invalid Format"})
+
+ {format === "single_elimination"
+ ? "Single Elimination"
+ : format === "double_elimination"
+ ? "Double Elimination"
+ : "Invalid Format"}
+
- {/*
-
- {numOfTeams % 2 !=== 0 &&
}
- {Array.from({ length: Math.floor(numOfTeams / 2) }).map((_, i) => (
-
-
-
-
- ))}
-
-
*/}
+ {/* The commented-out bracket grid is not needed for now */}
{/* */}
);
diff --git a/app/bracket/page.js b/app/bracket/page.js
index d4e69d1..e70d4fd 100644
--- a/app/bracket/page.js
+++ b/app/bracket/page.js
@@ -7,7 +7,6 @@ import Link from "next/link";
const BracketPage = () => {
return (
-
-
-
Games
-
-
-
- {errorMessage &&
{errorMessage}
}
-
-
- {Array.isArray(gameData) && gameData.length > 0 ? (
- gameData.map((game) => (
-
-
+
Games
+
+
+
+ {errorMessage &&
{errorMessage}
}
+
+
+ {Array.isArray(gameData) && gameData.length > 0 ? (
+ gameData.map((game) => (
+
+
-
-
-
- ))
- ) : (
-
No games found.
- )}
-
-
-
- );
+
+
+ ))
+ ) : (
+
No games found.
+ )}
+
+
+ );
+ }
}
-}
\ No newline at end of file
diff --git a/app/layout.js b/app/layout.js
index 4e4b8e4..fde0fd9 100644
--- a/app/layout.js
+++ b/app/layout.js
@@ -6,7 +6,7 @@ import Footer from "../components/Footer";
import AuthProvider from "../context/AuthProvider";
import NextTopLoader from "nextjs-toploader";
import dotenv from "dotenv";
-import { Toaster } from "../@/components/ui/toaster";
+import { Toaster } from "react-hot-toast";
dotenv.config();
@@ -70,7 +70,8 @@ export default function RootLayout({ children }) {
{children}
-
+
+