37 lines
915 B
TypeScript

import type { ApolloClient, NormalizedCache } from '@apollo/client';
import { gql } from '@apollo/client';
import type { User } from 'api/user/types';
import type { GetOwnerDataQuery, GetOwnerDataQueryVariables } from 'graphql/crm.types';
const QUERY_GET_OWNER_DATA = gql`
query GetOwnerData($domainname: String) {
selectLead: leads(owner_domainname: $domainname) {
label: fullname
value: leadid
}
selectOpportunity: opportunities(owner_domainname: $domainname) {
label: name
value: opportunityid
}
}
`;
export default async function getOwnerData(
apolloClient: ApolloClient<NormalizedCache>,
user: User
) {
const { data: ownerData } = await apolloClient.query<
GetOwnerDataQuery,
GetOwnerDataQueryVariables
>({
query: QUERY_GET_OWNER_DATA,
variables: {
domainname: user.domainName,
},
});
return {
options: ownerData,
};
}