This repository was archived by the owner on Feb 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: seller view published items (#25)
- Loading branch information
Showing
13 changed files
with
160 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ItemCardList } from "@/components/item"; | ||
import { type Account } from "@/types"; | ||
import { ServerRequester } from "@/utils/requester/server"; | ||
import type { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "My Belongings", | ||
}; | ||
|
||
export default async function BelongingsPage() { | ||
const me = await new ServerRequester().get<Account | undefined>("/auth/me"); | ||
|
||
if (!me) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="min-h-[calc(100vh-64px)]"> | ||
<div className="space-y-4 mt-4 md:mt-8 mb-8"> | ||
<h1 className="font-bold text-3xl">My Belongings</h1> | ||
<p className="text-muted-foreground"> | ||
Here are the items you have listed for sale. | ||
</p> | ||
</div> | ||
<ItemCardList sellerId={me.id} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { SingleItemPreviewCard } from "./single-item-preview-card"; | ||
export { ItemCardListServer as ItemCardList } from "./item-card-list-server"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
services/web/src/components/item/item-card-list-server.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { ItemStatus, SingleItem } from "@/types"; | ||
import { ServerRequester } from "@/utils/requester/server"; | ||
import { ItemCardListClient } from "./item-card-list-client"; | ||
|
||
type Props = { | ||
limit?: number; | ||
type?: "single" | "pack"; | ||
status?: ItemStatus; | ||
sellerId?: number; | ||
}; | ||
|
||
export async function ItemCardListServer({ | ||
limit = 8, | ||
type, | ||
status, | ||
sellerId, | ||
}: Props) { | ||
const initialSearchParams = new URLSearchParams(); | ||
initialSearchParams.set("limit", String(limit)); | ||
if (type) { | ||
initialSearchParams.set("type", type); | ||
} | ||
if (status !== undefined) { | ||
initialSearchParams.set("status", String(status)); | ||
} | ||
if (sellerId) { | ||
initialSearchParams.set("seller_id", String(sellerId)); | ||
} | ||
|
||
const initialData = await new ServerRequester().get<{ | ||
items: SingleItem[]; | ||
count: number; | ||
nextCursor: string; | ||
}>(`/items?${initialSearchParams.toString()}`); | ||
|
||
return ( | ||
<ItemCardListClient | ||
initialData={initialData} | ||
initialSearchParams={initialSearchParams.toString()} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { SingleItem } from "@/types"; | ||
|
||
export type ItemListResponse = { | ||
items: SingleItem[]; | ||
count: number; | ||
nextCursor: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters