Skip to main content
This page documents all constants and configuration values used throughout MicroCBM, including environment variables, routes, status options, and modal identifiers.

Environment Constants

Application environment configuration and runtime variables.

ENV_VARS

ENV_VARS
object
Environment variable configuration

Runtime Environment

ENVIRONMENT
string
default:"development"
Current Node.js environment (development, production, or test)
isDev
boolean
True if running in development mode
isTesting
boolean
True if running in test mode
import { ENV_VARS, isDev, ENVIRONMENT } from "@/utils";

const apiUrl = ENV_VARS.API_BASE_URL;
if (isDev) {
  console.log("Running in development mode");
}

Route Constants

Application route paths for navigation and redirects.

ROUTES

ROUTES
object
Centralized route constants
import { ROUTES } from "@/utils";
import { useRouter } from "next/navigation";

const router = useRouter();

// Navigate to login
router.push(ROUTES.AUTH.LOGIN);

// Navigate to RCA detail
router.push(ROUTES.RCA_VIEW("rca-123"));

Status and Severity Options

Dropdown options for status and severity fields.

STATUSES

General status options for entities.
const STATUSES = [
  { label: "All", value: "all" },
  { label: "Active", value: "active" },
  { label: "Inactive", value: "inactive" },
  { label: "Pending", value: "pending" },
];

ASSET_STATUSES

Severity levels for assets.
const ASSET_STATUSES = [
  { label: "All", value: "" },
  { label: "High", value: "high" },
  { label: "Medium", value: "medium" },
  { label: "Low", value: "low" },
  { label: "Critical", value: "critical" },
];

SEVERITY_OPTIONS

Severity levels for recommendations and alarms.
const SEVERITY_OPTIONS = [
  { value: "low", label: "Low" },
  { value: "medium", label: "Medium" },
  { value: "high", label: "High" },
  { value: "critical", label: "Critical" },
];

STATUS_OPTIONS

Operational status for equipment and assets.
const STATUS_OPTIONS = [
  { value: "active", label: "Active" },
  { value: "inactive", label: "Inactive" },
  { value: "maintenance", label: "Under Maintenance" },
];
import { SEVERITY_OPTIONS } from "@/utils";
import { Select } from "@/components/ui/select";

<Select options={SEVERITY_OPTIONS} name="severity" />

Asset Configuration

Constants for asset types, components, and sampling.

ASSET_TYPE_OPTIONS

const ASSET_TYPE_OPTIONS = [
  { label: "Engines", value: "engines" },
  { label: "Compressor", value: "compressor" },
  { label: "Pump", value: "pump" },
  { label: "Motor", value: "motor" },
  { label: "Gearbox", value: "gearbox" },
  { label: "Valve", value: "valve" },
];

CIRCUIT_TYPE_OPTIONS

const CIRCUIT_TYPE_OPTIONS = [
  "Circulating Oil (Recirculation System)",
  "Static Oil (Sump System)",
  "Hydraulic System",
  "Gear System",
  "Compressor System",
  "Turbine System",
  "Engine System",
  "Other",
];

COMPONENT_TYPE_OPTIONS

const COMPONENT_TYPE_OPTIONS = [
  "Gearbox",
  "Engine",
  "Hydraulic Pump",
  "Compressor",
  "Turbine",
  "Motor",
  "Bearing",
  "Transmission",
  "Other",
];

SAMPLE_FREQUENCY_OPTIONS

const SAMPLE_FREQUENCY_OPTIONS = [
  "Daily (≈8-24 Hours)",
  "Weekly (≈40-168 Hours)",
  "Monthly (≈250-500 Hours)",
  "Quarterly (≈750-1500 Hours)",
  "Semi-annually (≈1500-3000 Hours)",
  "Annually (≈3000-6000 Hours)",
  "As needed",
];

SYSTEM_CAPACITY_OPTIONS

const SYSTEM_CAPACITY_OPTIONS = [
  "Small (< 5 L / < 1.3 Gal)",
  "Medium (5 L - 50 L / 1.3 - 13 Gal)",
  "Large (50 L - 500 L / 13 - 132 Gal)",
  "Very Large (> 500 L / > 132 Gal)",
];
Constants for modal URL parameters and actions.

MODALS

MODALS
object
Modal identifier constants for URL-based modal management
import { MODALS } from "@/utils";

// Build modal URL
const editUserUrl = `?${MODALS.USER.PARAM_NAME}=${MODALS.USER.CHILDREN.EDIT}`;
// Result: "?user=edit"

Permission Modules

Constants for role-based access control.

PERMISSION_MODULES

Available permission modules in the system.
const PERMISSION_MODULES = [
  "dashboard",
  "alarms",
  "assets",
  "organizations",
  "recommendations",
  "reports",
  "samples",
  "sampling_points",
  "sampling_routes",
  "sites",
  "users",
  "roles",
  "permissions",
] as const;

PERMISSION_KEYS

CRUD operations for permissions.
const PERMISSION_KEYS = [
  "create",
  "read",
  "update",
  "delete",
  "list",
] as const;

DISABLE_PERMISSION_MODULES

Permissions that should not be assignable.
const DISABLE_PERMISSION_MODULES = [
  "dashboard:create",
  "dashboard:delete",
];

Filter Options

Constants for filtering entities in lists and tables.

OPTIONS

const OPTIONS = {
  ADMIN_STATUS: ["active", "deactivated", "pending"],
  USER_STATUS: ["active", "deactivated", "inactive", "pending_registration"],
  TRANSACTION_STATUS: ["pending", "processing", "failed", "successful", "cancelled"],
  DATE_RANGE: ["daily", "weekly", "monthly", "all time"],
  USER_TYPE: ["individual", "agent", "merchant"],
  TRANSACTION_TYPE: ["credit", "debit"],
};

Default Query Parameters

Default pagination and filter values.

DEFAULT_QUERY

const DEFAULT_QUERY = {
  page: 1,
  limit: 10,
  search: "",
  name: "",
};
import { DEFAULT_QUERY } from "@/utils";

const [query, setQuery] = useState(DEFAULT_QUERY);

const handleSearch = (search: string) => {
  setQuery({ ...query, search, page: 1 });
};

Role Constants

Constants for user roles.

ROLES

const ROLES = [
  { label: "All", value: "all" },
  { label: "Super Admin", value: "super-admin" },
  { label: "Analyst", value: "analyst" },
  { label: "Viewer", value: "viewer" },
  { label: "Technician", value: "technician" },
];

Best Practices

Import from Central Location: Always import constants from @/utils to ensure consistency across the application.
Type Safety: Use as const assertions when defining constant arrays to enable TypeScript literal type inference.
Route Functions: Use ROUTES.RCA_VIEW(id) instead of string interpolation for dynamic routes to maintain type safety and refactorability.

Build docs developers (and LLMs) love