-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix pictures in seeder & add carousel home page & add api to get even…
…t for a user
- Loading branch information
Showing
14 changed files
with
610 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
import TopBar from "@/components/TopBar"; | ||
import UserEventsFeed from "@/components/UserEventsFeed"; | ||
|
||
export default function Home() { | ||
return <main className=""></main>; | ||
return ( | ||
<> | ||
<TopBar /> | ||
<div className="mt-8"> | ||
<h1 className="text-center text-3xl font-bold">Mes événements</h1> | ||
<UserEventsFeed /> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { handleException } from "@/app/utils/errorHandlerUtils"; | ||
import { getEventsByUserId } from "@/services/userService"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
/** | ||
* @param req | ||
* @returns NextResponse | ||
* @description Handles GET request to retrieve all events for a specific user. | ||
*/ | ||
export async function GET( | ||
request: NextRequest, | ||
{ params }: { params: { id: string } }, | ||
) { | ||
try { | ||
const userId = Number(params.id); | ||
|
||
if (!userId) { | ||
return NextResponse.json( | ||
{ error: "User ID is required" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
const result = await getEventsByUserId(userId); | ||
return NextResponse.json({ data: result }, { status: 200 }); | ||
} catch (error) { | ||
return handleException(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"use client"; | ||
import { | ||
Carousel, | ||
CarouselContent, | ||
CarouselItem, | ||
CarouselNext, | ||
CarouselPrevious, | ||
} from "./ui/carousel"; | ||
import { Card, CardHeader, CardTitle } from "@/components/ui/card"; | ||
import { Event } from "@prisma/client"; | ||
import Image from "next/image"; | ||
|
||
type EventUserCarouselProps = { | ||
events: Event[]; | ||
}; | ||
|
||
const EventUserCarousel: React.FC<EventUserCarouselProps> = ({ events }) => { | ||
return ( | ||
<Carousel className="w-full max-w-sm"> | ||
<CarouselContent className="-ml-1 flex"> | ||
{events.map((event) => ( | ||
<CarouselItem key={event.id} className="flex-none basis-1/3 pl-1"> | ||
<div className="p-1"> | ||
<Card> | ||
{event.image && ( | ||
<Image | ||
src={event.image} | ||
alt={event.title} | ||
className="h-32 w-full rounded-t-lg object-cover" | ||
width={320} | ||
height={180} | ||
/> | ||
)} | ||
<CardHeader> | ||
<CardTitle>{event.title}</CardTitle> | ||
</CardHeader> | ||
</Card> | ||
</div> | ||
</CarouselItem> | ||
))} | ||
</CarouselContent> | ||
<CarouselPrevious /> | ||
<CarouselNext /> | ||
</Carousel> | ||
); | ||
}; | ||
|
||
export default EventUserCarousel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getEventsByUserId } from "@/services/userService"; | ||
import EventUserCarousel from "./EventUserCarousel"; | ||
import { Event } from "@prisma/client"; | ||
|
||
async function fetchUserEvents(userId: number): Promise<Event[]> { | ||
try { | ||
const events = await getEventsByUserId(userId); | ||
return events; | ||
} catch (error) { | ||
console.error("Error fetching user events:", error); | ||
throw error; | ||
} | ||
} | ||
|
||
const UserEventsFeed = async () => { | ||
const events = await fetchUserEvents(7); | ||
console.log(events); | ||
return ( | ||
<div className="mt-4 flex flex-col items-center justify-center"> | ||
<EventUserCarousel events={events} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UserEventsFeed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { cn } from "@/lib/tailwindUtils"; | ||
import * as React from "react"; | ||
|
||
const Card = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("rounded-lg border bg-white text-black shadow-sm", className)} | ||
{...props} | ||
/> | ||
)); | ||
Card.displayName = "Card"; | ||
|
||
const CardHeader = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex flex-col space-y-1.5 p-6", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardHeader.displayName = "CardHeader"; | ||
|
||
const CardTitle = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLHeadingElement> | ||
>(({ className, ...props }, ref) => ( | ||
<h3 | ||
ref={ref} | ||
className={cn( | ||
"text-2xl font-semibold leading-none tracking-tight", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
CardTitle.displayName = "CardTitle"; | ||
|
||
const CardDescription = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLParagraphElement> | ||
>(({ className, ...props }, ref) => ( | ||
<p | ||
ref={ref} | ||
className={cn("text-sm text-muted-foreground", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardDescription.displayName = "CardDescription"; | ||
|
||
const CardContent = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> | ||
)); | ||
CardContent.displayName = "CardContent"; | ||
|
||
const CardFooter = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex items-center p-6 pt-0", className)} | ||
{...props} | ||
/> | ||
)); | ||
CardFooter.displayName = "CardFooter"; | ||
|
||
export { | ||
Card, | ||
CardHeader, | ||
CardFooter, | ||
CardTitle, | ||
CardDescription, | ||
CardContent, | ||
}; |
Oops, something went wrong.