| |
| const CATEGORY_LABELS = { |
| deli_salad: "Deli Salad", |
| dairy_dip: "Dairy Dip", |
| acidified_sauce: "Acidified Sauce", |
| rte_meat: "RTE Meat", |
| plant_based_spread: "Plant-Based Spread", |
| smoked_seafood: "Smoked Seafood", |
| cooked_poultry: "Cooked Poultry", |
| mayo_dressing: "Mayo Dressing", |
| hummus_dip: "Hummus Dip", |
| soft_cheese: "Soft Cheese", |
| }; |
|
|
| |
| const PACKAGING_LABELS = { |
| tub: "Tub", |
| vacuum: "Vacuum Sealed", |
| jar: "Jar", |
| MAP: "Modified Atmosphere (MAP)", |
| tray: "Tray", |
| bottle: "Bottle", |
| foil: "Foil Pack", |
| sachet: "Sachet", |
| }; |
|
|
| |
| const OXYGEN_LABELS = { |
| aerobic: "Aerobic", |
| anaerobic: "Anaerobic", |
| reduced_oxygen: "Reduced Oxygen", |
| }; |
|
|
| |
| const INOCULATION_LABELS = { |
| low_inoculum: "Low Inoculum", |
| medium_inoculum: "Medium Inoculum", |
| high_inoculum: "High Inoculum", |
| }; |
|
|
| |
| const PRESERVATIVE_LABELS = { |
| none: "None", |
| sodium_benzoate: "Sodium Benzoate", |
| nisin: "Nisin", |
| potassium_sorbate: "Potassium Sorbate", |
| cultured_dextrose: "Cultured Dextrose", |
| }; |
|
|
| |
| const ACIDULANT_LABELS = { |
| none: "None", |
| vinegar: "Vinegar", |
| lactic_acid: "Lactic Acid", |
| acetic_acid: "Acetic Acid", |
| citric_acid: "Citric Acid", |
| }; |
|
|
| |
| const CURVE_MODE_LABELS = { |
| both: "Both (ML + Kinetic)", |
| ml: "Machine Learning", |
| kinetic: "Kinetic Model", |
| }; |
|
|
| |
| const RISK_CLASS_LABELS = { |
| low: "Low Risk", |
| moderate: "Moderate Risk", |
| high: "High Risk", |
| critical: "Critical Risk", |
| }; |
|
|
| |
| const CONFIDENCE_LABELS = { |
| low: "Low Confidence", |
| moderate: "Moderate Confidence", |
| high: "High Confidence", |
| }; |
|
|
| |
| const FEATURE_LABELS = { |
| storage_temperature_c: "Storage Temperature (°C)", |
| initial_inoculum_log_cfu_g: "Initial Inoculum (log CFU/g)", |
| ph: "pH", |
| aw: "Water Activity (aw)", |
| salt_percent: "Salt (%)", |
| sugar_percent: "Sugar (%)", |
| fat_percent: "Fat (%)", |
| target_shelf_life_days: "Target Shelf Life (days)", |
| product_category: "Product Category", |
| packaging_type: "Packaging Type", |
| oxygen_condition: "Oxygen Condition", |
| preservative_type: "Preservative Type", |
| preservative_flag: "Preservative Enabled", |
| acidulant_type: "Acidulant Type", |
| inoculation_type: "Inoculation Level", |
| time_days: "Time (days)", |
| }; |
|
|
| |
| const DIRECTION_LABELS = { |
| increases: "Increases Risk", |
| decreases: "Decreases Risk", |
| increase: "Increases Risk", |
| decrease: "Decreases Risk", |
| }; |
|
|
| |
| export function toTitleCase(value) { |
| if (!value || typeof value !== "string") return value; |
| return value |
| .split("_") |
| .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) |
| .join(" "); |
| } |
|
|
| |
| export function formatLabel(value, type = "generic") { |
| if (value === null || value === undefined) return ""; |
|
|
| const stringValue = String(value); |
|
|
| const labelMaps = { |
| category: CATEGORY_LABELS, |
| packaging: PACKAGING_LABELS, |
| oxygen: OXYGEN_LABELS, |
| inoculation: INOCULATION_LABELS, |
| preservative: PRESERVATIVE_LABELS, |
| acidulant: ACIDULANT_LABELS, |
| curveMode: CURVE_MODE_LABELS, |
| riskClass: RISK_CLASS_LABELS, |
| confidence: CONFIDENCE_LABELS, |
| feature: FEATURE_LABELS, |
| direction: DIRECTION_LABELS, |
| }; |
|
|
| const map = labelMaps[type]; |
| if (map && map[stringValue]) { |
| return map[stringValue]; |
| } |
|
|
| |
| return toTitleCase(stringValue); |
| } |
|
|
| |
| export const formatCategory = (v) => formatLabel(v, "category"); |
| export const formatPackaging = (v) => formatLabel(v, "packaging"); |
| export const formatOxygen = (v) => formatLabel(v, "oxygen"); |
| export const formatInoculation = (v) => formatLabel(v, "inoculation"); |
| export const formatPreservative = (v) => formatLabel(v, "preservative"); |
| export const formatAcidulant = (v) => formatLabel(v, "acidulant"); |
| export const formatCurveMode = (v) => formatLabel(v, "curveMode"); |
| export const formatRiskClass = (v) => formatLabel(v, "riskClass"); |
| export const formatConfidence = (v) => formatLabel(v, "confidence"); |
| export const formatFeature = (v) => formatLabel(v, "feature"); |
| export const formatDirection = (v) => formatLabel(v, "direction"); |
|
|
| |
| export const OPTIONS = { |
| category: Object.entries(CATEGORY_LABELS).map(([value, label]) => ({ value, label })), |
| packaging: Object.entries(PACKAGING_LABELS).map(([value, label]) => ({ value, label })), |
| oxygen: Object.entries(OXYGEN_LABELS).map(([value, label]) => ({ value, label })), |
| inoculation: Object.entries(INOCULATION_LABELS).map(([value, label]) => ({ value, label })), |
| preservative: Object.entries(PRESERVATIVE_LABELS).map(([value, label]) => ({ value, label })), |
| acidulant: Object.entries(ACIDULANT_LABELS).map(([value, label]) => ({ value, label })), |
| curveMode: Object.entries(CURVE_MODE_LABELS).map(([value, label]) => ({ value, label })), |
| }; |
|
|