Skip to content

Commit

Permalink
fix: remove cost id from create quote metric
Browse files Browse the repository at this point in the history
  • Loading branch information
enzomerca committed Aug 9, 2024
1 parent 6f7f5e2 commit a2ad991
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions react/utils/metrics/createQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const GRAPHQL_URL = (accountName: string, workspace?: string) => {
}

type CreateQuoteFieldsMetric = {
cost_center_id: string
cost_center_name: string
buyer_org_id: string
buyer_org_name: string
Expand All @@ -38,24 +37,20 @@ type CreateQuoteMetric = Metric & { fields: CreateQuoteFieldsMetric }
const fetchMetricsData = async (
accountName: string,
workspace: string,
quoteId: string,
userEmail: string
quoteId: string
) => {
const query = JSON.stringify({
query: `query GetMetricsData($id: String, $email: String!) {
query: `query GetMetricsData($id: String) {
getQuote(id: $id) @context(provider: "vtex.b2b-quotes-graphql") {
organization
organizationName
costCenterName
referenceName
creatorRole
creationDate
},
getUserByEmail(email: $email) @context(provider: "vtex.storefront-permissions") {
costId
}
}`,
variables: { id: quoteId, email: userEmail },
}
}`,
variables: { id: quoteId},
})

const { data, errors } = (
Expand All @@ -67,12 +62,10 @@ const fetchMetricsData = async (
throw new Error('Graphql Errors when trying get quote and user data')
}

const quoteResult = data?.getQuote as Omit<QuoteMetricsData, 'costId'>
const costId = (data?.getUserByEmail?.[0].costId ?? '') as string
const quoteResult = data?.getQuote as QuoteMetricsData

return {
...quoteResult,
costId,
}
}

Expand All @@ -85,8 +78,7 @@ const buildCreateQuoteMetric = async (
const metricsData = await fetchMetricsData(
metricsParam.account,
metricsParam.workspace,
metricsParam.quoteId,
userEmail
metricsParam.quoteId
)

const metric: CreateQuoteMetric = {
Expand All @@ -97,7 +89,6 @@ const buildCreateQuoteMetric = async (
fields: {
buyer_org_id: metricsData.organization,
buyer_org_name: metricsData.organizationName,
cost_center_id: metricsData.costId,
cost_center_name: metricsData.costCenterName,
member_id: namespaces?.profile?.id?.value,
member_email: userEmail,
Expand All @@ -115,7 +106,6 @@ const buildCreateQuoteMetric = async (
type QuoteMetricsData = {
organization: string // organizationId
organizationName: string
costId: string
costCenterName: string
referenceName: string // quote reference name
creatorRole: string
Expand Down

0 comments on commit a2ad991

Please sign in to comment.