import { ProductData } from './productInterface';
import { UserData } from './userInterface';
import { ObjectId } from 'mongodb';

export interface ShippingData extends UserData {
  email: string;
}

export interface OrderData {
  products: Array<ProductData>;
  time: Date;
  shippingAddress: ShippingData;
  totalPrice: number;
  numberOfItems: number;
  fulfilled: boolean;
  owner: ObjectId;
  stripeCheckoutId: string;
}

export interface OrderDataDB extends OrderData {
  id: string;
  _id: string;
  __v: number;
}

export interface OrderResponseGet {
  message: string;
  orders: Array<OrderDataDB>;
}

export interface OrderResponsePost {
  message: string;
  order: OrderDataDB;
}

export interface OrderResponseError {
  message: string;
}

export type OrderResponse =
  | OrderResponseGet
  | OrderResponsePost
  | OrderResponseError;
