import type { QSelectOption, QTableColumn } from "quasar";

export type ModuleAccessName = 'dashboard' | 'employee_list' | 'employee_management' | 'personal_profile' | 'timesheets' | 'timesheets_approval';
export type ModuleAccessPreset = 'admin' | 'employee' | 'none';

export class EmployeeProfile {
    first_name: string;
    last_name: string;
    supervisor_full_name: string;
    company_name: number;
    job_title: string;
    email: string;
    phone_number: string;
    first_work_day: string;
    last_work_day: string;
    external_payroll_id: number;
    residence: string;
    birth_date: string;
    user_module_access: ModuleAccessName[];

    constructor() {
        this.first_name = '';
        this.last_name = '';
        this.supervisor_full_name = '';
        this.company_name = 271583;
        this.job_title = '';
        this.email = '';
        this.phone_number = '';
        this.first_work_day = '';
        this.last_work_day = '';
        this.residence = '';
        this.birth_date = '';
        this.external_payroll_id = -1;
        this.user_module_access = ['dashboard',];
    }
}

export const employee_list_columns: QTableColumn<EmployeeProfile>[] = [
    {
        name: 'first_name',
        label: 'employee_list.table.first_name',
        field: 'first_name',
        align: 'left'
    },
    {
        name: 'last_name',
        label: 'employee_list.table.last_name',
        field: 'last_name',
        align: 'left'
    },
    {
        name: 'email',
        label: 'employee_list.table.email',
        field: 'email',
        align: 'left'
    },
    {
        name: 'supervisor_full_name',
        label: 'employee_list.table.supervisor',
        field: 'supervisor_full_name',
        align: 'left'
    },
    {
        name: 'company_name',
        label: 'employee_list.table.company',
        field: 'company_name',
        align: 'left'
    },
    {
        name: 'job_title',
        label: 'employee_list.table.role',
        field: 'job_title',
        align: 'left'
    },
];

export const employee_access_options: QSelectOption<ModuleAccessName>[] = [
    { label: 'dashboard', value: 'dashboard' },
    { label: 'employee_list', value: 'employee_list' },
    { label: 'employee_management', value: 'employee_management' },
    { label: 'personal_profile', value: 'personal_profile' },
    { label: 'timesheets', value: 'timesheets' },
    { label: 'timesheets_approval', value: 'timesheets_approval' },
]

export const employee_access_presets: Record<ModuleAccessPreset, ModuleAccessName[]> = {
    'admin' : ['dashboard', 'employee_list', 'employee_management', 'personal_profile', 'timesheets', 'timesheets_approval'],
    'employee' : ['dashboard', 'timesheets', 'personal_profile', 'employee_list'],
    'none' : [],
}

export const getCompanyName = (company_code: number) => {
    switch (company_code) {
        case 271583: return 'Targo';
        case 271585: return 'Solucom';
        default: return 'N / A';
    }
}