import { Address, User } from '@/domain/entities';
import { DEMO_PASSWORD } from '@/domain/constants/commerce';

export interface RegisterInput {
  name: string;
  email: string;
  password: string;
  phone: string;
  address: Address;
}

/**
 * DOMAIN SERVICE — Authentication business rules (demo app; no real password hashing)
 */
export class AuthDomainService {
  static isDemoCredentials(email: string, password: string): boolean {
    return password === DEMO_PASSWORD;
  }

  static createUser(data: RegisterInput): User {
    return {
      id: `user-${Date.now()}`,
      name: data.name,
      email: data.email,
      phone: data.phone,
      address: data.address,
      createdAt: new Date().toISOString(),
    };
  }

  static emailMatchesStoredUser(stored: User | null, email: string): boolean {
    return stored !== null && stored.email === email;
  }
}