import { gql } from '@apollo/client/core';

// ==================== CUSTOMER MUTATIONS ====================

export const CREATE_CUSTOMER = gql`
	mutation CreateCustomer($input: CreateCustomerInput!) {
		createCustomer(input: $input) {
			id
			name
			status
			startDate
			endDate
			billingTerms
			billingEmail
			waveCustomerId
			isActive
		}
	}
`;

export const UPDATE_CUSTOMER = gql`
	mutation UpdateCustomer($id: UUID!, $input: UpdateCustomerInput!) {
		updateCustomer(id: $id, input: $input) {
			id
			name
			status
			startDate
			endDate
			billingTerms
			billingEmail
			waveCustomerId
			isActive
		}
	}
`;

export const DELETE_CUSTOMER = gql`
	mutation DeleteCustomer($id: UUID!) {
		deleteCustomer(id: $id)
	}
`;

// ==================== CONTACT MUTATIONS ====================

export const CREATE_CUSTOMER_CONTACT = gql`
	mutation CreateCustomerContact($customerId: UUID!, $input: CreateCustomerContactInput!) {
		createCustomerContact(customerId: $customerId, input: $input) {
			id
			firstName
			lastName
			email
			phone
			isActive
			isPrimary
			notes
		}
	}
`;

export const UPDATE_CUSTOMER_CONTACT = gql`
	mutation UpdateCustomerContact($id: UUID!, $input: UpdateCustomerContactInput!) {
		updateCustomerContact(id: $id, input: $input) {
			id
			firstName
			lastName
			email
			phone
			isActive
			isPrimary
			notes
		}
	}
`;

export const DELETE_CUSTOMER_CONTACT = gql`
	mutation DeleteCustomerContact($id: UUID!) {
		deleteCustomerContact(id: $id)
	}
`;

// ==================== ADDRESS MUTATIONS ====================

export const CREATE_CUSTOMER_ADDRESS = gql`
	mutation CreateCustomerAddress($customerId: UUID!, $input: CreateCustomerAddressInput!) {
		createCustomerAddress(customerId: $customerId, input: $input) {
			id
			name
			streetAddress
			city
			state
			zipCode
			isActive
			isPrimary
			notes
		}
	}
`;

export const UPDATE_CUSTOMER_ADDRESS = gql`
	mutation UpdateCustomerAddress($id: UUID!, $input: UpdateCustomerAddressInput!) {
		updateCustomerAddress(id: $id, input: $input) {
			id
			name
			streetAddress
			city
			state
			zipCode
			isActive
			isPrimary
			notes
		}
	}
`;

export const DELETE_CUSTOMER_ADDRESS = gql`
	mutation DeleteCustomerAddress($id: UUID!) {
		deleteCustomerAddress(id: $id)
	}
`;

// ==================== INPUT TYPES ====================

export interface CreateCustomerInput {
	name: string;
	status?: 'ACTIVE' | 'INACTIVE' | 'PENDING';
	billingEmail?: string;
	billingTerms?: string;
	waveCustomerId?: string;
	startDate?: string;
	endDate?: string;
}

export interface UpdateCustomerInput {
	name?: string;
	status?: 'ACTIVE' | 'INACTIVE' | 'PENDING';
	billingEmail?: string;
	billingTerms?: string;
	waveCustomerId?: string;
	startDate?: string;
	endDate?: string;
}

export interface CreateCustomerContactInput {
	firstName: string;
	lastName: string;
	email?: string;
	phone?: string;
	notes?: string;
	isPrimary?: boolean;
}

export interface UpdateCustomerContactInput {
	firstName?: string;
	lastName?: string;
	email?: string;
	phone?: string;
	notes?: string;
	isPrimary?: boolean;
	isActive?: boolean;
}

export interface CreateCustomerAddressInput {
	name?: string;
	streetAddress: string;
	city: string;
	state: string;
	zipCode: string;
	notes?: string;
	isPrimary?: boolean;
}

export interface UpdateCustomerAddressInput {
	name?: string;
	streetAddress?: string;
	city?: string;
	state?: string;
	zipCode?: string;
	notes?: string;
	isPrimary?: boolean;
	isActive?: boolean;
}
