export const URL_CONSTANTS = {
  AUTH: {
    LOGIN: "/api/auth/login",
    REGISTER: "/api/auth/register",
    REFRESH_TOKEN: "/api/auth/refresh-token",
    LOGOUT: "/api/auth/logout",
    PROFILE: "/auth/profile",
    CHANGE_PASSWORD: "/api/auth/change-password",
    FORGOT_PASSWORD_REQUEST: "/api/auth/forgot-password/request",
    FORGOT_PASSWORD_VERIFY: "/api/auth/forgot-password/verify",
    FORGOT_PASSWORD_RESOLVE_LINK: "/api/auth/forgot-password/resolve-link",
  },

  USERS: {
    BASE: "/users",
    BY_ID: (id: string | number) => `/users/${id}`,
    SIGN_UP: "/api/auth/signup-with-pwd",
    SET_PASSWORD: "/api/auth/set-password",
    ME: "/api/auth/me",
    GENERATE_VERIFICATION_CODE: "/users/generate-verification-code",
    CHECK_AVAILABILITY: "/api/auth/check-availability",
  },

  // The signed-in user's own account record. Distinct from COMPANIES_API.PROFILE,
  // which is the company's business profile — these are the identity fields that
  // OTPs and SMS notifications are actually delivered to.
  ACCOUNT: {
    CONTACT_OTP: "/api/me/contact/otp",
    CONTACT: "/api/me/contact",
    NAME: "/api/me/name",
  },

  OTP: {
    SEND: "/api/otp/send",
    VERIFY: "/api/otp/verify",
  },
  ROLES: {
    BASE: "/roles",
    BY_ID: (id: string | number) => `/roles/${id}`,
  },

  PERMISSIONS: {
    BASE: "/permissions",
    BY_ID: (id: string | number) => `/permissions/${id}`,
  },

  PRODUCTS: {
    BASE: "/products",
    BY_ID: (id: string | number) => `/products/${id}`,
  },

  ORDERS: {
    BASE: "/orders",
    BY_ID: (id: string | number) => `/orders/${id}`,
  },

  FILES: {
    BASE: "/files",
    UPLOAD: "/files/upload",
    FILE_UPLOAD_SETTINGS: "/files/upload",
    FILE_UPLOAD_SETTINGS_BY_CODE: "/api/file-upload-settings/by-code",
    DOWNLOAD: (id: string | number) => `/files/${id}/download`,
    DELETE: (id: string | number) => `/files/${id}`,
    BY_ID: (id: string | number) => `/files/${id}`,
  },

  SETTINGS: {
    BASE: "/settings",
    GENERAL: "/settings/general",
    SECURITY: "/settings/security",
    NOTIFICATIONS: "/settings/notifications",
  },

  DROPDOWN_SETTINGS: {
    BASE: "/api/dropdown-settings",
    BY_ID: (id: string) => `/api/dropdown-settings/${id}`,
    BY_CODE: (code: string) =>
      `/api/dropdown-settings/by-code/${encodeURIComponent(code)}`,
    OPTIONS: (id: string) => `/api/dropdown-settings/${id}/options`,
    OPTION_BY_ID: (optionId: string) =>
      `/api/dropdown-settings/options/${optionId}`,
  },

  CUSTOMERS: {
    BASE: "/customers",
    BY_ID: (id: string | number) => `/customers/${id}`,
    BOOKINGS: (id: string | number) => `/customers/${id}/bookings`,
  },

  CUSTOMERS_API: {
    BASE: "/api/customers",
    BY_ID: (id: string) => `/api/customers/${id}`,
    BY_USER_ID: (id: string) => `/api/customers/user/${id}`,
  },

  COMPANIES_API: {
    GET_INFO: "/api/companies/getInfo",
    CREATE: "/api/companies/create",
    PROFILE: "/api/companies/profile",
    COMPANY_PROFILES: "/api/companies/company-profiles",
    COMPANY_PROFILE: "/api/companies/company-profile",
    ONBOARDING_START: "/api/companies/onboarding/start",
    ONBOARDING_STEP: "/api/companies/onboarding-step",
    ONBOARDING_COMPLETE: "/api/companies/onboarding/complete",
    ONBOARDING_REQUIREMENTS: "/api/companies/onboarding/requirements",
    DASHBOARD: "/api/companies/dashboard",
    FETCH_ETRADE_INFO: "/api/companies/fetch-etrade-info",
    DOCUMENTS: (id: string) => `/api/companies/${id}/documents`,
    PROFILE_LICENSE: (profileId: string) =>
      `/api/companies/company-profiles/${profileId}/license`,
    PROFILE_LICENSE_FILE: (profileId: string, fileId: string) =>
      `/api/companies/company-profiles/${profileId}/license/${fileId}`,
    PROFILE_LICENSE_REPLACE: (profileId: string, fileId: string) =>
      `/api/companies/company-profiles/${profileId}/license/${fileId}/replace`,
    POA_DELEGATION: "/api/companies/poa-delegation",
    POA_DELEGATION_FILE: (fileId: string) =>
      `/api/companies/poa-delegation/${fileId}`,
    PROFILE_CHANGE_REQUEST: "/api/companies/profile/change-request",
    PROFILE_REAPPLY: (profileId: string) =>
      `/api/companies/company-profiles/${profileId}/reapply`,
  },

  BOOKINGS: {
    BASE: "/bookings",
    BY_ID: (id: string | number) => `/api/bookings/${id}`,
    CONTRACT_VIEW: (id: string) => `/api/bookings/${id}/contract/view`,
    CONTRACT_DOCUMENT: (id: string) => `/api/bookings/${id}/contract/document`,
    CONTRACT_SIGN: (id: string) => `/api/bookings/${id}/contract/sign`,
    CONTRACT_DOWNLOAD: (id: string) => `/api/bookings/${id}/contract`,
    CANCEL: (id: string | number) => `/api/bookings/${id}/cancel`,
    CONFIRM: (id: string | number) => `/api/bookings/${id}/confirm`,
    CUSTOMER_TRUCKS: (id: string) => `/api/bookings/${id}/customer-trucks`,
    CUSTOMER_TRUCK: (id: string, assignmentId: string) =>
      `/api/bookings/${id}/customer-trucks/${assignmentId}`,
  },

  CONTRACTS: {
    BASE: "/api/contracts",
    MY: "/api/contracts/my",
    BY_ID: (id: string) => `/api/contracts/${id}`,
    DOCUMENTS: (id: string) => `/api/contracts/${id}/documents`,
    GENERATE_PRICE: (id: string) => `/api/contracts/${id}/generate-price`,
    SUBMIT: (id: string) => `/api/contracts/${id}/submit`,
    CONFIRM_SUBMIT: (id: string) => `/api/contracts/${id}/confirm-submit`,
    CONTRACT_GENERATE: (id: string) => `/api/contracts/${id}/contract/generate`,
    CONTRACT_VIEW: (id: string) => `/api/contracts/${id}/contract/view`,
    CONTRACT_DOCUMENT: (id: string) => `/api/contracts/${id}/contract/document`,
    CONTRACT_SIGN: (id: string) => `/api/contracts/${id}/contract/sign`,
    CONTRACT_SEND_SIGNING_OTP: (id: string) =>
      `/api/contracts/${id}/contract/send-signing-otp`,
    RENEW: (id: string) => `/api/contracts/${id}/renew`,
    CLEARANCE: (id: string) => `/api/contracts/${id}/clearance`,
    CLEARANCE_DOCUMENTS: (id: string) =>
      `/api/contracts/${id}/clearance/documents`,
    CLEARANCE_DUTY_SLIP: (id: string) => `/api/contracts/${id}/clearance/duty-slip`,
    /** Ask GL Ethiopia to correct the advised duty instead of paying it. */
    CLEARANCE_DUTY_DISPUTE: (id: string) =>
      `/api/contracts/${id}/clearance/duty/dispute`,
    BOOKINGS: (id: string) => `/api/contracts/${id}/bookings`,
    BOOKINGS_INITIATE: (id: string) => `/api/contracts/${id}/bookings/initiate`,
    BOOKINGS_COMPLETE: (id: string, bookingId: string) =>
      `/api/contracts/${id}/bookings/${bookingId}/complete`,
    VALIDATE_SHIPMENT: (id: string) =>
      `/api/contracts/${id}/validate-shipment`,
    MILESTONES: (id: string) => `/api/contracts/${id}/milestones`,
    BOOKING_MILESTONES: (bookingId: string) =>
      `/api/contracts/bookings/${bookingId}/milestones`,
    BOOKING_DUTY_SLIP: (bookingId: string) =>
      `/api/contracts/bookings/${bookingId}/duty-slip`,
    BOOKING_FINAL_INVOICE_SLIP: (bookingId: string) =>
      `/api/contracts/bookings/${bookingId}/final-invoice-slip`,
    BOOKING_SECOND_DUTY_SLIP: (bookingId: string) =>
      `/api/contracts/bookings/${bookingId}/second-duty-slip`,
    CAPACITY: (id: string) => `/api/contracts/${id}/capacity`,
    BOOKING_REQUESTS: (id: string) => `/api/contracts/${id}/booking-requests`,
    BOOKING_REQUEST_CANCEL: (reqId: string) =>
      `/api/contracts/booking-requests/${reqId}/cancel`,
  },

  TRAIN_SCHEDULING: {
    BOOKABLE_SCHEDULES: "/api/train-scheduling/bookable-schedules",
    AVAILABLE_DAYS: "/api/train-scheduling/available-days",
    AVAILABLE_DAYS_FOR_CARGO: "/api/train-scheduling/available-days-for-cargo",
    MY_BOOKING_WINDOWS: "/api/train-scheduling/my-booking-windows",
    CONTRACT_BOOKING_WINDOWS: (contractId: string) =>
      `/api/train-scheduling/contracts/${contractId}/booking-windows`,
  },

  PAYMENTS: {
    INITIATE: "/api/payments/initiate",
    INTENT: (bookingId: string) => `/api/payments/intents/${bookingId}`,
    CHECKOUT: "/api/payments/checkout",
  },

  BILLING: {
    MY_INVOICES: "/api/billing/my-invoices",
    MY_INVOICE_BY_ID: (id: string) => `/api/billing/my-invoices/${id}`,
    MY_INVOICE_DOCUMENT: (id: string) => `/api/billing/my-invoices/${id}/document`,
    MY_INVOICE_RECEIPT: (id: string) => `/api/billing/my-invoices/${id}/receipt`,
    PAY_INVOICE: (id: string) => `/api/billing/my-invoices/${id}/pay`,
  },

  WAREHOUSE_INVOICES: {
    FOR_BOOKING: (bookingId: string) =>
      `/api/bookings/${bookingId}/warehouse-fee-invoices`,
    BY_ID: (id: string) => `/api/warehouse-fee-invoices/${id}`,
    DOCUMENT: (id: string) => `/api/warehouse-fee-invoices/${id}/document`,
    RECEIPT: (id: string) => `/api/warehouse-fee-invoices/${id}/receipt`,
    PAY_ONLINE: (id: string) => `/api/warehouse-fee-invoices/${id}/pay-online`,
  },
};
