Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

improve front page

Bill Yang5966bd3235af
diff --git a/client/src/app/components/AddSite.tsx b/client/src/app/components/AddSite.tsx
index 9d9ae4694..0324613d2 100644
--- a/client/src/app/components/AddSite.tsx
+++ b/client/src/app/components/AddSite.tsx
@@ -14,7 +14,13 @@ import { Label } from "../../components/ui/label";
import { Input } from "../../components/ui/input";
import { addSite, useGetSites } from "../../hooks/api";
import { Alert, AlertDescription, AlertTitle } from "../../components/ui/alert";
-import { AlertCircle, AppWindow, Building2 } from "lucide-react";
+import {
+ AlertCircle,
+ AppWindow,
+ Building2,
+ Plus,
+ PlusCircle,
+} from "lucide-react";
import { authClient } from "../../lib/auth";
import {
Select,
@@ -36,7 +42,13 @@ function isValidDomain(domain: string): boolean {
return domainRegex.test(domain);
}
-export function AddSite() {
+export function AddSite({
+ trigger,
+ disabled,
+}: {
+ trigger?: React.ReactNode;
+ disabled?: boolean;
+}) {
const { data: sites, refetch } = useGetSites();
const { data: organizations } = authClient.useListOrganizations();
@@ -98,7 +110,12 @@ export function AddSite() {
}}
>
<DialogTrigger asChild>
- <Button>Add Website</Button>
+ {trigger || (
+ <Button disabled={disabled}>
+ <Plus className="h-4 w-4" />
+ Add Website
+ </Button>
+ )}
</DialogTrigger>
<DialogContent className="max-w-lg">
<DialogHeader>
diff --git a/client/src/app/page.tsx b/client/src/app/page.tsx
index df5a903ad..2ccf234ca 100644
--- a/client/src/app/page.tsx
+++ b/client/src/app/page.tsx
@@ -33,72 +33,74 @@ export default function Home() {
refetchSites();
};
- // If the user has no organizations, show a welcome message with the option to create one
- if (hasNoOrganizations) {
- return (
- <div className="flex min-h-screen flex-col items-center justify-center p-4">
- <Card className="w-full max-w-md">
- <CardHeader className="text-center">
+ return (
+ <div className="flex min-h-screen flex-col pt-1">
+ <div className="flex justify-between items-center mb-4">
+ <div className="text-2xl font-bold">Websites</div>
+ <AddSite disabled={hasNoOrganizations} />
+ </div>
+
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
+ {/* Organization required message */}
+ {hasNoOrganizations && (
+ <Card className="col-span-full p-6 flex flex-col items-center text-center">
<div className="mx-auto w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mb-4">
<Building className="h-6 w-6 text-primary" />
</div>
- <CardTitle className="text-2xl">Welcome to Frogstats</CardTitle>
- <CardDescription>
+ <CardTitle className="mb-2 text-xl">
+ Organization Required
+ </CardTitle>
+ <CardDescription className="mb-6">
You need to create an organization before you add a website
</CardDescription>
- </CardHeader>
- <CardContent className="flex flex-col items-center">
- <p className="text-muted-foreground text-center mb-6">
- Organizations help you organize your websites and collaborate with
- your team.
- </p>
<Button
onClick={() => setCreateOrgDialogOpen(true)}
- className="w-full max-w-xs"
+ className="max-w-xs"
>
<Plus className="mr-2 h-4 w-4" />
Create an Organization
</Button>
- </CardContent>
- </Card>
-
- <CreateOrganizationDialog
- open={createOrgDialogOpen}
- onOpenChange={setCreateOrgDialogOpen}
- onSuccess={handleOrganizationCreated}
- />
- </div>
- );
- }
+ </Card>
+ )}
- // Otherwise, show the normal dashboard with sites
- return (
- <div className="flex min-h-screen flex-col pt-1">
- <div className="flex justify-between items-center mb-4">
- <div className="text-2xl font-bold">Websites</div>
- <AddSite />
- </div>
+ {/* Sites list */}
+ {!hasNoOrganizations &&
+ sites?.data?.map((site) => {
+ return (
+ <SiteCard
+ key={site.siteId}
+ siteId={site.siteId}
+ domain={site.domain}
+ />
+ );
+ })}
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
- {sites?.data?.map((site) => {
- return (
- <SiteCard
- key={site.siteId}
- siteId={site.siteId}
- domain={site.domain}
- />
- );
- })}
- {(!sites?.data || sites.data.length === 0) &&
+ {/* No websites message */}
+ {!hasNoOrganizations &&
+ (!sites?.data || sites.data.length === 0) &&
!userOrganizations.isPending && (
<Card className="col-span-full p-6 flex flex-col items-center text-center">
<CardTitle className="mb-2 text-xl">No websites yet</CardTitle>
- <CardDescription>
+ <CardDescription className="mb-4">
Add your first website to start tracking analytics
</CardDescription>
+ <AddSite
+ trigger={
+ <Button variant="success">
+ <Plus className="h-4 w-4" />
+ Add Website
+ </Button>
+ }
+ />
</Card>
)}
</div>
+
+ <CreateOrganizationDialog
+ open={createOrgDialogOpen}
+ onOpenChange={setCreateOrgDialogOpen}
+ onSuccess={handleOrganizationCreated}
+ />
</div>
);
}