// User-related types

export interface User {
  id: number;
  name: string | null;
  email: string | null;
  mobile: string;
  createdAt: Date;
}

export interface UserDetails {
  id: number;
  userId: number;
  isSuspended: boolean;
  profileImage: string | null;
}

export interface Address {
  id: number;
  userId: number;
  addressLine1: string;
  addressLine2: string | null;
  city: string;
  state: string;
  pincode: string;
  lat: number | null;
  lng: number | null;
  isDefault: boolean;
}

export interface UserAddress {
  id: number;
  userId: number;
  name: string;
  phone: string;
  addressLine1: string;
  addressLine2: string | null;
  city: string;
  state: string;
  pincode: string;
  isDefault: boolean;
  latitude: number | null;
  longitude: number | null;
  googleMapsUrl: string | null;
  adminLatitude: number | null;
  adminLongitude: number | null;
  zoneId: number | null;
  createdAt: Date;
}

export interface UserAddressResponse {
  success: boolean;
  data: UserAddress | null;
}

export interface UserAddressesResponse {
  success: boolean;
  data: UserAddress[];
}

export interface UserAddressDeleteResponse {
  success: boolean;
  message: string;
}

export interface Product {
  id: number;
  name: string;
  description: string | null;
  price: string;
  productQuantity: string;
  images: string[] | null;
  isOutOfStock: boolean;
  storeId: number | null;
  unitId: number;
}

export interface CartItem {
  id: number;
  userId: number;
  productId: number;
  quantity: string;
}

export interface Order {
  id: number;
  userId: number;
  addressId: number;
  slotId: number | null;
  totalAmount: string;
  deliveryCharge: string;
  isFlashDelivery: boolean;
  adminNotes: string | null;
  isPackaged: boolean;
  isDelivered: boolean;
  isCancelled: boolean;
  createdAt: Date;
}

export interface OrderItem {
  id: number;
  orderId: number;
  productId: number;
  quantity: string;
  price: string;
  is_packaged: boolean;
  is_package_verified: boolean;
}

export interface Payment {
  id: number;
  orderId: number;
  paymentStatus: string;
  paymentMethod: string;
  amount: string;
  createdAt: Date;
}

export interface UserBanner {
  id: number;
  name: string;
  imageUrl: string;
  description: string | null;
  productIds: number[] | null;
  redirectUrl: string | null;
  serialNum: number | null;
  isActive: boolean;
  createdAt: Date;
  lastUpdated: Date;
}

export interface UserBannersResponse {
  banners: UserBanner[];
}

export interface UserCartProduct {
  id: number;
  name: string;
  price: string;
  productQuantity: number;
  unit: string;
  isOutOfStock: boolean;
  images: string[];
}

export interface UserCartItem {
  id: number;
  productId: number;
  quantity: number;
  addedAt: Date;
  product: UserCartProduct;
  subtotal: number;
}

export interface UserCartResponse {
  items: UserCartItem[];
  totalItems: number;
  totalAmount: number;
  message?: string;
}

export interface UserComplaint {
  id: number;
  complaintBody: string;
  response: string | null;
  isResolved: boolean;
  createdAt: Date;
  orderId: number | null;
}

export interface UserComplaintsResponse {
  complaints: UserComplaint[];
}

export interface UserRaiseComplaintResponse {
  success: boolean;
  message: string;
}

export interface UserTagSummary {
  id: number;
  tagName: string;
  tagDescription: string | null;
  imageUrl: string | null;
  productIds: number[];
}

export interface UserStoreSampleProduct {
  id: number;
  name: string;
  signedImageUrl: string | null;
}

export interface UserStoreSampleProductData {
  id: number;
  name: string;
  images: string[] | null;
}

export interface UserStoreSummary {
  id: number;
  name: string;
  description: string | null;
  signedImageUrl: string | null;
  productCount: number;
  sampleProducts: UserStoreSampleProduct[];
}

export interface UserStoreSummaryData {
  id: number;
  name: string;
  description: string | null;
  imageUrl: string | null;
  productCount: number;
  sampleProducts: UserStoreSampleProductData[];
}

export interface UserStoresResponse {
  stores: UserStoreSummary[];
}

export interface UserStoreProduct {
  id: number;
  name: string;
  shortDescription: string | null;
  price: string;
  marketPrice: string | null;
  incrementStep: number;
  unit: string;
  unitNotation: string;
  images: string[];
  isOutOfStock: boolean;
  productQuantity: number;
}

export interface UserStoreProductData {
  id: number;
  name: string;
  shortDescription: string | null;
  price: string;
  marketPrice: string | null;
  incrementStep: number;
  unit: string;
  unitNotation: string;
  images: string[] | null;
  isOutOfStock: boolean;
  productQuantity: number;
}

export interface UserStoreDetail {
  store: {
    id: number;
    name: string;
    description: string | null;
    signedImageUrl: string | null;
  };
  products: UserStoreProduct[];
  tags: UserTagSummary[];
}

export interface UserStoreDetailData {
  store: {
    id: number;
    name: string;
    description: string | null;
    imageUrl: string | null;
  };
  products: UserStoreProductData[];
}

export interface UserProductStoreInfo {
  id: number;
  name: string;
  description: string | null;
}

export interface UserProductDeliverySlot {
  id: number;
  deliveryTime: Date;
  freezeTime: Date;
}

export interface UserProductSpecialDeal {
  quantity: string;
  price: string;
  validTill: Date;
}

export interface UserProductDetailData {
  id: number;
  name: string;
  shortDescription: string | null;
  longDescription: string | null;
  price: string;
  marketPrice: string | null;
  unitNotation: string;
  images: string[] | null;
  isOutOfStock: boolean;
  store: UserProductStoreInfo | null;
  incrementStep: number;
  productQuantity: number;
  isFlashAvailable: boolean;
  flashPrice: string | null;
  deliverySlots: UserProductDeliverySlot[];
  specialDeals: UserProductSpecialDeal[];
}

export interface UserProductDetail extends UserProductDetailData {
  images: string[];
}

export interface UserProductReview {
  id: number;
  reviewBody: string;
  ratings: number;
  imageUrls: string[] | null;
  reviewTime: Date;
  userName: string | null;
}

export interface UserProductReviewWithSignedUrls extends UserProductReview {
  signedImageUrls: string[];
}

export interface UserProductReviewsResponse {
  reviews: UserProductReviewWithSignedUrls[];
  hasMore: boolean;
}

export interface UserCreateReviewResponse {
  success: boolean;
  review: UserProductReview;
}

export interface UserSlotProduct {
  id: number;
  name: string;
  shortDescription: string | null;
  productQuantity: number;
  price: string;
  marketPrice: string | null;
  unit: string | null;
  images: string[];
  isOutOfStock: boolean;
  storeId: number | null;
  nextDeliveryDate: Date;
}

export interface UserSlotWithProducts {
  id: number;
  deliveryTime: Date;
  freezeTime: Date;
  isActive: boolean;
  isCapacityFull: boolean;
  products: UserSlotProduct[];
}

export interface UserSlotData {
  slotId: number;
  deliveryTime: Date;
  freezeTime: Date;
  products: UserSlotProduct[];
}

export interface UserSlotAvailability {
  id: number;
  name: string;
  isOutOfStock: boolean;
  isFlashAvailable: boolean;
}

export interface UserDeliverySlot {
  id: number;
  deliveryTime: Date;
  freezeTime: Date;
  isActive: boolean;
  isFlash: boolean;
  isCapacityFull: boolean;
  deliverySequence: unknown;
  groupIds: unknown;
}

export interface UserSlotsResponse {
  slots: UserSlotWithProducts[];
  count: number;
}

export interface UserSlotsListResponse {
  slots: UserDeliverySlot[];
  count: number;
}

export interface UserSlotsWithProductsResponse {
  slots: UserSlotWithProducts[];
  productAvailability: UserSlotAvailability[];
  count: number;
}

export interface UserPaymentOrderResponse {
  razorpayOrderId: string | number;
  key: string | undefined;
}

export interface UserPaymentVerifyResponse {
  success: boolean;
  message: string;
}

export interface UserPaymentFailResponse {
  success: boolean;
  message: string;
}

export interface UserAuthProfile {
  id: number;
  name?: string | null;
  email: string | null;
  mobile: string | null;
  createdAt: string;
  profileImage: string | null;
  bio?: string | null;
  dateOfBirth?: string | null;
  gender?: string | null;
  occupation?: string | null;
}

export interface UserAuthResponse {
  token: string;
  user: UserAuthProfile;
}

export interface UserAuthResult {
  success: boolean;
  data: UserAuthResponse;
}

