| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- import { Head, Link } from '@inertiajs/react';
- import { Plus, Store as StoreIcon } from 'lucide-react';
- import { Badge } from '@/components/ui/badge';
- import { Button } from '@/components/ui/button';
- import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- } from '@/components/ui/card';
- import { dashboard } from '@/routes';
- import { create, show } from '@/routes/stores';
- import type { Store } from '@/types';
-
- export default function Dashboard({ stores }: { stores: Store[] }) {
- return (
- <>
- <Head title="Dashboard" />
-
- <div className="flex h-full flex-1 flex-col gap-6 p-4">
- <div className="flex flex-wrap items-center justify-between gap-4">
- <div>
- <h1 className="text-xl font-semibold">Your stores</h1>
- <p className="text-sm text-muted-foreground">
- Create a store, then let AI design it for you.
- </p>
- </div>
-
- {stores.length > 0 && (
- <Button asChild>
- <Link href={create()}>
- <Plus />
- Create store
- </Link>
- </Button>
- )}
- </div>
-
- {stores.length === 0 ? (
- <div className="flex flex-1 flex-col items-center justify-center gap-4 rounded-xl border border-dashed p-10 text-center">
- <div className="flex size-12 items-center justify-center rounded-full bg-muted">
- <StoreIcon className="size-6 text-muted-foreground" />
- </div>
- <div>
- <h2 className="font-medium">No stores yet</h2>
- <p className="mt-1 max-w-sm text-sm text-muted-foreground">
- Tell us about your brand and we will set up your
- first online store.
- </p>
- </div>
- <Button asChild>
- <Link href={create()}>
- <Plus />
- Create your first store
- </Link>
- </Button>
- </div>
- ) : (
- <div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
- {stores.map((store) => (
- <Link
- key={store.id}
- href={show(store.slug)}
- className="rounded-xl focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none"
- >
- <Card className="h-full transition-colors hover:bg-accent/40">
- <CardHeader>
- <div className="flex items-start justify-between gap-3">
- <CardTitle className="leading-snug">
- {store.name}
- </CardTitle>
- <Badge
- variant={
- store.status === 'published'
- ? 'default'
- : 'secondary'
- }
- >
- {store.status_label}
- </Badge>
- </div>
- <CardDescription>
- {store.category_label}
- </CardDescription>
- </CardHeader>
- <CardContent>
- <p className="line-clamp-3 text-sm text-muted-foreground">
- {store.description}
- </p>
- </CardContent>
- </Card>
- </Link>
- ))}
- </div>
- )}
- </div>
- </>
- );
- }
-
- Dashboard.layout = {
- breadcrumbs: [
- {
- title: 'Dashboard',
- href: dashboard(),
- },
- ],
- };
|