Overview
The ViewCamera component serves as the detail view for individual cameras. It extracts the camera model from the URL parameters, filters the camera data from Redux state, and renders a comprehensive camera information card with navigation back to the listing.Component Structure
Props
This component does not accept any props. It retrieves data through URL parameters and Redux state.State Management
Redux Hooks
Retrieves the filtered camera data from the Redux store’s
camaras state. After filtering, expects a single-item array.Provides access to dispatch the
filterModelo action for filtering cameras by model.Router Hooks
Extracts the camera model parameter from the URL route. The model name is used to filter the camera data.
Lifecycle Behavior
On component mount, theuseEffect hook dispatches the filterModelo action with the model extracted from URL parameters:
Loading State
The component includes conditional rendering:- Loading: When
camara.length > 1, displays “loading…” - Loaded: When filtered to a single camera, renders the
CardCamaracomponent
CardCamara Subcomponent
The internalCardCamara component handles the detailed camera display:
CardCamara Props
The camera object containing all detailed specifications.
Camera model name displayed in the specifications.
Array of image URLs. The first image is displayed as the main product image.
Camera design type (e.g., “Bala”, “Domo”).
Camera resolution specification.
Connectivity options for the camera.
Physical dimensions of the camera.
Detailed text description of the camera’s features and capabilities.
Layout
The detail view uses a two-column Bootstrap layout:- Left column (col-lg-8): Large featured image centered with flexbox
- Right column (col-lg-4): Specifications, description, share button, and back button
Features
Product Image
Displays the first image from the camera’s image array with the model name as alt text.Specifications Display
Shows the following camera details:- Modelo (Model)
- Diseño (Design)
- Resolución (Resolution)
- Conectividad (Connectivity)
- Dimensiones (Dimensions)
- Descripción (Description)
Share Button
Includes a share button with Font Awesome icon (currently non-functional placeholder):Back Navigation
Provides a “Volver al listado” (Back to listing) button that uses React Router’snavigate(-1) to return to the previous page.
URL Pattern
The component expects to be rendered at the route::modelo is the camera model name parameter.
Usage Example
Dependencies
- React (useEffect hook)
- React Redux (useSelector, useDispatch hooks)
- React Router DOM (useParams, useNavigate, Link)
- Redux actions (filterModelo)
- Font Awesome (for share icon)
- Bootstrap CSS (for layout)