pages: use fetch data hooks (fetch all gql data on client) mocks: use process.env variables
37 lines
922 B
TypeScript
37 lines
922 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';
|
|
|
|
export 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,
|
|
};
|
|
}
|