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

// Mutations
export const CREATE_WAVE_INVOICE = gql`
	mutation CreateWaveInvoice($input: CreateWaveInvoiceInput!) {
		createWaveInvoice(input: $input) {
			success
			error
			invoice {
				id
				invoiceNumber
				invoiceDate
				status
				total {
					value
					currencyCode
					currencySymbol
				}
				pdfUrl
			}
			nexusInvoice {
				id
				waveInvoiceId
			}
		}
	}
`;

export const CREATE_WAVE_CUSTOMER = gql`
	mutation CreateWaveCustomer($input: CreateWaveCustomerInput!) {
		createWaveCustomer(input: $input) {
			success
			error
			customer {
				id
				name
				email
			}
			nexusCustomer {
				id
				waveCustomerId
			}
		}
	}
`;

export const LINK_CUSTOMER_TO_WAVE = gql`
	mutation LinkCustomerToWave($customerId: UUID!, $waveCustomerId: String!) {
		linkCustomerToWave(customerId: $customerId, waveCustomerId: $waveCustomerId) {
			id
			name
			waveCustomerId
		}
	}
`;

export const UNLINK_CUSTOMER_FROM_WAVE = gql`
	mutation UnlinkCustomerFromWave($customerId: UUID!) {
		unlinkCustomerFromWave(customerId: $customerId) {
			id
			name
			waveCustomerId
		}
	}
`;

// Invoice Lifecycle Mutations
export const APPROVE_WAVE_INVOICE = gql`
	mutation ApproveWaveInvoice($invoiceId: String!) {
		approveWaveInvoice(invoiceId: $invoiceId) {
			success
			error
			data {
				id
				invoiceNumber
				status
				pdfUrl
			}
		}
	}
`;

export const SEND_WAVE_INVOICE = gql`
	mutation SendWaveInvoice($invoiceId: String!) {
		sendWaveInvoice(invoiceId: $invoiceId) {
			success
			error
			data {
				id
				invoiceNumber
				status
			}
		}
	}
`;

export const DELETE_WAVE_INVOICE = gql`
	mutation DeleteWaveInvoice($invoiceId: String!) {
		deleteWaveInvoice(invoiceId: $invoiceId) {
			success
			error
			data
		}
	}
`;

// Product Mutations
export const CREATE_WAVE_PRODUCT = gql`
	mutation CreateWaveProduct($input: CreateWaveProductInput!) {
		createWaveProduct(input: $input) {
			success
			error
			data {
				id
				name
				description
				unitPrice
				isSold
				isArchived
			}
		}
	}
`;

export const UPDATE_WAVE_PRODUCT = gql`
	mutation UpdateWaveProduct($input: UpdateWaveProductInput!) {
		updateWaveProduct(input: $input) {
			success
			error
			data {
				id
				name
				description
				unitPrice
				isSold
				isArchived
			}
		}
	}
`;

export const ARCHIVE_WAVE_PRODUCT = gql`
	mutation ArchiveWaveProduct($productId: String!) {
		archiveWaveProduct(productId: $productId) {
			success
			error
			data {
				id
				name
				isArchived
			}
		}
	}
`;

// Customer Mutations
export const UPDATE_WAVE_CUSTOMER = gql`
	mutation UpdateWaveCustomer($input: UpdateWaveCustomerInput!) {
		updateWaveCustomer(input: $input) {
			success
			error
			data {
				id
				name
				email
				currencyCode
			}
		}
	}
`;

export const DELETE_WAVE_CUSTOMER = gql`
	mutation DeleteWaveCustomer($customerId: String!) {
		deleteWaveCustomer(customerId: $customerId) {
			success
			error
			data
		}
	}
`;