export interface UserOtpVerifyResponse {
  success: boolean;
  token: string;
  user: {
    id: number;
    name: string | null;
    email: string | null;
    mobile: string | null;
    createdAt: string;
    profileImage: string | null;
  };
}

export interface UserPasswordUpdateResponse {
  success: boolean;
  message: string;
}

export interface UserProfileResponse {
  success: boolean;
  data: {
    id: number;
    name: string | null;
    email: string | null;
    mobile: string | null;
  };
}

export interface UserDeleteAccountResponse {
  success: boolean;
  message: string;
}

export interface UserCouponUsage {
  id: number;
  userId: number;
  couponId: number;
  orderId: number | null;
  orderItemId: number | null;
  usedAt: Date;
}

export interface UserCouponApplicableUser {
  id: number;
  couponId: number;
  userId: number;
}

export interface UserCouponApplicableProduct {
  id: number;
  couponId: number;
  productId: number;
}

export interface UserCoupon {
  id: number;
  couponCode: string;
  isUserBased: boolean;
  discountPercent: string | null;
  flatDiscount: string | null;
  minOrder: string | null;
  productIds: unknown;
  maxValue: string | null;
  isApplyForAll: boolean;
  validTill: Date | null;
  maxLimitForUser: number | null;
  isInvalidated: boolean;
  exclusiveApply: boolean;
  createdAt: Date;
}

export interface UserCouponWithRelations extends UserCoupon {
  usages: UserCouponUsage[];
  applicableUsers: UserCouponApplicableUser[];
  applicableProducts: UserCouponApplicableProduct[];
}

export interface UserEligibleCouponsResponse {
  success: boolean;
  data: UserCouponWithRelations[];
}

export interface UserCouponDisplay {
  id: number;
  code: string;
  discountType: 'percentage' | 'flat';
  discountValue: number;
  maxValue?: number;
  minOrder?: number;
  description: string;
  validTill?: Date;
  usageCount: number;
  maxLimitForUser?: number;
  isExpired: boolean;
  isUsedUp: boolean;
}

export interface UserMyCouponsResponse {
  success: boolean;
  data: {
    personal: UserCouponDisplay[];
    general: UserCouponDisplay[];
  };
}

export interface UserRedeemCouponResponse {
  success: boolean;
  coupon: UserCoupon;
}

export interface UserSelfDataResponse {
  success: boolean;
  data: {
    user: {
      id: number;
      name: string | null;
      email: string | null;
      mobile: string | null;
      profileImage?: string | null;
      bio?: string | null;
      dateOfBirth?: string | null;
      gender?: string | null;
      occupation?: string | null;
    };
  };
}

export interface UserProfileCompleteResponse {
  isComplete: boolean;
}

export interface UserSavePushTokenResponse {
  success: boolean;
}

export interface UserOrderItemSummary {
  productName: string;
  quantity: number;
  price: number;
  discountedPrice: number;
  amount: number;
  image: string | null;
}

export interface UserOrderSummary {
  id: number;
  orderId: string;
  orderDate: string;
  deliveryStatus: string;
  deliveryDate?: string;
  orderStatus: string;
  cancelReason: string | null;
  paymentMode: string;
  totalAmount: number;
  deliveryCharge: number;
  paymentStatus: string;
  refundStatus: string;
  refundAmount: number | null;
  userNotes: string | null;
  items: UserOrderItemSummary[];
  isFlashDelivery: boolean;
  createdAt: string;
}

export interface UserOrdersResponse {
  success: boolean;
  data: UserOrderSummary[];
  pagination: {
    page: number;
    pageSize: number;
    totalCount: number;
    totalPages: number;
  };
}

export interface UserOrderDetail extends UserOrderSummary {
  cancellationStatus: string;
  couponCode: string | null;
  couponDescription: string | null;
  discountAmount: number | null;
  orderAmount: number;
}

export interface UserCancelOrderResponse {
  success: boolean;
  message: string;
}

export interface UserUpdateNotesResponse {
  success: boolean;
  message: string;
}

export interface UserRecentProduct {
  id: number;
  name: string;
  shortDescription: string | null;
  price: string;
  images: string[];
  isOutOfStock: boolean;
  unit: string;
  incrementStep: number;
  nextDeliveryDate: string | null;
}

export interface UserRecentProductsResponse {
  success: boolean;
  products: UserRecentProduct[];
}
