Skip to content

Commit

Permalink
revamed the contact page
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashyap1ankit committed Dec 21, 2024
1 parent b418101 commit b1413af
Show file tree
Hide file tree
Showing 17 changed files with 481 additions and 293 deletions.
30 changes: 14 additions & 16 deletions app/api/brackets/[id]/mockBrackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,20 @@ export default {
name: "Revenant Esports",
},
],
"stage": [
{
"id": 0,
"tournament_id": 1,
"name": "Elimination stage",
"type": "single_elimination",
"settings": {
"grandFinal": "single",
"consolationFinal": false,
"matchesChildCount": 0,
"size": 16,
"seedOrdering": [
"inner_outer"
]
}
}
stage: [
{
id: 0,
tournament_id: 1,
name: "Elimination stage",
type: "single_elimination",
settings: {
grandFinal: "single",
consolationFinal: false,
matchesChildCount: 0,
size: 16,
seedOrdering: ["inner_outer"],
},
},
],
group: [
{
Expand Down
101 changes: 51 additions & 50 deletions app/api/brackets/route.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,72 @@

import dbConnect from '../../../lib/dbConnect';
import Bracket from '../../../model/Bracket';
import { NextResponse } from 'next/server';
import Tournament from '../../../model/Tournament';
import { z } from 'zod';
import dbConnect from "../../../lib/dbConnect";
import Bracket from "../../../model/Bracket";
import { NextResponse } from "next/server";
import Tournament from "../../../model/Tournament";
import { z } from "zod";

const bracketSchema = z.object({
tournament_name: z.string().min(1),
format: z.enum(['single_elimination', 'double_elimination']),
consolationFinal: z.boolean().default(false),
grandFinalType: z.enum(['simple', 'double']),
teams: z.array(z.string().min(1)).min(4, "At least 4 teams are required")
})
tournament_name: z.string().min(1),
format: z.enum(["single_elimination", "double_elimination"]),
consolationFinal: z.boolean().default(false),
grandFinalType: z.enum(["simple", "double"]),
teams: z.array(z.string().min(1)).min(4, "At least 4 teams are required"),
});

export async function POST(request) {
try {
await dbConnect();

const body = await request.json();

const validation = bracketSchema.safeParse(body)
const body = await request.json();

if (!validation.success) {
return NextResponse.json(validation.error.format(), { status: 400 })
}
const validation = bracketSchema.safeParse(body);

console.log(validation.data)
if (!validation.success) {
return NextResponse.json(validation.error.format(), { status: 400 });
}

return NextResponse.json(validation.data, { status: 201 });
console.log(validation.data);

// const { tournament_id, consolationFinal, grandFinalType } = validation.data;
return NextResponse.json(validation.data, { status: 201 });

// const { tournament_id, consolationFinal, grandFinalType } = validation.data;

// const tournament = await Tournament.findById(tournament_id);
// if (!tournament) {
// return NextResponse.json({ error: 'Tournament not found' }, { status: 404 });
// }
// const tournament = await Tournament.findById(tournament_id);
// if (!tournament) {
// return NextResponse.json({ error: 'Tournament not found' }, { status: 404 });
// }

// const bracketName = tournament.tournamentName;
// const registeredCount = tournament.teamsRegistered.length
// const bracketName = tournament.tournamentName;
// const registeredCount = tournament.teamsRegistered.length

// const newBracket = new Bracket({
// bracketName,
// tournamentId: tournament_id,
// BracketNumber: registeredCount,
// consolationFinal,
// grandFinalType,
// });
// const newBracket = new Bracket({
// bracketName,
// tournamentId: tournament_id,
// BracketNumber: registeredCount,
// consolationFinal,
// grandFinalType,
// });

// await newBracket.save();
// await newBracket.save();

// // Update the tournament with the new bracket
// await Tournament.findByIdAndUpdate(tournament_id,
// { $push: { brackets: newBracket._id } }
// );
// // Update the tournament with the new bracket
// await Tournament.findByIdAndUpdate(tournament_id,
// { $push: { brackets: newBracket._id } }
// );

// return NextResponse.json({
// message: 'Bracket created and associated with tournament 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 });
}
// return NextResponse.json({
// message: 'Bracket created and associated with tournament 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 },
);
}
}

export async function GET() {
Expand Down
1 change: 0 additions & 1 deletion app/api/games/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ export async function GET(req) {
);
}
}

8 changes: 3 additions & 5 deletions app/bracket/create/page.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react'
import BracketForm from '../../../components/BracketForm'
import React from "react";
import BracketForm from "../../../components/BracketForm";

