import { Module } from "@/interfaces"; import clsx from "clsx"; import { ReactNode, useEffect, useState } from "react"; import { MdDelete, MdEdit, MdEditOff, MdRefresh, MdSave, MdSignalCellularAlt } from "react-icons/md"; import { HiOutlineClipboardCheck, HiOutlineClipboardList } from "react-icons/hi"; import { Difficulty } from "@/interfaces/exam"; import Option from "@/interfaces/option"; import ReactSelect, { components } from "react-select"; interface Props { title: string; description: string; editing: boolean; difficulty?: Difficulty; saveDifficulty?: (diff: Difficulty) => void; module?: Module; handleSave: () => void; handleDiscard: () => void; handleDelete?: () => void; handlePractice?: () => void; handleEdit?: () => void; isEvaluationEnabled?: boolean; children?: ReactNode; } const Header: React.FC = ({ title, description, editing, difficulty, saveDifficulty, isEvaluationEnabled, handleSave, handleDiscard, handleDelete, handleEdit, handlePractice, children, module }) => { const DIFFICULTIES: Difficulty[] = ["A1", "A2", "B1", "B2", "C1", "C2"]; const difficultyOptions: Option[] = DIFFICULTIES.map(level => ({ label: level, value: level })); return (

{title}

{description}

{handleEdit && ( )} {handlePractice && } {handleDelete && ( )} {difficulty !== undefined && (
opt.value === difficulty)} onChange={(value) => saveDifficulty!(value!.value as Difficulty)} menuPortalTarget={document?.body} components={{ IndicatorSeparator: null, ValueContainer: ({ children, ...props }) => (
{children}
) }} styles={{ menuPortal: (base) => ({ ...base, zIndex: 9999 }), control: (styles) => ({ ...styles, minHeight: '40px', border: '1px solid #e5e7eb', borderRadius: '0.5rem', boxShadow: 'none', backgroundColor: '#f3f4f6', cursor: 'pointer', '&:hover': { border: '1px solid #e5e7eb', } }), valueContainer: (styles) => ({ ...styles, padding: '0 8px', display: 'flex', alignItems: 'center' }), input: (styles) => ({ ...styles, margin: '0', padding: '0' }), dropdownIndicator: (styles) => ({ ...styles, padding: '8px' }), option: (styles, state) => ({ ...styles, backgroundColor: state.isFocused ? "#D5D9F0" : state.isSelected ? "#7872BF" : "white", color: state.isFocused ? "black" : styles.color, }), }} className="text-sm" />
)} {children}
); } export default Header;