Open HumbertoTM10 opened 1 month ago
The changes introduce a new NFT service and related components to the application. This includes functions to fetch user NFTs from both a TRPC endpoint and the Starknet blockchain. A new React component, NFTCollectionPage
, displays the user's NFT collection, while the LoginPage
now fetches and shows NFTs as well. Additionally, a new API router for NFTs has been established, enhancing the backend functionality. The NFTCard
component has been updated to accommodate new properties for displaying NFT details.
Files | Change Summary |
---|---|
apps/web/src/app/api/nftService.ts |
Added functions fetchUserNFTs and fetchUserNFTsFromStarknet for fetching NFTs with error handling. |
apps/web/src/app/nfts/page.tsx |
Introduced NFTCollectionPage component to display user NFTs, including state management and loading status. |
apps/web/src/app/page.tsx |
Updated LoginPage to fetch and display NFTs, including state variables for NFTs and loading status. |
apps/web/src/server/api/root.ts |
Added nftRouter to the appRouter , integrating NFT-related routes. |
apps/web/src/server/api/routers/nft.ts |
Introduced nftRouter with the getUserNFTs procedure for fetching user NFTs from the blockchain. |
apps/web/src/utils/trpc.ts |
Created trpc.ts to facilitate TRPC integration with React Query. |
packages/ui/src/nftCard.tsx |
Updated NFTCard component to include new props for image URL and description, enhancing its display capabilities. |
🐇 In fields of code, we hop and play,
New NFTs bloom, brightening the day.
With cards that shine and collections to show,
Our digital treasures, in a vibrant flow.
Fetching and displaying, all in a dance,
Join us, dear friends, in this NFT romance! 🌼✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@HumbertoTM10 thanks for the improvements. In general the code is pretty self-explanatory. Can you please remove the unnecessary comments?
Let's use comments only when necessary, otherwise let's rely on clean code best practices to make it readable.
@brolag Removed unnecessary comments and made the suggestion to enhance error handling.
@HumbertoTM10 can you double check these missing conflict lines then run the build and the linter please?
@brolag Done, fixed the conflicts in page.tsx. Let me know if you need anything else.
Closes issue #13
Description
This PR introduces significant updates to the NFT collection UI and implements the logic for fetching user-specific NFTs from the blockchain.
Key changes include:
NFT Collection UI: Created a new NFTCollectionPage that displays the user's NFT collection using the NftCard component. The UI adapts to different screen sizes using a responsive grid.
Blockchain Integration: Added functionality to fetch user-specific NFTs from the blockchain using the fetchUserNFTs API call. The NFT data is loaded asynchronously and displayed within the UI. Loading states and error handling have also been implemented.
UI Enhancements: The NftCard component now supports displaying NFT images, titles, and descriptions.
These updates provide a more seamless user experience for interacting with NFTs, with a dynamic UI that displays user assets directly from the blockchain.
Checklist
Type of Change
Testing
Manual Testing
Ensure Blockchain Connection Verify that your blockchain connection is properly configured, and you have access to the wallet. Confirm that the StarkNet network is functioning correctly.
Run the Application Start the Next.js application using npm run dev or yarn dev. Navigate to the NFT collection page where the new UI is implemented.
Verify NFT Display UI Navigate to /nfts (or the route where the NFTCollectionPage is rendered). Check that the NFT collection page loads correctly and that the UI displays the page title “My NFT Collection”.
If the user owns NFTs, verify that the NFTs are displayed in a responsive grid. Each NFT card should show the title, image, and description of the NFT.
Test Loading State Ensure that while the NFTs are being fetched, a "Loading NFTs..." message is displayed.
Once the loading is complete, the NFTs should populate in the UI.
Test Empty State Log in with a wallet that does not own any NFTs.
Verify that the message "You don't own any NFTs yet" is displayed when no NFTs are returned.
Check Blockchain Integration Confirm that the correct NFTs are fetched from the blockchain for the connected user wallet.
Error Handling Simulate network errors or blockchain API issues (disconnecting or invalid responses).
Ensure that errors are caught and logged in the console without crashing the app. The loading state should stop, and the user should still see relevant UI feedback.
Automated Tests
Summary by CodeRabbit
Release Notes
New Features
NFTCollectionPage
component to display user NFTs in a grid format.LoginPage
to fetch and display NFTs upon user login.Improvements
NFTCard
component to show images and descriptions for each NFT.API Enhancements