import type { ExpenseType } from "src/modules/timesheets/models/expense.models";

export const getExpenseIcon = (type: ExpenseType) => {
    switch (type) {
        case 'MILEAGE': return 'time_to_leave';
        case 'EXPENSES': return 'las la-coins';
        case 'PER_DIEM': return 'hotel';
        case 'ON_CALL': return 'phone_android';
        default: return 'help_outline';
    }
};

export const useExpenseRules = (t: (_key: string) => string) => {
    const isPresent = (val: unknown) => val !== undefined && val !== null && val !== '';
    const typeRequired = (val: unknown) => (!!val) || t('timesheet.expense.errors.type_required');
    const amountRequired = (val: unknown) => (isPresent(val)) || t('timesheet.expense.errors.amount_required_for_type');
    const mileageRequired = (val: unknown) => (isPresent(val)) || t('timesheet.expense.errors.mileage_required_for_type');
    const commentRequired = (val: unknown) => (typeof val === 'string' ? val.trim().length > 0 : false) || t('timesheet.expense.hints.comment_required');

    return {
        typeRequired,
        amountRequired,
        mileageRequired,
        commentRequired,
    };
};