export interface ColumnDef {
  key: string;
  label: string;
  dataType: "string" | "number" | "date" | "boolean";
  prismaPath?: string;
}

const RESOURCE_COLUMNS: ColumnDef[] = [
  { key: "id", label: "ID", dataType: "string" },
  { key: "eid", label: "Employee ID", dataType: "string" },
  { key: "displayName", label: "Name", dataType: "string" },
  { key: "email", label: "Email", dataType: "string" },
  { key: "chapter", label: "Chapter", dataType: "string" },
  { key: "resourceType", label: "Resource Type", dataType: "string" },
  { key: "lcrCents", label: "LCR (cents)", dataType: "number" },
  { key: "ucrCents", label: "UCR (cents)", dataType: "number" },
  { key: "currency", label: "Currency", dataType: "string" },
  { key: "chargeabilityTarget", label: "Chargeability Target (%)", dataType: "number" },
  { key: "fte", label: "FTE", dataType: "number" },
  { key: "enterpriseId", label: "Enterprise ID", dataType: "string" },
  { key: "portfolioUrl", label: "Portfolio URL", dataType: "string" },
  { key: "valueScore", label: "Value Score", dataType: "number" },
  { key: "valueScoreUpdatedAt", label: "Value Score Updated At", dataType: "date" },
  { key: "isActive", label: "Active", dataType: "boolean" },
  { key: "chgResponsibility", label: "Chg Responsibility", dataType: "boolean" },
  { key: "rolledOff", label: "Rolled Off", dataType: "boolean" },
  { key: "departed", label: "Departed", dataType: "boolean" },
  { key: "postalCode", label: "Postal Code", dataType: "string" },
  { key: "federalState", label: "Federal State", dataType: "string" },
  { key: "blueprint.name", label: "Blueprint", dataType: "string", prismaPath: "blueprint" },
  { key: "country.code", label: "Country Code", dataType: "string", prismaPath: "country" },
  { key: "country.name", label: "Country", dataType: "string", prismaPath: "country" },
  { key: "metroCity.name", label: "Metro City", dataType: "string", prismaPath: "metroCity" },
  { key: "clientUnit.name", label: "Client Unit", dataType: "string", prismaPath: "clientUnit" },
  { key: "orgUnit.name", label: "Org Unit", dataType: "string", prismaPath: "orgUnit" },
  { key: "managementLevelGroup.name", label: "Mgmt Level Group", dataType: "string", prismaPath: "managementLevelGroup" },
  { key: "managementLevel.name", label: "Mgmt Level", dataType: "string", prismaPath: "managementLevel" },
  { key: "areaRole.name", label: "Area Role", dataType: "string", prismaPath: "areaRole" },
  { key: "createdAt", label: "Created At", dataType: "date" },
  { key: "updatedAt", label: "Updated At", dataType: "date" },
];

const PROJECT_COLUMNS: ColumnDef[] = [
  { key: "id", label: "ID", dataType: "string" },
  { key: "shortCode", label: "Short Code", dataType: "string" },
  { key: "name", label: "Name", dataType: "string" },
  { key: "orderType", label: "Order Type", dataType: "string" },
  { key: "allocationType", label: "Allocation Type", dataType: "string" },
  { key: "status", label: "Status", dataType: "string" },
  { key: "winProbability", label: "Win Probability (%)", dataType: "number" },
  { key: "budgetCents", label: "Budget (cents)", dataType: "number" },
  { key: "shoringThreshold", label: "Shoring Threshold (%)", dataType: "number" },
  { key: "onshoreCountryCode", label: "Onshore Country Code", dataType: "string" },
  { key: "color", label: "Color", dataType: "string" },
  { key: "clientId", label: "Client ID", dataType: "string" },
  { key: "startDate", label: "Start Date", dataType: "date" },
  { key: "endDate", label: "End Date", dataType: "date" },
  { key: "responsiblePerson", label: "Responsible Person", dataType: "string" },
  { key: "client.name", label: "Client", dataType: "string", prismaPath: "client" },
  { key: "utilizationCategory.name", label: "Util. Category", dataType: "string", prismaPath: "utilizationCategory" },
  { key: "blueprint.name", label: "Blueprint", dataType: "string", prismaPath: "blueprint" },
  { key: "createdAt", label: "Created At", dataType: "date" },
  { key: "updatedAt", label: "Updated At", dataType: "date" },
];

