AI Skill Report Card
Creating TypeScript Model Files
Quick Start15 / 15
TypeScriptimport { defaultPaginationValues } from '@/constants/pagination'; import useLoading from '@/hooks/use-loading'; import { updateArrayItem } from '@/utils/update-array-item'; import { message } from 'antd'; import { useState } from 'react'; import { createItemController, deleteItemController, getItemsController, updateItemController, } from './item.controller'; export default () => { const [items, setItems] = useState<App.Pagination<Entity.Item>>(defaultPaginationValues); const { loading, startLoading, stopLoading } = useLoading(); const getItems = async (...args: Parameters<typeof getItemsController>) => { try { startLoading(); const response = await getItemsController(...args); const { data } = response; setItems(data); } catch (error) { message.error('Não foi possível obter os dados'); return Promise.reject(); } finally { stopLoading(); } }; return { itemLoading: loading, items, getItems, }; };
Recommendation▾
Examples should show actual input/output pairs rather than just describing scenarios - show the actual controller interfaces and resulting complete model code
Workflow13 / 15
Progress:
- Analyze controller functions to determine available operations
- Determine if pagination is used (check controller return type)
- Identify parameter structure (no params, single param, multiple params)
- Set up appropriate state structure
- Implement CRUD functions based on available controllers
- Configure proper updateArrayItem usage for multi-parameter scenarios
Step 1: Analyze Controllers
Check which CRUD operations have corresponding controllers:
getController→ implement get functioncreateController→ implement create functionupdateController→ implement update functiondeleteController→ implement delete function
Step 2: Determine Data Structure
With Pagination:
TypeScriptconst [items, setItems] = useState<App.Pagination<EntityType>>(defaultPaginationValues);
Without Pagination:
TypeScriptconst [items, setItems] = useState<EntityType[]>([]);
Step 3: Implement CRUD Functions
Each function follows the pattern:
startLoading()- Call controller with spread args
- Update state appropriately
- Show success message (create/update/delete only)
- Handle errors with generic messages
stopLoading()in finally
Step 4: Handle updateArrayItem Parameters
No parameters (args[0] is ID):
TypeScriptidentification: args[0]
With parameters (args[1] is ID):
TypeScriptidentification: args[1]
Recommendation▾
Add concrete templates for the different patterns (with/without pagination, with/without parameters) as copy-paste ready code blocks
Examples12 / 20
Example 1: With Pagination, No Parameters Input: Controllers for getAreas, createArea, updateArea, deleteArea Output: Full CRUD model with pagination state management
Example 2: Without Pagination, No Parameters
Input: Controllers for getVersoes, createVersao, updateVersao, deleteVersao
Output: Array-based state management without pagination
Example 3: With Pagination and Parameters Input: Controllers with versao parameter in URL path Output: Proper args[1] usage in updateArrayItem for ID identification
Recommendation▾
Include the complete updateArrayItem implementation details and show exactly how count updates work for paginated delete operations
Best Practices
- Always use generic error messages: "Não foi possível obter os dados"
- Import required utilities at the top
- Use spread args pattern:
...args: Parameters<typeof controller> - Return Promise.resolve() on success, Promise.reject() on error
- Update state immutably using functional updates
- Use proper TypeScript typing for all state and parameters
Common Pitfalls
- Don't hardcode entity names in error messages
- Don't assume pagination exists - check controller return types
- Don't use wrong args index in updateArrayItem (args[0] vs args[1])
- Don't forget to handle count updates for paginated delete operations
- Don't implement functions for non-existent controllers
- Don't add success messages to GET operations