import { gql } from '@apollo/client/core';
import type { TeamRole, EntityStatus } from './team';
import type { CustomerInfo } from './customerProfile';

export const MY_PROFILE_QUERY = gql`
	query MyProfile {
		me {
			__typename
			... on TeamProfileType {
				id
				firstName
				lastName
				fullName
				email
				phone
				role
				status
				notes
				createdAt
				updatedAt
			}
			... on CustomerProfileType {
				id
				firstName
				lastName
				fullName
				email
				phone
				status
				notes
				createdAt
				updatedAt
				customers {
					id
					name
				}
			}
		}
	}
`;

export interface MyTeamProfile {
	__typename: 'TeamProfileType';
	id: string;
	firstName: string;
	lastName: string;
	fullName: string;
	email: string | null;
	phone: string | null;
	role: TeamRole;
	status: EntityStatus;
	notes: string | null;
	createdAt: string;
	updatedAt: string;
}

export interface MyCustomerProfile {
	__typename: 'CustomerProfileType';
	id: string;
	firstName: string;
	lastName: string;
	fullName: string;
	email: string | null;
	phone: string | null;
	status: EntityStatus;
	notes: string | null;
	createdAt: string;
	updatedAt: string;
	customers: CustomerInfo[];
}

export type MyProfile = MyTeamProfile | MyCustomerProfile;

export interface MyProfileQueryResult {
	me: MyProfile | null;
}
