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

export const CUSTOMER_QUERY = gql`
	query Customer($id: UUID!) {
		customer(id: $id) {
			id
			name
			status
			startDate
			endDate
			billingTerms
			billingEmail
			waveCustomerId
			waveCustomerName
			isActive
			contacts {
				id
				firstName
				lastName
				email
				phone
				isActive
				isPrimary
				notes
			}
			addresses {
				id
				name
				streetAddress
				city
				state
				zipCode
				isActive
				isPrimary
			}
			accounts {
				id
				name
				status
				isActive
			}
		}
	}
`;

export interface CustomerContact {
	id: string;
	firstName: string;
	lastName: string;
	email: string | null;
	phone: string | null;
	isActive: boolean;
	isPrimary: boolean;
	notes: string | null;
}

export interface CustomerAddress {
	id: string;
	name: string | null;
	streetAddress: string;
	city: string;
	state: string;
	zipCode: string;
	isActive: boolean;
	isPrimary: boolean;
}

export interface CustomerAccount {
	id: string;
	name: string;
	status: string;
	isActive: boolean;
}

export interface Customer {
	id: string;
	name: string;
	status: string;
	startDate: string | null;
	endDate: string | null;
	billingTerms: string | null;
	billingEmail: string | null;
	waveCustomerId: string | null;
	waveCustomerName: string | null;
	isActive: boolean;
	contacts: CustomerContact[];
	addresses: CustomerAddress[];
	accounts: CustomerAccount[];
}

export interface CustomerQueryResult {
	customer: Customer | null;
}
