analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
58 lines (44 loc) • 2.26 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _chunkHLCT4MJAjs = require('./chunk-HLCT4MJA.js');
var _chunkMJX4EXOOjs = require('./chunk-MJX4EXOO.js');
var _chunkHGWU3GUNjs = require('./chunk-HGWU3GUN.js');
// src/components/TypeSelector/TypeSelector.tsx
var _react = require('react');
var _reactrouterdom = require('react-router-dom');
var _jsxruntime = require('react/jsx-runtime');
var TypeSelector = ({
value,
currentTab,
config,
allowedCategories: allowedCategoriesProp
}) => {
const navigate = _reactrouterdom.useNavigate.call(void 0, );
const { hasExams } = _chunkMJX4EXOOjs.useModules.call(void 0, );
const allowedCategories = _react.useMemo.call(void 0, () => {
if (allowedCategoriesProp) {
return allowedCategoriesProp;
}
const categories = ["ATIVIDADE" /* ATIVIDADE */];
if (hasExams) {
categories.push("PROVA" /* PROVA */);
}
return categories;
}, [hasExams, allowedCategoriesProp]);
const handleTypeChange = _react.useCallback.call(void 0,
(newType) => {
if (newType === value) return;
const typeConfig = config[newType];
const tabPath = _chunkHLCT4MJAjs.getTabPath.call(void 0, currentTab);
navigate(`${typeConfig.routes.base}${tabPath}`);
},
[value, currentTab, navigate, config]
);
const selectItems = allowedCategories.map((category) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGWU3GUNjs.SelectItem, { value: category, children: config[category].labels.selectorLabel }, category));
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkHGWU3GUNjs.Select_default, { value, onValueChange: handleTypeChange, size: "small", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGWU3GUNjs.SelectTrigger, { className: "w-[160px] h-8 bg-background", variant: "outlined", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGWU3GUNjs.SelectValue, { placeholder: "Tipo" }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGWU3GUNjs.SelectContent, { children: selectItems })
] });
};
var TypeSelector_default = TypeSelector;
exports.TypeSelector = TypeSelector; exports.TypeSelector_default = TypeSelector_default;
//# sourceMappingURL=chunk-JO6FYEKH.js.map