Files
front-AT/app/Components/Selection/Selection.tsx
T
2026-02-27 19:15:56 -06:00

72 lines
1.7 KiB
TypeScript

"use client";
import { useState } from "react";
import "./Selection.css";
import Image from "next/image";
export default function Selection({
plataformasInscritas = [],
onSelect,
}: {
plataformasInscritas: string[];
onSelect: (plataforma: string | null) => void;
}) {
const [selected, setSelected] = useState<string | null>(null);
const handleSelect = (optionName: string) => {
const value = selected === optionName ? null : optionName;
setSelected(value);
onSelect(value);
};
const options = [
{
name: "WINDOWS",
img: "/windows.png",
},
{
name: "MACINTOSH",
img: "/apple.png",
},
{
name: "PROFESORES",
img: "/teacher.png",
},
];
const opcionesDisponibles = options.filter(
(option) => !plataformasInscritas.includes(option.name),
);
return (
<section className="selection">
{opcionesDisponibles.map((option, index) => (
<div
key={index}
className="selectionItem"
onClick={() => handleSelect(option.name)}
>
<button
className={`buttonSelection ${selected === option.name ? "active" : ""
}`}
>
<div className="imageSelection">
<Image
src={option.img}
alt={option.name.toLowerCase()}
fill
/>
</div>
</button>
<span className="buttonLabel">{option.name}</span>
</div>
))}
{opcionesDisponibles.length === 0 && (
<p style={{ opacity: 0.6 }}>
El alumno ya está inscrito en todas las plataformas
</p>
)}
</section>
);
}
//IO