// Cart Domain Mock Data
// This file contains mock data and utilities for cart domain testing

import type { CartEntity } from '../entities/Cart';

/**
 * TODO: Replace this interface with your actual Cart entity
 * Import from: '../entities/Cart'
 */
interface Cart {
  id: string;
  name: string;
  createdAt: string;
  updatedAt: string;
  // Add your domain-specific fields here
}

/**
 * Mock cart data store
 */
class MockCartData {
  private data: Cart[] = [
    {
      id: '1',
      name: 'Sample Cart 1',
      createdAt: '2025-01-01T00:00:00Z',
      updatedAt: '2025-01-01T00:00:00Z',
    },
    {
      id: '2',
      name: 'Sample Cart 2',
      createdAt: '2025-01-02T00:00:00Z',
      updatedAt: '2025-01-02T00:00:00Z',
    },
    {
      id: '3',
      name: 'Sample Cart 3',
      createdAt: '2025-01-03T00:00:00Z',
      updatedAt: '2025-01-03T00:00:00Z',
    },
  ];

  /**
   * Get all cart items
   */
  getAll(): Cart[] {
    return [...this.data];
  }

  /**
   * Get cart item by ID
   */
  getById(id: string): Cart | undefined {
    return this.data.find(item => item.id === id);
  }

  /**
   * Create new cart item
   */
  create(item: Partial<Cart>): Cart {
    const newItem: Cart = {
      id: Date.now().toString(),
      name: item.name || 'New Cart',
      createdAt: new Date().toISOString(),
      updatedAt: new Date().toISOString(),
      ...item,
    };
    
    this.data.push(newItem);
    return newItem;
  }

  /**
   * Update cart item
   */
  update(id: string, updates: Partial<Cart>): Cart | undefined {
    const index = this.data.findIndex(item => item.id === id);
    
    if (index === -1) {
      return undefined;
    }
    
    this.data[index] = {
      ...this.data[index],
      ...updates,
      updatedAt: new Date().toISOString(),
    };
    
    return this.data[index];
  }

  /**
   * Delete cart item
   */
  delete(id: string): boolean {
    const index = this.data.findIndex(item => item.id === id);
    
    if (index === -1) {
      return false;
    }
    
    this.data.splice(index, 1);
    return true;
  }

  /**
   * Reset data to initial state (useful for tests)
   */
  reset(): void {
    this.data = [
      {
        id: '1',
        name: 'Sample Cart 1',
        createdAt: '2025-01-01T00:00:00Z',
        updatedAt: '2025-01-01T00:00:00Z',
      },
      {
        id: '2',
        name: 'Sample Cart 2',
        createdAt: '2025-01-02T00:00:00Z',
        updatedAt: '2025-01-02T00:00:00Z',
      },
      {
        id: '3',
        name: 'Sample Cart 3',
        createdAt: '2025-01-03T00:00:00Z',
        updatedAt: '2025-01-03T00:00:00Z',
      },
    ];
  }

  /**
   * Add custom methods for your domain-specific operations
   * Example: getByStatus, getByUser, etc.
   */
}

// Export singleton instance
export const mockCartData = new MockCartData();


