UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

58 lines (56 loc) 1.87 kB
import { getTabPath } from "./chunk-3SHJQQCA.mjs"; import { useModules } from "./chunk-KSJOLTXH.mjs"; import { SelectContent, SelectItem, SelectTrigger, SelectValue, Select_default } from "./chunk-UU7Q5S52.mjs"; // src/components/TypeSelector/TypeSelector.tsx import { useCallback, useMemo } from "react"; import { useNavigate } from "react-router-dom"; import { jsx, jsxs } from "react/jsx-runtime"; var TypeSelector = ({ value, currentTab, config, allowedCategories: allowedCategoriesProp }) => { const navigate = useNavigate(); const { hasExams } = useModules(); const allowedCategories = useMemo(() => { if (allowedCategoriesProp) { return allowedCategoriesProp; } const categories = ["ATIVIDADE" /* ATIVIDADE */]; if (hasExams) { categories.push("PROVA" /* PROVA */); } return categories; }, [hasExams, allowedCategoriesProp]); const handleTypeChange = useCallback( (newType) => { if (newType === value) return; const typeConfig = config[newType]; const tabPath = getTabPath(currentTab); navigate(`${typeConfig.routes.base}${tabPath}`); }, [value, currentTab, navigate, config] ); const selectItems = allowedCategories.map((category) => /* @__PURE__ */ jsx(SelectItem, { value: category, children: config[category].labels.selectorLabel }, category)); return /* @__PURE__ */ jsxs(Select_default, { value, onValueChange: handleTypeChange, size: "small", children: [ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-[160px] h-8 bg-background", variant: "outlined", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Tipo" }) }), /* @__PURE__ */ jsx(SelectContent, { children: selectItems }) ] }); }; var TypeSelector_default = TypeSelector; export { TypeSelector, TypeSelector_default }; //# sourceMappingURL=chunk-Z7PV3KSQ.mjs.map