34 lines
894 B
TypeScript
34 lines
894 B
TypeScript
import type { ApolloClient, NormalizedCache } from '@apollo/client';
|
|
import { gql } from '@apollo/client';
|
|
import type { User } from 'api/user/types';
|
|
import type { GetOwnerData, GetOwnerDataVariables } from './__generated__/GetOwnerData';
|
|
|
|
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<GetOwnerData, GetOwnerDataVariables>({
|
|
query: QUERY_GET_OWNER_DATA,
|
|
variables: {
|
|
domainname: user.domainName,
|
|
},
|
|
});
|
|
|
|
return {
|
|
options: ownerData,
|
|
};
|
|
}
|