Skip to content

Commit

Permalink
feat: add hidden property to products
Browse files Browse the repository at this point in the history
  • Loading branch information
brolag committed Feb 23, 2025
1 parent b4ec33f commit ec1c918
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/web/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ model Product {
name String
price Float
nftMetadata Json
hidden Boolean? @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
shoppingCartItems ShoppingCartItem[]
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/app/_components/features/ProductList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function ProductList({ products }: ProductListProps) {
tokenId: product.tokenId,
name: product.name,
price: product.price,
hidden: false,
nftMetadata: JSON.stringify({
imageUrl: "/default-image.webp",
description: product.description,
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/app/_components/features/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type Product = {
name: string;
price: number;
nftMetadata: Prisma.JsonValue | NftMetadata;
hidden?: boolean | null;
process?: string;
createdAt: Date;
updatedAt: Date;
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/server/api/routers/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,24 @@ export const productRouter = createTRPCRouter({
z.object({
limit: z.number().min(1),
cursor: z.number().optional(),
includeHidden: z.boolean().optional().default(false),
}),
)
.query(async ({ input }) => {
const { limit, cursor } = input;
const { limit, cursor, includeHidden } = input;

const products = await db.product.findMany({
take: limit,
skip: cursor ? 1 : 0,
cursor: cursor ? { id: cursor } : undefined,
orderBy: { id: "asc" },
where: includeHidden
? undefined
: {
NOT: {
hidden: true,
},
},
});

const nextCursor =
Expand Down

0 comments on commit ec1c918

Please sign in to comment.