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

// ==================== ACCOUNT MUTATIONS ====================

export const CREATE_ACCOUNT = gql`
	mutation CreateAccount($input: CreateAccountInput!) {
		createAccount(input: $input) {
			id
			customerId
			name
			status
			startDate
			endDate
			isActive
		}
	}
`;

export const UPDATE_ACCOUNT = gql`
	mutation UpdateAccount($id: UUID!, $input: UpdateAccountInput!) {
		updateAccount(id: $id, input: $input) {
			id
			customerId
			name
			status
			startDate
			endDate
			isActive
		}
	}
`;

export const DELETE_ACCOUNT = gql`
	mutation DeleteAccount($id: UUID!) {
		deleteAccount(id: $id)
	}
`;

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

export const CREATE_ACCOUNT_CONTACT = gql`
	mutation CreateAccountContact($accountId: UUID!, $input: CreateAccountContactInput!) {
		createAccountContact(accountId: $accountId, input: $input) {
			id
			firstName
			lastName
			email
			phone
			isActive
			isPrimary
			notes
		}
	}
`;

export const UPDATE_ACCOUNT_CONTACT = gql`
	mutation UpdateAccountContact($id: UUID!, $input: UpdateAccountContactInput!) {
		updateAccountContact(id: $id, input: $input) {
			id
			firstName
			lastName
			email
			phone
			isActive
			isPrimary
			notes
		}
	}
`;

export const DELETE_ACCOUNT_CONTACT = gql`
	mutation DeleteAccountContact($id: UUID!) {
		deleteAccountContact(id: $id)
	}
`;

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

export const CREATE_ACCOUNT_ADDRESS = gql`
	mutation CreateAccountAddress($accountId: UUID!, $input: CreateAccountAddressInput!) {
		createAccountAddress(accountId: $accountId, input: $input) {
			id
			accountId
			name
			streetAddress
			city
			state
			zipCode
			isActive
			isPrimary
			notes
		}
	}
`;

export const DELETE_ACCOUNT_ADDRESS = gql`
	mutation DeleteAccountAddress($id: UUID!) {
		deleteAccountAddress(id: $id)
	}
`;

// ==================== REVENUE MUTATIONS ====================

export const CREATE_REVENUE = gql`
	mutation CreateRevenue($accountId: UUID!, $input: CreateRevenueInput!) {
		createRevenue(accountId: $accountId, input: $input) {
			id
			amount
			startDate
			endDate
			waveServiceId
			isActive
		}
	}
`;

export const UPDATE_REVENUE = gql`
	mutation UpdateRevenue($id: UUID!, $input: UpdateRevenueInput!) {
		updateRevenue(id: $id, input: $input) {
			id
			amount
			startDate
			endDate
			waveServiceId
			isActive
		}
	}
`;

export const DELETE_REVENUE = gql`
	mutation DeleteRevenue($id: UUID!) {
		deleteRevenue(id: $id)
	}
`;

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

export interface CreateAccountInput {
	customerId: string;
	name: string;
	status?: 'ACTIVE' | 'INACTIVE' | 'PENDING';
	startDate?: string;
	endDate?: string;
}

export interface UpdateAccountInput {
	name?: string;
	status?: 'ACTIVE' | 'INACTIVE' | 'PENDING';
	startDate?: string;
	endDate?: string;
}

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

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

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

export interface CreateRevenueInput {
	amount: number;
	startDate: string;
	waveServiceId?: string;
}

export interface UpdateRevenueInput {
	amount?: number;
	startDate?: string;
	endDate?: string;
	waveServiceId?: string;
}