export default function Page() {
return (
<BracketForm />
)
return <BracketForm />;
}
27 changes: 15 additions & 12 deletions app/bracket/page.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import TournamentBracket from "../../components/TournamentBracket";
import React from "react"
import React from "react";
import BracketList from "../../components/BracketList";
import { buttonVariants } from "../../components/ui/button"
import { buttonVariants } from "../../components/ui/button";
import Link from "next/link";

const BracketPage = () => {
return (
<div className="min-h-[70vh] px-7">
<div className="border-b pb-4 px-4 flex">
<Link href="/bracket/create" className={`ml-auto ${buttonVariants({ variant: "default" })}`}>
Create a bracket
</Link>
</div>
<BracketList />
</div>
);
return (
<div className="min-h-[70vh] px-7">
<div className="border-b pb-4 px-4 flex">
<Link
href="/bracket/create"
className={`ml-auto ${buttonVariants({ variant: "default" })}`}
>
Create a bracket
</Link>
</div>
<BracketList />
</div>
);
};

export default BracketPage;
80 changes: 5 additions & 75 deletions app/contact/page.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,13 @@
"use client";

import { Card, CardContent } from "../../@/components/ui/card";
import { Input } from "../../@/components/ui/input";
import { Label } from "../../@/components/ui/label";
import { Textarea } from "../../@/components/ui/textarea";
import { Button } from "../../@/components/ui/button";

const contactdetails = [
{
title: "Email",
content: "[email protected]",
},
{
title: "Phone",
content: "+1 (800) 123 XX21",
},
{
title: "Support",
content: "[email protected]",
},
];
import ContactLeftComp from "../../components/Contatct/Contact-left";
import ContactRightComp from "../../components/Contatct/Contact-right";

export default function ContactPage() {
return (
<div className="min-h-[70vh] grid md:grid-cols-2 gap-10 items-center justify-center pt-10 px-10 lg:px-[5%] xl:px-[15%] transition-all">
<div className="flex flex-col items-start gap-10">
<div className="flex flex-col gap-4">
<h1 className="text-4xl font-medium tracking-tight transition-all">
Contact us
</h1>

<h6 className="text-foreground/80 max-w-md tracking-tight">
We are always looking for ways to improve our products and services.
Contact us and let us know how we can help you.
</h6>
</div>

<div className="flex flex-col gap-4">
{contactdetails.map((item, idx) => (
<div key={idx} className="">
<h1 className="">{item.title}</h1>
<p className="text-sm text-foreground/80">{item.content}</p>
</div>
))}
</div>
</div>

<div className="w-full flex flex-col items-center lg:p-10">
<Card className="w-full p-5">
<CardContent className="w-full md:py-5">
<form className="flex flex-col gap-10">
<div>
<Label>Full Name</Label>

<Input className="mt-2" />
</div>

<div>
<Label>Email Address</Label>

<Input className="mt-2" />
</div>

<div>
<Label>Message</Label>

<Textarea rows={3} className="mt-2" />
</div>

<Button
// variant="outline"
className="w-1/3"
>
Submit
</Button>
</form>
</CardContent>
</Card>
</div>
<div className=" w-11/12 mx-auto border border-neutral-700 rounded-sm flex flex-row justify-evenly md:max-w-7xl">
<ContactLeftComp className={"hidden sm:block md:w-1/2"} />
<ContactRightComp className={"w-full md:w-1/2"} />
</div>
);
}
38 changes: 22 additions & 16 deletions app/games/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@ import Link from "next/link";
import { games } from "./data/index";
import Filter from "../../components/Filter";

export default async function page({searchParams}) {

let filterUrl
if(searchParams?.filter){
filterUrl = `${process.env.NEXT_PUBLIC_BASE_URL}/api/games?filter=${searchParams.filter}`
}else{
filterUrl = `${process.env.NEXT_PUBLIC_BASE_URL}/api/games`
export default async function page({ searchParams }) {
let filterUrl;
if (searchParams?.filter) {
filterUrl = `${process.env.NEXT_PUBLIC_BASE_URL}/api/games?filter=${searchParams.filter}`;
} else {
filterUrl = `${process.env.NEXT_PUBLIC_BASE_URL}/api/games`;
}

const response = await fetch(`${filterUrl}`, {
method: "GET"
method: "GET",
});

const gameData = await response.json()
const gameData = await response.json();

const filterss = [{
name: 'FPS', value: 'fps'
}, {
name: 'Battle Royale', value: 'battle royale'
},{
name: "None", value: 'none'
}]
const filterss = [
{
name: "FPS",
value: "fps",
},
{
name: "Battle Royale",
value: "battle royale",
},
{
name: "None",
value: "none",
},
];

return (
<section className="px-[5%] xl:px-[12%] pt-10 pb-20 transition-all">
Expand Down
Loading

0 comments on commit b1413af

Please sign in to comment.