export interface ApiResult<T> {
    data: T;
    message: string;
    status: string;
}

export type ErrorResponse = ApiResult<null>;
export type Response = ApiResult<any>;

export function isErrorResponse(response: any): response is ErrorResponse {
    return response.status === "error";
}

export interface Filter{
    start_date?: string;
    end_date?: string;
    organization_code?: string;
    estate_name?: string;
    job_name?: string;
}

export interface FilterOptions{
    regions: {
        name: string;
        codes: string;
    }[];
    organizations: {
        code: string;
        name: string;
    }[];
    estates: {
        name: string;
    }[];
}

export type EmployeeSummary = {
    id: string;
    organization_code: string;
    organization_name: string;
    count: number;
    updated_at: string;
    created_at: string;
}

export type AttendanceSummary = {
    organization_code: string;
    organization_name: string;
    workdays: number;
    absent: number;
    count: number;
}

export type SanctionSummary = {
    organization_code: string;
    organization_name: string;
    st: number;
    sp1: number;
    sp2: number;
    sp3: number;
    phk: number;
}

export type MonthlyEmployee = {
    date: string;
    count: number;
}

export type MonthlyAttendance = {
    date: string;
    workdays: number;
    count: number;
}

export type AttendanceRange = {
    range: string;
    count: number;
}

export type ResignSummary = {
    organization_code: string;
    organization_name: string;
    count: number;
    // active: number;
}

export type ResignationType = {
    type: string;
    count: number;
}

export type ResignationCategory = {
    category: string;
    count: number;
}

export type ResignationReason = {
    reason: string;
    count: number;
}

export type EmployeeMovement = {
    organization_code: string;
    organization_name: string;
    recruitment: number;
    resignation: number;
    promotion: number;
    mutation: number;
    demotion: number;
}

export type MppRecruitment = {
    organization_code: string;
    organization_name: string;
    estate_name: string;
    job_name: string;
    total: number;
}

export type User = {
    ad_user_id: number;
    name: string;
    username: string;
    password: string;
    hc_employee_id: number;
}

export type ProductivityByRegion = {
    organization_code: string;
    organization_name: string;
    tonnage: number;
    count: number;
}

export type ProductivityByAge = {
    age_range: string;
    tonnage: number;
    count: number;
}

export type ProductivityByTenure = {
    tenure_range: string;
    tonnage: number;
    count: number;
}

export type TonnageHarvestGroupEmployee = {
    tonnage_range: string;
    count: number;
    percentage: number;
}

export type TonnageHarvestByEmployeeOrigin = {
    category: string;
    tonnage: number;
    count: number;
}

export type TonnageHarvestByEmployeeSalary = {
    salary_range: string;
    tonnage: number;
    count: number;
    percentage: number;
}

export type TargetTonnage = {
    total: number;
}

export type HrCostByJob = {
    job_label: string;
    total_salary: number;
}

export type HrCost = {
    total_salary: number;
    total_bpjs_tk: number;
    total_bpjs_ks: number;
    total_thr: number;
}

export type HrCostByOrganization = {
    organization_code: string;
    organization_name: string;
    total_salary: number;
}

export type HrCostPerMonth = {
    month: number;
    month_name: string;
    total_salary: number;
    year: number;
}

export type HrCostPerEmployee = {
    id_karyawan: string;
    name: string;
    address: string;
    salary: number;
}

export type CostData = {
    organization_code: string;
    estate_code: string;
    estate_name: string;
    date: string;
    amount: number;
}

export type OrganizationMap = {
    value: string;
    sap_code: string;
}