enum OrderType {
  ONE_TIME
  PERMANENT
  RECURRING
  RAPID
}

enum OrderStatus {
  DRAFT
  POSTED
  FILLED
  COMPLETED
  CANCELLED
  PENDING
  FULLY_STAFFED
  PARTIAL_STAFFED
}

enum OrderDuration {
  WEEKLY
  MONTHLY
}

#events
type Order @table(name: "orders", key: ["id"]) {
  id: UUID! @default(expr: "uuidV4()")
  eventName: String

  vendorId: UUID
  vendor: Vendor @ref(fields: "vendorId", references: "id")

  businessId: UUID!
  business: Business! @ref(fields: "businessId", references: "id")

  orderType: OrderType!
  #location: String
  status: OrderStatus! @default(expr: "'DRAFT'")
  duration: OrderDuration 
  lunchBreak: Int
  total: Float
  deparment: String

  assignedStaff: Any @col(dataType: "jsonb")
  shifts: Any @col(dataType: "jsonb")

  requested: Int
  teamHubId: UUID!
  teamHub: TeamHub! @ref(fields: "teamHubId", references: "id")

  date: Timestamp 

  startDate: Timestamp #for recurring and permanent
  endDate: Timestamp #for recurring and permanent

  recurringDays: Any @col(dataType: "jsonb")
  poReference: String

  permanentDays: Any @col(dataType: "jsonb")

  detectedConflicts: Any @col(dataType:"jsonb")
  notes: String

  createdAt: Timestamp @default(expr: "request.time")
  updatedAt: Timestamp @default(expr: "request.time")
  createdBy: String
}