const ASSIGNMENT_COLUMNS: ColumnDef[] = [
  { key: "id", label: "ID", dataType: "string" },
  { key: "resourceId", label: "Resource ID", dataType: "string" },
  { key: "projectId", label: "Project ID", dataType: "string" },
  { key: "resource.displayName", label: "Resource", dataType: "string", prismaPath: "resource" },
  { key: "resource.eid", label: "Resource EID", dataType: "string", prismaPath: "resource" },
  { key: "resource.chapter", label: "Resource Chapter", dataType: "string", prismaPath: "resource" },
  { key: "resource.resourceType", label: "Resource Type", dataType: "string", prismaPath: "resource" },
  { key: "resource.chargeabilityTarget", label: "Resource Chargeability Target (%)", dataType: "number", prismaPath: "resource" },
  { key: "resource.country.code", label: "Resource Country Code", dataType: "string", prismaPath: "resource" },
  { key: "resource.federalState", label: "Resource State", dataType: "string", prismaPath: "resource" },
  { key: "resource.country.name", label: "Resource Country", dataType: "string", prismaPath: "resource" },
  { key: "resource.metroCity.name", label: "Resource City", dataType: "string", prismaPath: "resource" },
  { key: "resource.orgUnit.name", label: "Resource Org Unit", dataType: "string", prismaPath: "resource" },
  { key: "resource.managementLevelGroup.name", label: "Resource Mgmt Level Group", dataType: "string", prismaPath: "resource" },
  { key: "resource.managementLevel.name", label: "Resource Mgmt Level", dataType: "string", prismaPath: "resource" },
  { key: "project.name", label: "Project", dataType: "string", prismaPath: "project" },
  { key: "project.shortCode", label: "Project Code", dataType: "string", prismaPath: "project" },
  { key: "project.status", label: "Project Status", dataType: "string", prismaPath: "project" },
  { key: "project.orderType", label: "Project Order Type", dataType: "string", prismaPath: "project" },
  { key: "project.allocationType", label: "Project Allocation Type", dataType: "string", prismaPath: "project" },
  { key: "project.blueprint.name", label: "Project Blueprint", dataType: "string", prismaPath: "project" },
  { key: "project.client.name", label: "Project Client", dataType: "string", prismaPath: "project" },
  { key: "project.utilizationCategory.name", label: "Project Util. Category", dataType: "string", prismaPath: "project" },
  { key: "startDate", label: "Start Date", dataType: "date" },
  { key: "endDate", label: "End Date", dataType: "date" },
  { key: "hoursPerDay", label: "Hours/Day", dataType: "number" },
  { key: "percentage", label: "Percentage", dataType: "number" },
  { key: "role", label: "Role (legacy)", dataType: "string" },
  { key: "roleEntity.name", label: "Role", dataType: "string", prismaPath: "roleEntity" },
  { key: "dailyCostCents", label: "Daily Cost (cents)", dataType: "number" },
  { key: "status", label: "Status", dataType: "string" },
  { key: "createdAt", label: "Created At", dataType: "date" },
  { key: "updatedAt", label: "Updated At", dataType: "date" },
];

export const RESOURCE_MONTH_COLUMNS: ColumnDef[] = [
  { key: "id", label: "Row ID", dataType: "string" },
  { key: "resourceId", label: "Resource ID", dataType: "string" },
  { key: "monthKey", label: "Month", dataType: "string" },
  { key: "periodStart", label: "Period Start", dataType: "date" },
  { key: "periodEnd", label: "Period End", dataType: "date" },
  { key: "eid", label: "Employee ID", dataType: "string" },
  { key: "displayName", label: "Name", dataType: "string" },
  { key: "email", label: "Email", dataType: "string" },
  { key: "chapter", label: "Chapter", dataType: "string" },
  { key: "resourceType", label: "Resource Type", dataType: "string" },
  { key: "isActive", label: "Active", dataType: "boolean" },
  { key: "chgResponsibility", label: "Chg Responsibility", dataType: "boolean" },
  { key: "rolledOff", label: "Rolled Off", dataType: "boolean" },
  { key: "departed", label: "Departed", dataType: "boolean" },
  { key: "countryCode", label: "Country Code", dataType: "string" },
  { key: "countryName", label: "Country", dataType: "string" },
  { key: "federalState", label: "Federal State", dataType: "string" },
  { key: "metroCityName", label: "Metro City", dataType: "string" },
  { key: "orgUnitName", label: "Org Unit", dataType: "string" },
  { key: "managementLevelGroupName", label: "Mgmt Level Group", dataType: "string" },
  { key: "managementLevelName", label: "Mgmt Level", dataType: "string" },
  { key: "fte", label: "FTE", dataType: "number" },
  { key: "lcrCents", label: "LCR (cents)", dataType: "number" },
  { key: "ucrCents", label: "UCR (cents)", dataType: "number" },
  { key: "currency", label: "Currency", dataType: "string" },
  { key: "monthlyChargeabilityTargetPct", label: "Target Chargeability (%)", dataType: "number" },
  { key: "monthlyTargetHours", label: "Target Hours", dataType: "number" },
  { key: "monthlyBaseWorkingDays", label: "Base Working Days", dataType: "number" },
  { key: "monthlyEffectiveWorkingDays", label: "Effective Working Days", dataType: "number" },
  { key: "monthlyBaseAvailableHours", label: "Base Available Hours", dataType: "number" },
  { key: "monthlySahHours", label: "SAH", dataType: "number" },
  { key: "monthlyPublicHolidayCount", label: "Holiday Dates", dataType: "number" },
  { key: "monthlyPublicHolidayWorkdayCount", label: "Holiday Workdays", dataType: "number" },
  { key: "monthlyPublicHolidayHoursDeduction", label: "Holiday Hours Deduction", dataType: "number" },
  { key: "monthlyAbsenceDayEquivalent", label: "Absence Day Equivalent", dataType: "number" },
  { key: "monthlyAbsenceHoursDeduction", label: "Absence Hours Deduction", dataType: "number" },
  { key: "monthlyActualBookedHours", label: "Actual Booked Hours", dataType: "number" },
  { key: "monthlyExpectedBookedHours", label: "Expected Booked Hours", dataType: "number" },
  { key: "monthlyActualChargeabilityPct", label: "Actual Chargeability (%)", dataType: "number" },
  { key: "monthlyExpectedChargeabilityPct", label: "Expected Chargeability (%)", dataType: "number" },
  { key: "monthlyUnassignedHours", label: "Unassigned Hours", dataType: "number" },
];

export const COLUMN_MAP = {
  resource: RESOURCE_COLUMNS,
  project: PROJECT_COLUMNS,
  assignment: ASSIGNMENT_COLUMNS,
  resource_month: RESOURCE_MONTH_COLUMNS,
} as const;
