diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index 9536def..99a8e8f 100644 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -29,5 +29,5 @@ docker build \ --build-arg RECAPTCHA_API_KEY="$RECAPTCHA_API_KEY" \ --build-arg NEXT_PUBLIC_RECAPTCHA_SITE_KEY="$NEXT_PUBLIC_RECAPTCHA_SITE_KEY" \ --build-arg NEXT_PUBLIC_NFT_IMAGE_REPOSITORY="$NEXT_PUBLIC_NFT_IMAGE_REPOSITORY" \ - --BUILD-ARG NEXT_PUBLIC_NFT_MARKETPLACE_URL="$NEXT_PUBLIC_NFT_MARKETPLACE_URL" \ + --build-arg NEXT_PUBLIC_NFT_MARKETPLACE_URL="$NEXT_PUBLIC_NFT_MARKETPLACE_URL" \ -t my-nextjs-app .. diff --git a/src/app/api/_data/blk-service.ts b/src/app/api/_data/blk-service.ts index bcf4fbc..080c666 100644 --- a/src/app/api/_data/blk-service.ts +++ b/src/app/api/_data/blk-service.ts @@ -98,12 +98,6 @@ export async function getConversationRates(): Promise { return result } -/* -export async function getNftById(nftId: string): Promise { - return fetchNftById(nftId) -} -*/ - // --------------------------------------------------------------------------------------------- async function getBalances(walletAddress: string): Promise { diff --git a/src/app/api/_data/data-service.ts b/src/app/api/_data/data-service.ts index 4168890..70afa64 100644 --- a/src/app/api/_data/data-service.ts +++ b/src/app/api/_data/data-service.ts @@ -179,57 +179,19 @@ export async function getWalletNfts(wallet: string): Promise return nfts } -export async function getNftById(nftId: number): Promise { +export async function getNftById(id: string): Promise { const client = await getClientPromise() const db = client.db(DB_CHATTERPAY_NAME) - const cursor: INFTDB[] | null = await db - .collection(SCHEMA_NFTS) - .aggregate([ - { - $match: { - id: nftId - } - }, - { - $project: { - _id: 1, // bddId - id: 1, // nftId - channel_user_id: 1, - wallet: 1, - trxId: 1, - metadata: 1 - } - } - ]) - .toArray() + const nft: INFT | null = await db.collection(SCHEMA_NFTS).findOne({ + id + }) - if (!cursor || cursor.length === 0) { + if (!nft) { return undefined } - const default_image_url = { - gcp: '/assets/images/nfts/default_nft.png', - ipfs: '/assets/images/nfts/default_nft.png', - icp: '/assets/images/nfts/default_nft.png' - } - - const nfts: INFT[] = cursor.map(({ _id, id, metadata, ...rest }) => { - const { image_url, ...metadataRest } = metadata || {} - const formatted_image_url = image_url || default_image_url - - return { - bddId: getFormattedId(_id), - nftId: id, - metadata: { - ...metadataRest, - image_url: formatted_image_url - }, - ...rest - } - }) - - return nfts + return nft } export async function getWalletNft(wallet: string, nftId: string): Promise { diff --git a/src/app/api/v1/nft/[id]/route.ts b/src/app/api/v1/nft/[id]/route.ts index d99a42e..33c8631 100644 --- a/src/app/api/v1/nft/[id]/route.ts +++ b/src/app/api/v1/nft/[id]/route.ts @@ -32,9 +32,11 @@ export async function GET(request: Request, { params }: { params: IParams }) { } try { - const response: INFT[] | undefined = await getNftById(parseInt(params.id, 10)) - if (response && response.length > 0 && response[0].metadata.image_url) { - return NextResponse.json(response[0]) + const nft: INFT | undefined = await getNftById(params.id) + console.log('3', params, nft) + + if (nft) { + return NextResponse.json(nft) } return new NextResponse(JSON.stringify(errorMessage), { diff --git a/src/sections/nfts/nft-item.tsx b/src/sections/nfts/nft-item.tsx index 3ff78f3..f569e0d 100644 --- a/src/sections/nfts/nft-item.tsx +++ b/src/sections/nfts/nft-item.tsx @@ -22,8 +22,8 @@ import { useTranslate } from 'src/locales' import { NFT_SHARE, UI_API_URL, - NFT_MARKETPLACE_URL, NFT_TRX_EXPLORER, + NFT_MARKETPLACE_URL, NFT_IMAGE_REPOSITORY } from 'src/config-global'