Skip to content

Commit

Permalink
Merge pull request #28 from FGA0138-MDS-Ajax/server
Browse files Browse the repository at this point in the history
canais e times feito
  • Loading branch information
Jose1277 authored Jun 30, 2024
2 parents ca2970c + 189830d commit 2f344af
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 79 deletions.
Binary file removed projeto/client/app/favicon.ico
Binary file not shown.
34 changes: 0 additions & 34 deletions projeto/client/app/home/canais/Premiere/page.tsx

This file was deleted.

59 changes: 59 additions & 0 deletions projeto/client/app/home/canais/premiere/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use client';

import React, {useEffect, useState} from "react";
import { Bebas_Neue } from "next/font/google";
import { cn } from "@/lib/utils";
import {CardTimes} from "@/components/home/card-times";
import {Match} from "@/models/match";

const font = Bebas_Neue({
subsets: ["latin"],
weight: ["400"],
});

export default function Home() {
const [matches, setMatches] = useState<Match[]>([]);

useEffect(() => {
fetch("http://localhost:8000/api/v2/games/premiere")
.then(response => response.json())
.then(data => {
const matchInstances = data.map((matchData: any) => new Match(
matchData.campeonato,
matchData.data_hora,
matchData.time_1,
matchData.time_2,
matchData.channels
));
setMatches(matchInstances);
})
.catch(error => {
console.error('Erro ao buscar os dados:', error);
});
}, []);
return (
<main className="flex flex-col items-center justify-center flex-grow">
<img
src="https://upload.wikimedia.org/wikipedia/pt/thumb/a/a2/Logo_Premiere_FC_2018.png/1200px-Logo_Premiere_FC_2018.png"
alt="Premiere"
width={200}
height={200}
/>
<div className="space-y-6 text-center">
<h1
className={cn(
"text-6xl font-semibold text-white drop-shadow-md",
font.className
)}
>
Premiere
</h1>
<div className="grid grid-cols-2 gap-2">
{matches.map((match, index) => (
<CardTimes key={index} match={match} />
))}
</div>
</div>
</main>
);
}
14 changes: 13 additions & 1 deletion projeto/client/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@ const h2ClassName = "text-3xl font-semibold text-white drop-shadow-md";

const lib = new Match("Libertadores", "Sem Jogos", "", "", [""]);
const br = new Match("Brasileirão", "Sem Jogos", "", "", [""]);
const canais = ["Sportv", "Premiere", "Globo", "ESPN", "Disney+", "Paramount+"].sort();

export default function HomePage() {
const [favorito, setFavorito] = useState<string | undefined>();
const [rodada, setRodada] = useState<number>(0);
const [jogoBr, setJogoBr] = useState<Match>(br);
const [jogoLib, setJogoLib] = useState<Match>(lib);
const [canais, setCanais] = useState<string[]>([]);

const { data: session, status } = useSession();
const id = session?.user?.id;

useEffect(() => {
fetch("http://localhost:8000/api/v1/canais")
.then(response => response.json())
.then(data => {
setCanais(data);
})
.catch(error => {
console.error('Erro ao buscar os dados:', error);
});
}, []);

useEffect(() => {
if (id) {
Expand Down Expand Up @@ -99,6 +109,8 @@ export default function HomePage() {
}
}, [favorito]);



if (status === 'loading') {
return <div>Loading...</div>;
}
Expand Down
70 changes: 47 additions & 23 deletions projeto/client/app/home/timesBr/Flamengo/page.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
import React from 'react';
'use client';

import React, { useEffect, useState } from 'react';
import { Bebas_Neue } from 'next/font/google';
import { cn } from '@/lib/utils';
import { CardTimes } from "@/components/home/card-times";
import { Match } from "@/models/match";

const font = Bebas_Neue({
subsets: ['latin'],
weight: ['400'],
subsets: ['latin'],
weight: ['400'],
});

export default function Home() {
return (
<main className="flex flex-col items-center justify-center flex-grow">
<img src="https://logodetimes.com/times/flamengo/logo-flamengo-2048.png" alt="Flamengo" width={100} height={100} />
<div className="space-y-6 text-center">

<h1
className={cn(
'text-6xl font-semibold text-white drop-shadow-md',
font.className
)}
>
Flamengo
</h1>
<p className="text-lg text-black">
Chega de ficar se perguntando onde o jogo do seu time favorito será transmitido
</p>
</div>
</main>
const [matches, setMatches] = useState<Match[]>([]);

useEffect(() => {
fetch("http://localhost:8000/api/v1/games/flamengo")
.then(response => response.json())
.then(data => {
const matchInstances = data.map((matchData: any) => new Match(
matchData.campeonato,
matchData.data_hora,
matchData.time_1,
matchData.time_2,
matchData.channels
));
setMatches(matchInstances);
})
.catch(error => {
console.error('Erro ao buscar os dados:', error);
});
}, []);

);
}
return (
<main className="flex flex-col items-center justify-center flex-grow">
<img src="https://logodetimes.com/times/flamengo/logo-flamengo-2048.png" alt="Flamengo" width={100} height={100} />
<div className="space-y-6 text-center">
<h1
className={cn(
'text-6xl font-semibold text-white drop-shadow-md',
font.className
)}
>
Flamengo
</h1>
<div className="grid grid-cols-2 gap-2">
{matches.map((match, index) => (
<CardTimes key={index} match={match} />
))}
</div>
</div>
</main>
);
}
7 changes: 4 additions & 3 deletions projeto/client/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Onde é o jogo",
description: "Listagem dos canais de trasmissão dos jogos dos campeonatos Libertadores e Brasileirão",

};

