auth, trips and join trips
This commit is contained in:
+234
-57
@@ -1,65 +1,242 @@
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { tripService } from "@/server/services/trip.service";
|
||||
import { TripCard } from "@/features/trip/components/trip-card";
|
||||
import { SearchBar } from "@/features/trip/components/search-bar";
|
||||
|
||||
export default async function HomePage() {
|
||||
const trips = await tripService.getOpenTrips();
|
||||
|
||||
const now = new Date();
|
||||
const nextWeek = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
|
||||
|
||||
const upcomingTrips = trips.filter((t) => new Date(t.date) <= nextWeek);
|
||||
const budgetTrips = trips.filter((t) => t.price <= 300000).slice(0, 3);
|
||||
const latestTrips = trips.slice(0, 6);
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
|
||||
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/next.svg"
|
||||
alt="Next.js logo"
|
||||
width={100}
|
||||
height={20}
|
||||
priority
|
||||
/>
|
||||
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
|
||||
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
|
||||
To get started, edit the page.tsx file.
|
||||
<div className="relative min-h-screen bg-neutral-50">
|
||||
{/* ========== HERO ========== */}
|
||||
<section className="relative overflow-hidden bg-neutral-900">
|
||||
{/* Gradient overlay */}
|
||||
<div className="absolute inset-0 bg-linear-to-br from-primary-900/90 via-neutral-900/80 to-secondary-900/70" />
|
||||
|
||||
<div className="relative mx-auto max-w-4xl px-4 pb-16 pt-14 text-center">
|
||||
{/* Brand */}
|
||||
<div className="mb-6 inline-flex items-center gap-2 rounded-full border border-primary-400/30 bg-primary-600/20 px-4 py-1.5">
|
||||
<span className="text-sm">🏔️</span>
|
||||
<span className="text-sm font-medium text-primary-300">
|
||||
Open Trip Pendakian Gunung
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 className="mb-4 text-4xl font-extrabold leading-tight tracking-tight text-white sm:text-5xl">
|
||||
Se<span className="text-primary-400">Trip</span>
|
||||
</h1>
|
||||
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
||||
Looking for a starting point or more instructions? Head over to{" "}
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Templates
|
||||
</a>{" "}
|
||||
or the{" "}
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Learning
|
||||
</a>{" "}
|
||||
center.
|
||||
|
||||
<p className="mx-auto mb-3 max-w-lg text-lg font-medium text-neutral-300">
|
||||
Masa cowok sejati, cewek seimut nggak{" "}
|
||||
<span className="text-primary-400">SeTrip</span> bareng?
|
||||
</p>
|
||||
<p className="mx-auto mb-8 max-w-md text-neutral-400">
|
||||
Yuk mulai dari sini. Cari open trip pendakian, gabung bareng, nikmati
|
||||
petualangan ke gunung-gunung Jawa Barat.
|
||||
</p>
|
||||
|
||||
<SearchBar />
|
||||
|
||||
{/* Stats */}
|
||||
<div className="mt-10 flex justify-center gap-8 sm:gap-12">
|
||||
<div>
|
||||
<p className="text-2xl font-bold text-primary-400">
|
||||
{trips.length}
|
||||
</p>
|
||||
<p className="text-xs text-neutral-400">Trip Tersedia</p>
|
||||
</div>
|
||||
<div className="h-10 w-px bg-neutral-700" />
|
||||
<div>
|
||||
<p className="text-2xl font-bold text-secondary-400">8</p>
|
||||
<p className="text-xs text-neutral-400">Gunung Jabar</p>
|
||||
</div>
|
||||
<div className="h-10 w-px bg-neutral-700" />
|
||||
<div>
|
||||
<p className="text-2xl font-bold text-white">100%</p>
|
||||
<p className="text-xs text-neutral-400">Seru</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
className="dark:invert"
|
||||
src="/vercel.svg"
|
||||
alt="Vercel logomark"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Deploy Now
|
||||
</a>
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
</section>
|
||||
|
||||
{/* ========== CONTENT ========== */}
|
||||
<div className="mx-auto max-w-6xl px-4 py-10 space-y-12">
|
||||
{/* Trip Terdekat */}
|
||||
{upcomingTrips.length > 0 && (
|
||||
<section>
|
||||
<div className="mb-5 flex items-center gap-3">
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-primary-100 text-lg">
|
||||
🔥
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-lg font-bold text-neutral-800">
|
||||
Trip Terdekat
|
||||
</h2>
|
||||
<p className="text-xs text-neutral-500">
|
||||
Berangkat dalam 7 hari ke depan
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{upcomingTrips.slice(0, 3).map((trip) => (
|
||||
<TripCard
|
||||
key={trip.id}
|
||||
id={trip.id}
|
||||
title={trip.title}
|
||||
mountain={trip.mountain}
|
||||
location={trip.location}
|
||||
date={trip.date}
|
||||
price={trip.price}
|
||||
maxParticipants={trip.maxParticipants}
|
||||
participantCount={trip._count.participants}
|
||||
organizerName={trip.organizer.name}
|
||||
status={trip.status}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Open Trip */}
|
||||
<section>
|
||||
<div className="mb-5 flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-secondary-100 text-lg">
|
||||
🏔️
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-lg font-bold text-neutral-800">
|
||||
Open Trip
|
||||
</h2>
|
||||
<p className="text-xs text-neutral-500">
|
||||
Pendakian gunung bareng teman baru
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<Link
|
||||
href="/trips"
|
||||
className="rounded-lg bg-secondary-50 px-3 py-1.5 text-sm font-medium text-secondary-600 hover:bg-secondary-100"
|
||||
>
|
||||
Lihat semua
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{latestTrips.length === 0 ? (
|
||||
<div className="rounded-2xl border-2 border-dashed border-neutral-200 bg-white p-14 text-center">
|
||||
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary-50 text-3xl">
|
||||
🏕️
|
||||
</div>
|
||||
<p className="mb-1 text-lg font-bold text-neutral-800">
|
||||
Belum ada trip tersedia
|
||||
</p>
|
||||
<p className="mb-6 text-sm text-neutral-500">
|
||||
Jadilah yang pertama buat open trip pendakian!
|
||||
</p>
|
||||
<Link
|
||||
href="/create-trip"
|
||||
className="inline-block rounded-xl bg-primary-600 px-6 py-2.5 text-sm font-semibold text-white shadow-lg shadow-primary-600/25 hover:bg-primary-700"
|
||||
>
|
||||
+ Buat Trip Baru
|
||||
</Link>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{latestTrips.map((trip) => (
|
||||
<TripCard
|
||||
key={trip.id}
|
||||
id={trip.id}
|
||||
title={trip.title}
|
||||
mountain={trip.mountain}
|
||||
location={trip.location}
|
||||
date={trip.date}
|
||||
price={trip.price}
|
||||
maxParticipants={trip.maxParticipants}
|
||||
participantCount={trip._count.participants}
|
||||
organizerName={trip.organizer.name}
|
||||
status={trip.status}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* Budget Friendly */}
|
||||
{budgetTrips.length > 0 && (
|
||||
<section>
|
||||
<div className="mb-5 flex items-center gap-3">
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-primary-100 text-lg">
|
||||
💸
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-lg font-bold text-neutral-800">
|
||||
Budget Friendly
|
||||
</h2>
|
||||
<p className="text-xs text-neutral-500">
|
||||
Trip di bawah Rp 300.000
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{budgetTrips.map((trip) => (
|
||||
<TripCard
|
||||
key={trip.id}
|
||||
id={trip.id}
|
||||
title={trip.title}
|
||||
mountain={trip.mountain}
|
||||
location={trip.location}
|
||||
date={trip.date}
|
||||
price={trip.price}
|
||||
maxParticipants={trip.maxParticipants}
|
||||
participantCount={trip._count.participants}
|
||||
organizerName={trip.organizer.name}
|
||||
status={trip.status}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* CTA Bottom */}
|
||||
<section className="overflow-hidden rounded-2xl bg-neutral-800 p-8 text-center sm:p-12">
|
||||
<h2 className="mb-2 text-2xl font-bold text-white">
|
||||
Siap naik gunung?
|
||||
</h2>
|
||||
<p className="mx-auto mb-6 max-w-sm text-neutral-400">
|
||||
Buat trip sendiri atau gabung trip yang sudah ada. Seru bareng teman
|
||||
baru!
|
||||
</p>
|
||||
<div className="flex justify-center gap-3">
|
||||
<Link
|
||||
href="/create-trip"
|
||||
className="rounded-xl bg-primary-600 px-6 py-2.5 text-sm font-semibold text-white shadow-lg shadow-primary-600/25 hover:bg-primary-500"
|
||||
>
|
||||
Buat Trip
|
||||
</Link>
|
||||
<Link
|
||||
href="/trips"
|
||||
className="rounded-xl border border-neutral-600 px-6 py-2.5 text-sm font-semibold text-neutral-300 hover:border-neutral-500 hover:text-white"
|
||||
>
|
||||
Cari Trip
|
||||
</Link>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* ========== FAB ========== */}
|
||||
<Link
|
||||
href="/create-trip"
|
||||
className="fixed bottom-6 right-6 z-50 flex h-14 w-14 items-center justify-center rounded-full bg-primary-600 text-2xl font-bold text-white shadow-xl shadow-primary-600/30 transition-all hover:scale-110 hover:bg-primary-500 active:scale-95"
|
||||
title="Buat Trip"
|
||||
>
|
||||
+
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user