import type { StationMainType } from "../enums.js"
import type { ShopUserListItemDto } from "./shop-user.dto.js"
import type { StationProductDepositLinkDto } from "./station-product-deposit.dto.js"
import type { StationProductionWorkflowStepDto } from "./order-item.dto.js"

export interface StationListItemDto {
    id: string
    name: string
    mainType: StationMainType
    active: boolean
    revision: number
    createdAt: string
}

export interface StationLinkedProductDto {
    id: string
    name: string
    categoryId: string
    categoryName: string
}

export interface StationProductDto {
    id: string
    name: string
    price: number
    categoryId: string
    categoryName: string
    depositLinks: StationProductDepositLinkDto[]
}

export interface StationDetailDto extends StationListItemDto {
    shopId: string
    shopUsers: ShopUserListItemDto[]
    linkedProducts: StationLinkedProductDto[]
    productionWorkflow: StationProductionWorkflowDto | null
}

export interface StationProductionWorkflowDto {
    enabled: boolean
    revision: number
    steps: StationProductionWorkflowStepDto[]
}

export interface StationQueueStatDto {
    status: string
    count: number
}

export interface ProductionStationStatsOverviewDto {
    completedOrderCount: number
    completedLineCount: number
    completedUnitCount: number
    uniqueProductCount: number
    avgLeadTimeSec: number | null
    avgPrepTimeSec: number | null
    peakHourLabel: string | null
    peakHourUnitCount: number
    topCashierName: string | null
    topCashierUnitCount: number
    topCashierOrderCount: number
}

export interface ProductionStationCashierStatDto {
    cashierId: string | null
    cashierName: string
    completedOrderCount: number
    completedLineCount: number
    completedUnitCount: number
    uniqueProductCount: number
    shareOfUnits: number
    avgLeadTimeSec: number | null
}

export interface ProductionStationProductStatDto {
    productId: string
    productName: string
    completedOrderCount: number
    completedLineCount: number
    completedUnitCount: number
    avgLeadTimeSec: number | null
}

export interface ProductionStationHourStatDto {
    hourLabel: string
    completedLineCount: number
    completedUnitCount: number
}

export interface ProductionStationStatsDto {
    stationId: string
    stationName: string
    generatedAt: string
    periodStart: string
    periodEnd: string
    periodLabel: string
    overview: ProductionStationStatsOverviewDto
    cashiers: ProductionStationCashierStatDto[]
    topProducts: ProductionStationProductStatDto[]
    hourly: ProductionStationHourStatDto[]
}

export interface StationProductStockDto {
    id: string
    stationId: string
    productId: string
    productName: string
    quantity: number
    updatedAt: string
}
