AI Skill Report Card

Creating TypeScript Model Files

B+78·May 6, 2026·Source: Web
15 / 15
TypeScript
import { 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
13 / 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 function
  • createController → implement create function
  • updateController → implement update function
  • deleteController → implement delete function

Step 2: Determine Data Structure

With Pagination:

TypeScript
const [items, setItems] = useState<App.Pagination<EntityType>>(defaultPaginationValues);

Without Pagination:

TypeScript
const [items, setItems] = useState<EntityType[]>([]);

Step 3: Implement CRUD Functions

Each function follows the pattern:

  1. startLoading()
  2. Call controller with spread args
  3. Update state appropriately
  4. Show success message (create/update/delete only)
  5. Handle errors with generic messages
  6. stopLoading() in finally

Step 4: Handle updateArrayItem Parameters

No parameters (args[0] is ID):

TypeScript
identification: args[0]

With parameters (args[1] is ID):

TypeScript
identification: args[1]
Recommendation
Add concrete templates for the different patterns (with/without pagination, with/without parameters) as copy-paste ready code blocks
12 / 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
  • 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
  • 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
0
Grade B+AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
15/15
Workflow
13/15
Examples
12/20
Completeness
11/20
Format
15/15
Conciseness
12/15