export default function RootLayout({
Expand All @@ -17,9 +18,9 @@ export default function RootLayout({
}>) {
return (
<html lang="pt-br">
<body className={inter.className}>
<ClientSessionProvider>{children}</ClientSessionProvider>
</body>
<body className={inter.className}>
<ClientSessionProvider>{children}</ClientSessionProvider>
</body>
</html>
);
}
44 changes: 34 additions & 10 deletions projeto/client/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
'use client';

import Image from 'next/image';
import { usePathname } from 'next/navigation';
import { HomeButton } from '@/components/auth/home-button';

const Navbar = () => {
const pathname = usePathname();

if (pathname === "/home") {
return (
<nav className="bg-[#005B14] p-3 relative">
<div className="container mx-auto flex justify-between items-center">
<div className="container mx-auto flex justify-center items-center">
<a href={"/"}>
<Image
src="/logoss.png" alt="Logo" width={120} height={120} />
</a>
</div>
<div className="absolute right-8 top-5 bg-transparent text-black hover:bg-gray-200 text-lg font-semibold py-2 px-4 rounded-lg">
</div>
</div>
</nav>
);
}

return (
<nav className="bg-[#005B14] p-3 relative">
<div className="container mx-auto flex justify-between items-center">
<div className="container mx-auto flex justify-center items-center">
<Image src="/logoss.png" alt="Logo" width={120} height={120} />
<nav className="bg-[#005B14] p-3 relative">
<div className="container mx-auto flex justify-between items-center">
<div className="container mx-auto flex justify-center items-center">
<a href={"/"}>
<Image
src="/logoss.png" alt="Logo" width={120} height={120} />
</a>
</div>
<div className="absolute right-8 top-5 bg-transparent text-black hover:bg-gray-200 text-lg font-semibold py-2 px-4 rounded-lg">
<HomeButton mode="redirect">Home</HomeButton>
</div>
</div>
<div className="absolute right-8 top-5 bg-transparent text-black hover:bg-gray-200 text-lg font-semibold py-2 px-4 rounded-lg">
<HomeButton mode="redirect">Home</HomeButton>
</div>
</div>
</nav>
</nav>
);
};

export default Navbar;

13 changes: 8 additions & 5 deletions projeto/client/components/home/card-canais.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ export const CardCanais = ({ canais }: CardCanaisProps) => {
<CardContent className="flex justify-center">
<div className="flex gap-8">
{canais.sort().map((canal, index) => (
<div key={index} className="flex flex-col items-center justify-center px-2">
<div className="h-24 flex items-center justify-center">
<Image src={`/${canal}.png`} alt={canal} width={100} height={100} />
// eslint-disable-next-line react/jsx-key
<a href={`/home/canais/${canal.toLowerCase()}`}>
<div key={index} className="flex flex-col items-center justify-center px-2">
<div className="h-24 flex items-center justify-center">
<Image src={`/${canal}.png`} alt={canal} width={100} height={100} />
</div>
<span className="mt-2">{canal}</span>
</div>
<span className="mt-2">{canal}</span>
</div>
</a>
))}
</div>
</CardContent>
Expand Down
6 changes: 3 additions & 3 deletions projeto/client/components/home/card-times.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card_custom"
} from "@/components/ui/card_custom";

import { Match } from "@/models/match";

Expand Down Expand Up @@ -38,8 +38,8 @@ export const CardTimes = ({ match }: CardTimesProps) => {
<CardFooter className="flex space-x-2 justify-center">
{match.channels.map((channel, index) => (
<span key={index} className="channel-item">
{channel}
</span>
{channel}
</span>
))}
</CardFooter>
</Card>
Expand Down
Binary file added projeto/client/public/favicon.ico
Binary file not shown.
10 changes: 10 additions & 0 deletions projeto/server/src/repositories/api.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ class GameRepository {
}
}

async getCanais(): Promise<string[]> {
try {
const [response]: [any[], any[]] = await mysqlConn.execute("SELECT NOME_CANAL FROM CANAL");
return response.map((canal: any) => canal.NOME_CANAL);
} catch (error) {
console.error(error);
return [];
}
}

}

export default new GameRepository();
9 changes: 9 additions & 0 deletions projeto/server/src/routes/api.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,13 @@ router.get('/v1/games/liberta/:favorito', async (req, res) => {
}
});

router.get('/v1/canais', async (req, res) => {
try {
const canais = await GameRepository.getCanais();
res.send(canais);
} catch (error) {
res.status(500).send(error);
}
});

export default router;

0 comments on commit 2f344af

Please sign in to comment.