Files

72 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

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