Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ export default [
route("/api/insights", "routes/api.insights.ts"),
route("/api/export/tax", "routes/api.export.tax.ts"),
route("/api/inventory/search", "routes/api.inventory.search.ts"),
route("/:username", "routes/$username.tsx"),
route("/api/integrations", "routes/api.integrations.ts"),
] satisfies RouteConfig;
68 changes: 68 additions & 0 deletions app/routes/$username.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { useLoaderData } from "react-router";
import type { Route } from "./+types/$username";
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export async function loader({ params }: Route.LoaderArgs) {
const { username } = params;

const user = await prisma.user.findUnique({
where: { username },
select: { id: true, name: true, username: true, avatarUrl: true },
});

if (!user) throw new Response("Not Found", { status: 404 });

const items = await prisma.inventoryItem.findMany({
where: { userId: user.id, isPublic: true },
select: {
id: true,
name: true,
brand: true,
sku: true,
size: true,
condition: true,
status: true,
askingPrice: true,
imageUrl: true,
category: true,
tags: true,
},
orderBy: { createdAt: "desc" },
});

return {
user,
items: items.map((item) => ({
...item,
askingPrice: item.askingPrice ? Number(item.askingPrice) : null,
})),
};
}

export default function PublicShowroom() {
const { user, items } = useLoaderData<typeof loader>();

return (
<div style={{ maxWidth: 900, margin: "0 auto", padding: "2rem" }}>
<h1>{user.name ?? user.username}&apos;s Showroom</h1>
{items.length === 0 ? (
<p>No items listed for sale.</p>
) : (
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(220px, 1fr))", gap: "1rem" }}>
{items.map((item) => (
<div key={item.id} style={{ border: "1px solid var(--color-border)", borderRadius: 8, padding: "1rem" }}>
{item.imageUrl && <img src={item.imageUrl} alt={item.name} style={{ width: "100%", borderRadius: 4 }} />}
<h3 style={{ margin: "0.5rem 0 0.25rem" }}>{item.name}</h3>
<p style={{ margin: 0, fontSize: 14, color: "var(--color-text-muted)" }}>{item.brand} · {item.size}</p>
<p style={{ margin: "0.5rem 0 0", fontWeight: 600 }}>
{item.askingPrice ? `$${item.askingPrice.toFixed(2)}` : "Price on request"}
</p>
</div>
))}
</div>
)}
</div>
);
}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Add username to User model
ALTER TABLE "User" ADD COLUMN "username" TEXT;
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");

-- Add isPublic to InventoryItem model
ALTER TABLE "InventoryItem" ADD COLUMN "isPublic" BOOLEAN NOT NULL DEFAULT false;
42 changes: 22 additions & 20 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,27 @@ enum Theme {
// ─── CORE MODELS ──────────────────────────────────────────────────────────────

model User {
id String @id @default(uuid())
email String @unique
name String?
avatarUrl String?
plan Plan @default(FREE)
stripeCustomerId String? @unique
stripeSubId String? @unique
currency Currency @default(USD)
theme Theme @default(LIGHT)
phone String?
pushEndpoint String? // Web push subscription JSON
emailNotifications Boolean @default(true)
smsNotifications Boolean @default(false)
pushNotifications Boolean @default(false)
weeklySummary Boolean @default(true)
priceAlertTriggered Boolean @default(true)
teamId String?
role String @default("owner") // owner | member (team)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id String @id @default(uuid())
email String @unique
username String? @unique
name String?
avatarUrl String?
plan Plan @default(FREE)
stripeCustomerId String? @unique
stripeSubId String? @unique
currency Currency @default(USD)
theme Theme @default(LIGHT)
phone String?
pushEndpoint String? // Web push subscription JSON
emailNotifications Boolean @default(true)
smsNotifications Boolean @default(false)
pushNotifications Boolean @default(false)
weeklySummary Boolean @default(true)
priceAlertTriggered Boolean @default(true)
teamId String?
role String @default("owner") // owner | member (team)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

inventory InventoryItem[]
sales Sale[]
Expand Down Expand Up @@ -168,6 +169,7 @@ model InventoryItem {
askingPrice Decimal? @db.Decimal(10, 2)
notes String?
imageUrl String?
isPublic Boolean @default(false)
currency Currency @default(USD)
tags String[] // flexible tags
createdAt DateTime @default(now())
Expand Down
Loading