Files

73 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

2026-01-22 11:14:21 -06:00
"use client";
import { useState } from "react";
import "./Selection.css";
2026-02-27 19:15:56 -06:00
import Image from "next/image";
2026-01-22 11:14:21 -06:00
2026-02-23 13:46:09 -06:00
export default function SelectionCo({
2026-01-22 11:14:21 -06:00
plataformasInscritas = [],
onSelect,
}: {
plataformasInscritas: string[];
onSelect: (plataforma: string | null) => void;
}) {
const [selected, setSelected] = useState<string | null>(null);
const options = [
{
name: "WINDOWS",
2026-01-23 19:34:03 -06:00
img: "/windows.png",
2026-01-22 11:14:21 -06:00
},
{
name: "MACINTOSH",
2026-03-02 11:46:56 -06:00
img: "/apple.png",
2026-01-22 11:14:21 -06:00
},
{
name: "PROFESORES",
2026-03-02 11:46:56 -06:00
img: "/teacher.png",
2026-01-22 11:14:21 -06:00
},
];
const opcionesInscritas = options.filter((option) =>
plataformasInscritas.includes(option.name),
);
const handleSelect = (optionName: string) => {
const value = selected === optionName ? null : optionName;
setSelected(value);
onSelect(value);
};
return (
<section className="selection">
{opcionesInscritas.map((option, index) => (
<div
key={index}
className="selectionItem"
onClick={() => handleSelect(option.name)}
>
<button
2026-02-27 19:15:56 -06:00
className={`buttonSelection ${selected === option.name ? "active" : ""
}`}
2026-01-22 11:14:21 -06:00
>
2026-02-27 19:15:56 -06:00
<div className="imageSelection">
<Image
src={option.img}
alt={option.name.toLowerCase()}
fill
/>
</div>
2026-01-22 11:14:21 -06:00
</button>
<span className="buttonLabel">{option.name}</span>
</div>
))}
{opcionesInscritas.length === 0 && (
<p style={{ opacity: 0.6 }}>
El alumno no está inscrito en ninguna plataforma
</p>
)}
</section>
);
}
2026-02-23 13:46:09 -06:00
//IO