Overview
Creating a case involves defining the case properties (name, price, image) and configuring the items that can be won from the case along with their drop probabilities.Prerequisites
- Admin role assigned to your account
- Access to the admin panel at
/admin/create-case - Item images hosted and accessible via URLs
Case Creation Form
The case creation interface is located at:/home/daytona/workspace/source/app/admin/create-case/page.tsx
Step-by-Step Guide
Step 1: Access the Create Case Page
Navigate to the admin panel and select “Create New Case” or visit/admin/create-case directly.
The page will verify your admin status:
Step 2: Fill Case Details
Case Name
- Required: Yes
- Validation: Minimum 1 character
- Note: Will be used to generate a URL-friendly slug
Price
- Required: Yes
- Type: Number (decimal supported)
- Validation: Must be positive (≥ 0)
- Format: Use dollars/currency units (e.g., 9.99)
Description
- Required: No
- Type: Text (supports multiple lines)
- Use: Provide context about the case theme or contents
Image URL
- Required: Yes
- Validation: Must be a valid URL
- Format:
https://example.com/image.png - Recommended: Use a CDN or image hosting service
/home/daytona/workspace/source/components/admin/create-case-form.tsx:19-23
Step 3: Configure Case Items
Each case must have between 2-15 items.Item Properties
For each item, configure: Name- Item display name
- Required, minimum 1 character
- Item worth in currency units
- Must be ≥ 0
- Affects rarity perception
- Valid URL to item image
- Should be square format for best display
- Drop chance percentage
- Must be between 0-100
- Important: Total of all item probabilities must equal exactly 100%
/home/daytona/workspace/source/components/admin/create-case-form.tsx:12-17
Adding/Removing Items
Add Item: Click the “Agregar Ítem” button at the bottom of the items list- Minimum 2 items must remain
/home/daytona/workspace/source/components/admin/create-case-form.tsx:224-232
Step 4: Validate Probabilities
The form shows a real-time probability total:- Green indicator: Probabilities sum to 100% ✓
- Red indicator: Probabilities don’t sum to 100% ✗
/home/daytona/workspace/source/components/admin/create-case-form.tsx:69-71
Step 5: Submit the Form
Once all validations pass, click “Crear Caja” to submit.What Happens During Submission
- Client-side validation using Zod schema
- Server action receives the form data
- Admin role verification
- Slug generation from case name:
- Database transaction:
- Insert case into
casestable - Insert all items into
case_itemstable - If items fail, rollback case insertion
- Insert case into
- Audit log creation:
- Cache revalidation for
/casesroute
/home/daytona/workspace/source/app/actions/create-case.ts:34-136
Database Schema
Cases Table
/home/daytona/workspace/source/types/supabase.ts:44-72
Case Items Table
/home/daytona/workspace/source/types/supabase.ts:73-101
Validation Rules
The create case action enforces these rules:/home/daytona/workspace/source/app/actions/create-case.ts:14-26
Error Handling
Duplicate Case Name
If a case with the same slug already exists:/home/daytona/workspace/source/app/actions/create-case.ts:102-104
Transaction Rollback
If items fail to insert, the case is automatically deleted:/home/daytona/workspace/source/app/actions/create-case.ts:121-125
Best Practices
Probability Distribution
- Common items: 50-70% total
- Rare items: 20-30% total
- Legendary items: 1-10% total
Pricing Strategy
-
Calculate expected value:
- Set price slightly above expected value for sustainability
- Consider player psychology: Round numbers (9.99, 19.99) perform better
Image Guidelines
- Format: PNG or WebP for transparency
- Dimensions: Square (512x512 or 1024x1024)
- Optimization: Compress images to reduce load times
- CDN: Use a CDN for better performance
- Backup: Keep source images in case URLs change
Common Issues
Probabilities Don’t Sum to 100%
Problem: Submit button disabled, red indicator shows. Solution: Adjust item probabilities. The form requires exact 100% (within 0.01 tolerance).Invalid Image URL
Problem: Form validation fails with “URL inválida”. Solution: Ensure URLs:- Start with
http://orhttps:// - Point to actual image files
- Are publicly accessible
Duplicate Slug Error
Problem: Error message about existing case name. Solution:- Choose a different case name
- The slug is auto-generated from the name
- Names like “Dragon Lore” become “dragon-lore”
Example: Complete Case Creation
Next Steps
- Managing Items - Learn how to update and manage case items
- Monitoring - Track case creation in audit logs
- Admin Overview - Learn about roles and permissions
