Skip to content

ISSUE-CU06-003: Implement UI-Contract for Claiming PrizesΒ #548

@davidmelendez

Description

@davidmelendez

ISSUE-CU06-003: Implement UI-Contract for Claiming Prizes

✨ Issue Request

Implement the complete user interface for the prize claiming functionality (CU-06), allowing players to visualize their tickets with assigned prizes and execute the claim transaction from the frontend in an intuitive and secure manner.

πŸ“Œ Description

This issue focuses exclusively on the frontend implementation for use case CU-06 "Claim Prize". The smart contract functionality must be implemented previously (see SL-CU06-001).

We need to implement:

  1. Prize Claiming Page (/claim-prizes)

    • Display user's ticket list with assigned prizes
    • Filter only tickets with prize_assigned = true and claimed = false
    • Responsive and modern design
  2. UI Components

    • Ticket cards with detailed information
    • "Claim prize" button with dynamic states
    • Success/error notifications
    • Loading states during transactions
  3. Starknet Integration

    • Connection with wallet (Argent/Braavos)
    • Execute ClaimPrize transaction
    • Automatic UI update after claiming
    • Contract error handling
  4. Custom Hooks

    • Hook to get claimable tickets
    • Hook to execute claim
    • Hook to verify transaction status

πŸ› οΈ Steps to Reproduce (if applicable)

Current context:

  1. No prize claiming page exists in frontend
  2. Users cannot visualize their assigned prizes
  3. No integration with contract's ClaimPrize function
  4. No reusable components to display tickets with prizes

πŸ–ΌοΈ Screenshots (if applicable)

Not applicable - new functionality to implement.

Suggested design references:

  • Existing profile page for style consistency
  • Dashboard with ticket cards
  • Scaffold-Stark components for common patterns

🎯 Expected Behavior

The implementation must meet the following requirements:

Main Page (/claim-prizes):

  1. πŸ”Ή Display title "Claim Prizes"
  2. πŸ”Ή Verify wallet connection (show message if not connected)
  3. πŸ”Ή Get all finalized draws with distribution_done = true
  4. πŸ”Ή For each draw, get user's tickets with prizes
  5. πŸ”Ή Display list of claimable ticket cards
  6. πŸ”Ή Show message if no prizes available
  7. πŸ”Ή Loading skeleton while loading data
  8. πŸ”Ή Responsive design (mobile, tablet, desktop)

ClaimPrizeCard Component:

  1. πŸ”Ή Display draw ID and date
  2. πŸ”Ή Display ticket numbers (e.g., "5 - 12 - 23 - 34 - 40")
  3. πŸ”Ή Display prize amount in STRKP with formatting
  4. πŸ”Ή Display match level (1-4 matches)
  5. πŸ”Ή "Claim" button with states:
    • Enabled: Prize available
    • Disabled: Already claimed or no prize
    • Loading: Transaction in progress
  6. πŸ”Ή Status badge (Available / Claimed)
  7. πŸ”Ή Attractive design with theme colors

Wallet Integration:

  1. πŸ”Ή Detect connected wallet
  2. πŸ”Ή Get user address
  3. πŸ”Ή Execute ClaimPrize transaction on click
  4. πŸ”Ή Show wallet confirmation modal
  5. πŸ”Ή Wait for transaction confirmation
  6. πŸ”Ή Automatically update UI after confirming

Notifications and UX:

  1. πŸ”Ή Success toast with block explorer link
  2. πŸ”Ή Error toast with descriptive message
  3. πŸ”Ή Loading spinner in button during transaction
  4. πŸ”Ή Disable button after claiming
  5. πŸ”Ή Clear visual feedback at each step
  6. πŸ”Ή Contract error handling (translate Cairo errors)

Navigation:

  1. πŸ”Ή Add link in main menu
  2. πŸ”Ή Badge with number of available prizes (optional)
  3. πŸ”Ή Accessible route: /claim-prizes or /profile/claim-prizes

πŸš€ Suggested Solution / Feature Request

File Structure

packages/nextjs/
β”œβ”€β”€ app/
β”‚   └── claim-prizes/
β”‚       └── page.tsx                    # Main page
β”œβ”€β”€ components/
β”‚   └── claim-prizes/
β”‚       β”œβ”€β”€ ClaimPrizeCard.tsx         # Individual card
β”‚       β”œβ”€β”€ ClaimPrizesList.tsx        # Card list
β”‚       └── EmptyClaimState.tsx        # Empty state
└── hooks/
    └── scaffold-stark/
        β”œβ”€β”€ useClaimablePrizes.ts      # Hook to get prizes
        └── useClaimPrize.ts           # Hook to claim

Implementation

[Same code examples as Spanish version above]

πŸ“Œ Additional Notes

Issue Dependencies:

  • SL-CU06-001: Contract's ClaimPrize function must be implemented
  • Deployed Contract: Must be in deployedContracts.ts
  • Wallet: User must have connected wallet (Argent/Braavos)

UX Considerations:

  • Loading States: Show skeletons while loading
  • Error Handling: Translate technical errors to friendly messages
  • Visual Feedback: Clear success/error confirmations
  • Responsiveness: Functional on mobile, tablet and desktop
  • Accessibility: Use semantic HTML and ARIA labels

Internationalization:

  • Consider adding translations (i18n)
  • Support Spanish and English
  • Format numbers according to locale

Performance:

  • Paginate prize list if many
  • Lazy loading of heavy components
  • Optimize re-renders with React.memo

Testing (Manual):

  1. βœ… Connect wallet and verify prizes load
  2. βœ… Click "Claim" and sign transaction
  3. βœ… Verify success notification
  4. βœ… Verify button disables after claiming
  5. βœ… Verify responsive on mobile
  6. βœ… Test with wallet without prizes (empty state)
  7. βœ… Test errors (no funds, already claimed, etc.)

⚠️ Before Applying

Please read this guide: Contributor Guidelines

Definition of Done:

  • Page /claim-prizes created and functional
  • Components ClaimPrizeCard, ClaimPrizesList, EmptyClaimState implemented
  • Hook useClaimablePrizes working correctly
  • Integration with wallet (Argent/Braavos) operational
  • Transaction ClaimPrize executing correctly
  • Success/error notifications implemented
  • Responsive design (mobile, tablet, desktop)
  • Link added in main menu
  • Contract error handling translated
  • Manual testing completed
  • Code formatted with yarn format
  • Successful build with yarn build

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions