Skip to content

Commit fa85f2a

Browse files
moved event cards into a component
1 parent db1cb23 commit fa85f2a

3 files changed

Lines changed: 69 additions & 36 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import Link from "next/link";
2+
3+
import {
4+
Card,
5+
CardContent,
6+
CardDescription,
7+
CardFooter,
8+
CardHeader,
9+
CardTitle,
10+
} from "@/components/ui/card";
11+
12+
import type { Event } from "../../hooks/events";
13+
import { Button } from "./button";
14+
import TagList from "./tag-list";
15+
16+
interface EventCardProps {
17+
event: Event;
18+
}
19+
20+
export default function EventCard({ event }: EventCardProps) {
21+
return (
22+
<Card>
23+
<CardHeader className="p-3">
24+
<CardTitle>{event.event_name}</CardTitle>
25+
<CardDescription>{event.event_location}</CardDescription>
26+
</CardHeader>
27+
28+
<CardContent>
29+
<TagList tags={event.tags}></TagList>
30+
<p className="line-clamp-3 text-muted-foreground">
31+
{event.event_description}
32+
</p>
33+
</CardContent>
34+
35+
<CardFooter className="flex-end flex-row justify-center gap-2">
36+
<Link href={`/events/${event.id}`} className="w-full">
37+
<Button className="w-full rounded-full">View Details</Button>
38+
</Link>
39+
<Link href={`/events/${event.id}`}>
40+
<Button className="rounded-full">Signup</Button>
41+
</Link>
42+
</CardFooter>
43+
</Card>
44+
);
45+
}

client/src/components/ui/input.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as React from "react";
2+
3+
import { cn } from "@/lib/utils";
4+
5+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
6+
({ className, type, ...props }, ref) => {
7+
return (
8+
<input
9+
type={type}
10+
className={cn(
11+
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
12+
className,
13+
)}
14+
ref={ref}
15+
{...props}
16+
/>
17+
);
18+
},
19+
);
20+
Input.displayName = "Input";
21+
22+
export { Input };

client/src/pages/home.tsx

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
import Link from "next/link";
2-
3-
import TagList from "@/components/ui/tag-list";
1+
import EventCard from "@/components/ui/event-card";
42
import { useEvents } from "@/hooks/events";
53

6-
import { Button } from "../components/ui/button";
7-
import {
8-
Card,
9-
CardContent,
10-
CardDescription,
11-
CardFooter,
12-
CardHeader,
13-
CardTitle,
14-
} from "../components/ui/card";
154
import SearchDock from "../components/ui/search-dock";
165
import DockLayout from "./layouts/docklayout";
176

@@ -24,30 +13,7 @@ export default function Home() {
2413
<div className="mx-auto max-w-7xl space-y-3 px-4 py-6">
2514
{!isLoading &&
2615
events?.map((event) => (
27-
<Card key={event.id}>
28-
<CardHeader className="p-3">
29-
<CardTitle>{event.event_name}</CardTitle>
30-
<CardDescription>{event.event_location}</CardDescription>
31-
</CardHeader>
32-
33-
<CardContent>
34-
<TagList tags={event.tags}></TagList>
35-
<p className="line-clamp-3 text-muted-foreground">
36-
{event.event_description}
37-
</p>
38-
</CardContent>
39-
40-
<CardFooter className="flex-end flex-row justify-center gap-2">
41-
<Link href={`/events/${event.id}`} className="w-full">
42-
<Button className="w-full rounded-full">
43-
View Details
44-
</Button>
45-
</Link>
46-
<Link href={`/events/${event.id}`}>
47-
<Button className="rounded-full">Signup</Button>
48-
</Link>
49-
</CardFooter>
50-
</Card>
16+
<EventCard key={event.id} event={event}></EventCard>
5117
))}
5218
</div>
5319
</DockLayout>

0 commit comments

Comments
 (0)