analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
88 lines (87 loc) • 3.37 kB
JavaScript
// src/types/common.ts
var GenericApiStatus = /* @__PURE__ */ ((GenericApiStatus2) => {
GenericApiStatus2["A_VENCER"] = "A_VENCER";
GenericApiStatus2["VENCIDA"] = "VENCIDA";
GenericApiStatus2["CONCLUIDA"] = "CONCLUIDA";
return GenericApiStatus2;
})(GenericApiStatus || {});
var GenericDisplayStatus = /* @__PURE__ */ ((GenericDisplayStatus3) => {
GenericDisplayStatus3["ATIVA"] = "ATIVA";
GenericDisplayStatus3["VENCIDA"] = "VENCIDA";
GenericDisplayStatus3["CONCLUIDA"] = "CONCLU\xCDDA";
return GenericDisplayStatus3;
})(GenericDisplayStatus || {});
var BadgeActionType = /* @__PURE__ */ ((BadgeActionType3) => {
BadgeActionType3["SUCCESS"] = "success";
BadgeActionType3["WARNING"] = "warning";
BadgeActionType3["ERROR"] = "error";
return BadgeActionType3;
})(BadgeActionType || {});
var getStatusBadgeAction = (status) => {
const actionMap = {
["CONCLU\xCDDA" /* CONCLUIDA */]: "success" /* SUCCESS */,
["ATIVA" /* ATIVA */]: "warning" /* WARNING */,
["VENCIDA" /* VENCIDA */]: "error" /* ERROR */
};
return actionMap[status] ?? "warning" /* WARNING */;
};
// src/types/recommendedLessons.ts
var getGoalStatusBadgeAction = (status) => getStatusBadgeAction(status);
var GOAL_FILTER_STATUS_OPTIONS = [
{ id: "VENCIDA" /* VENCIDA */, name: "Vencida" },
{ id: "A_VENCER" /* A_VENCER */, name: "Ativa" }
];
var GOAL_STATUS_OPTIONS = [
{ id: "A_VENCER" /* A_VENCER */, name: "A Vencer" },
{ id: "VENCIDA" /* VENCIDA */, name: "Vencida" },
{ id: "CONCLUIDA" /* CONCLUIDA */, name: "Conclu\xEDda" }
];
var StudentLessonStatus = /* @__PURE__ */ ((StudentLessonStatus2) => {
StudentLessonStatus2["A_INICIAR"] = "A INICIAR";
StudentLessonStatus2["EM_ANDAMENTO"] = "EM ANDAMENTO";
StudentLessonStatus2["NAO_FINALIZADO"] = "N\xC3O FINALIZADO";
StudentLessonStatus2["CONCLUIDO"] = "CONCLU\xCDDO";
return StudentLessonStatus2;
})(StudentLessonStatus || {});
var getStudentStatusBadgeAction = (status) => {
const actionMap = {
["CONCLU\xCDDO" /* CONCLUIDO */]: "success",
["EM ANDAMENTO" /* EM_ANDAMENTO */]: "info",
["A INICIAR" /* A_INICIAR */]: "warning",
["N\xC3O FINALIZADO" /* NAO_FINALIZADO */]: "error"
};
return actionMap[status] ?? "warning";
};
var isDeadlinePassed = (deadline) => {
if (!deadline) return false;
return new Date(deadline) < /* @__PURE__ */ new Date();
};
var deriveStudentStatus = (progress, completedAt, deadline) => {
if (completedAt) return "CONCLU\xCDDO" /* CONCLUIDO */;
if (progress === 100) return "CONCLU\xCDDO" /* CONCLUIDO */;
if (isDeadlinePassed(deadline ?? null) && progress < 100) {
return "N\xC3O FINALIZADO" /* NAO_FINALIZADO */;
}
if (progress === 0) return "A INICIAR" /* A_INICIAR */;
if (progress > 0) return "EM ANDAMENTO" /* EM_ANDAMENTO */;
return "A INICIAR" /* A_INICIAR */;
};
var formatDaysToComplete = (daysToComplete) => {
if (daysToComplete === null) return null;
if (daysToComplete === 1) return "1 dia";
return `${daysToComplete} dias`;
};
export {
GOAL_FILTER_STATUS_OPTIONS,
GOAL_STATUS_OPTIONS,
GenericApiStatus as GoalApiStatus,
BadgeActionType as GoalBadgeActionType,
GenericDisplayStatus as GoalDisplayStatus,
StudentLessonStatus,
deriveStudentStatus,
formatDaysToComplete,
getGoalStatusBadgeAction,
getStudentStatusBadgeAction,
isDeadlinePassed
};
//# sourceMappingURL=index.mjs.map