import React, { useState } from "react"; import styles from "./Carousel.module.css"; // Import CSS module const Carousel = ({ selectedIndex, items, onSelect }) => { const moveToNext = () => { console.log('aa') if (selectedIndex < items.length - 1) { console.log('bb') onSelect(selectedIndex + 1); // Send the next index to the parent } }; const moveToPrev = () => { if (selectedIndex > -1) { onSelect(selectedIndex - 1); // Send the previous index to the parent } }; return (
{/* Previous Item */}
0 ? "hidden" : "visible" , backgroundColor: items.length < 1 ? '#919191':'#007bff'}} > {selectedIndex === -1 ? (items.length > 0 ? "+" : "") : items[selectedIndex - 1]?.name || "+"}
{/* Current Item */}
{selectedIndex >= 0 ? items[selectedIndex]?.name : "+"}
{/* Next Item */}
0 ? "hidden" : "visible", backgroundColor: items.length < 1 ? '#919191':'#007bff' }} > {selectedIndex < items.length - 1 && items[selectedIndex + 1]?.name}
); }; export default Carousel;