Skip to main content
The Redux actions are automatically generated by camarasSlice and provide type-safe ways to dispatch state changes. Use these actions to filter cameras and manage the application state.

Available Actions

filterCamara

Dispatches an action to filter the camera state by a specific camera ID.
payload
number
required
The unique ID of the camera you want to retrieve
Action Type: camaras/filterCamara
// Dispatch example
dispatch(filterCamara(5))

// Resulting action object:
// { type: 'camaras/filterCamara', payload: 5 }
Use Case: Use this action when you need to display details for a single camera, such as on a product detail page.

filterModelo

Dispatches an action to filter cameras by their model number.
payload
string
required
The camera model string to filter by (e.g., “IPC-TA42P-D”, “IPC-S41FP”)
Action Type: camaras/filterModelo
// Dispatch example
dispatch(filterModelo("IPC-F42FP-D-0280B"))

// Resulting action object:
// { type: 'camaras/filterModelo', payload: 'IPC-F42FP-D-0280B' }
Use Case: Use this action to find cameras with a specific model number, useful for inventory searches or model comparisons.

filterCamarasAside

Dispatches an action to apply multi-criteria filtering based on camera properties. This action supports both single and multiple filter values.
payload
array
required
Array of filter strings. Each string is matched against all camera properties after capitalization.
Action Type: camaras/filterCamarasAside
// Single filter example
dispatch(filterCamarasAside(["wifi"]))
// Returns cameras with conectividad: "Wifi"

// Multiple filters example (AND logic)
dispatch(filterCamarasAside(["exterior", "bullet", "4 mp"]))
// Returns cameras matching ALL three criteria

// Resulting action object:
// { type: 'camaras/filterCamarasAside', payload: ['exterior', 'bullet', '4 mp'] }
Filter Behavior:
Single Filter
array
Returns cameras where any property value matches the capitalized filter string
Multiple Filters
array
Returns cameras where ALL filter strings match at least one property value (AND logic)
Use Case: Use this action for sidebar filtering, advanced search interfaces, or category navigation where users select multiple criteria.

backToInitialState

Dispatches an action to reset the camera state to the complete original catalog. Action Type: camaras/backToInitialState
// Dispatch example
dispatch(backToInitialState())

// Resulting action object:
// { type: 'camaras/backToInitialState' }
Use Case: Use this action when clearing all filters, navigating back to the main catalog page, or resetting search results.

returnPreviousState

Dispatches an action that internally calls backToInitialState through case reducers. Action Type: camaras/returnPreviousState
// Dispatch example
dispatch(returnPreviousState())

// Resulting action object:
// { type: 'camaras/returnPreviousState' }
This action uses camarasSlice.caseReducers.backToInitialState() internally. Consider using backToInitialState directly for clearer intent.
Use Case: Internal utility action for state management workflows.

Importing Actions

Import actions from the slice exports:
const { 
  filterCamara, 
  filterModelo, 
  filterCamarasAside, 
  backToInitialState, 
  returnPreviousState 
} = camarasSlice.actions

Complete Workflow Example

Here’s how you might use these actions in a typical user workflow:
// 1. User opens the catalog (show all cameras)
dispatch(backToInitialState())

// 2. User filters by exterior cameras
dispatch(filterCamarasAside(["exterior"]))

// 3. User adds additional filter for 4MP resolution
dispatch(filterCamarasAside(["exterior", "4 mp"]))

// 4. User clicks on a specific camera model
dispatch(filterModelo("IPC-F42FP-D-0280B"))

// 5. User returns to full catalog
dispatch(backToInitialState())

Action Payloads Reference

filterCamara
number
Camera ID to filter
filterModelo
string
Camera model string
filterCamarasAside
array<string>
Array of filter criteria
backToInitialState
void
No payload required
returnPreviousState
any
Payload passed to internal reducer

Build docs developers (and LLMs) love