Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Add IBAN validation in frontend and backend
- Remove IBAN and accountHolderNumber if refund method different than bank
- Stop relying on saving the sellerName at the creation of a return request. Instead get the seller name when resolving the objects that serve it to the front end.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase and make sure changelog is right. The changes listed above are already released.


## [3.4.1] - 2022-08-18

Expand Down
2 changes: 1 addition & 1 deletion graphql/types/ReturnRequest.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ type ReturnRequestItem {
imageUrl: String!
unitMultiplier: Float!
sellerId: String!
sellerName: String!
sellerName: String
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are resolving it before sending the response, we can keep it as non-nullable.

It's important to note that when you change something on GraphQL (also routes on node), depending on the changes we get a warning in the terminal like the below one. If we proceed with these change, we would have to release a new major.
Screen Shot 2022-08-30 at 6 21 18 PM

productId: String!
refId: String!
}
Expand Down
2 changes: 1 addition & 1 deletion masterdata/returnRequest/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"imageUrl": { "type": "string" },
"unitMultiplier": { "type": "number" },
"sellerId": { "type": "string" },
"sellerName": { "type": "string" },
"sellerName": { "type": ["string", "null"] },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to make it null as well. The field is not listed as a required one, so it can be undefined.

"productId": { "type": "string" },
"refId": { "type": "string" },
"returnReason": {
Expand Down
2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"vtex.my-account": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account@1.25.0/public/@types/vtex.my-account",
"vtex.my-account-commons": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account-commons@1.6.0/public/@types/vtex.my-account-commons",
"vtex.render-runtime": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime",
"vtex.return-app": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.return-app@3.4.1/public/@types/vtex.return-app",
"vtex.return-app": "https://seller--vtexspain.myvtex.com/_v/private/typings/linked/v1/vtex.return-app@3.4.1+build1661412341/public/@types/vtex.return-app",
"vtex.store-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.155.32/public/@types/vtex.store-graphql",
"vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.1/public/@types/vtex.styleguide",
"vtex.tenant-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.tenant-graphql@0.1.2/public/@types/vtex.tenant-graphql"
Expand Down
25 changes: 17 additions & 8 deletions node/resolvers/ReturnRequestResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,28 @@ export const ReturnRequestResponse = {
return refundData
},
items: async (root: ReturnRequest, _args: unknown, ctx: Context) => {
const { id, items } = root

if (items) return items
const { id } = root

const {
clients: { returnRequest: returnRequestClient },
clients: { returnRequest: returnRequestClient, oms },
} = ctx

const { items: itemsList } = await returnRequestClient.get(id as string, [
'items',
])
const { orderId, items: itemsList } = await returnRequestClient.get(
id as string,
['orderId', 'items']
)
Comment on lines +140 to +143
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to make another request to get the request. It is passed into this function as root, hence the type it has. Moreover, not sure the order should be the source of truth here. @cesarocampov told me about a endpoint that brings the seller name giving the seller id.


const { sellers } = await oms.order(orderId, 'AUTH_TOKEN')

const itemsWithSellerName = itemsList.map((item) => {
const sellerName =
sellers.find((sellerInfo) => sellerInfo.id === item.sellerId)?.name ??
''

return { ...item, sellerName }
})

return itemsList
return itemsWithSellerName
},
refundData: async (root: ReturnRequest, _args: unknown, ctx: Context) => {
const { id, refundData } = root
Expand Down
2 changes: 0 additions & 2 deletions node/services/createReturnRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export const createReturnRequestService = async (
totals,
creationDate,
status,
sellers,
// @ts-expect-error itemMetadata is not typed in the OMS client project
itemMetadata,
shippingData,
Expand Down Expand Up @@ -168,7 +167,6 @@ export const createReturnRequestService = async (
const itemsToReturn = await createItemsToReturn({
itemsToReturn: items,
orderItems,
sellers,
itemMetadata,
catalogGQL,
})
Expand Down
12 changes: 1 addition & 11 deletions node/utils/createItemsToReturn.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { UserInputError } from '@vtex/api'
import type {
OrderItemDetailResponse,
PriceTag,
SellerDetail,
} from '@vtex/clients'
import type { OrderItemDetailResponse, PriceTag } from '@vtex/clients'
import type { ReturnRequestItemInput, ReturnRequestItem } from 'vtex.return-app'

import type { CatalogGQL } from '../clients/catalogGQL'
Expand Down Expand Up @@ -50,13 +46,11 @@ const calculateItemTax = ({
export const createItemsToReturn = async ({
itemsToReturn,
orderItems,
sellers,
itemMetadata,
catalogGQL,
}: {
itemsToReturn: ReturnRequestItemInput[]
orderItems: OrderItemDetailResponse[]
sellers: SellerDetail[]
itemMetadata: ItemMetadata
catalogGQL: CatalogGQL
}): Promise<ReturnRequestItem[]> => {
Expand Down Expand Up @@ -84,9 +78,6 @@ export const createItemsToReturn = async ({
productId,
} = orderItem

const sellerName =
sellers.find((sellerInfo) => sellerInfo.id === seller)?.name ?? ''

const productImage =
imageUrl ??
itemMetadata.Items.find((itemMeta) => itemMeta.Id === id)?.ImageUrl ??
Expand All @@ -104,7 +95,6 @@ export const createItemsToReturn = async ({
sellerId: seller,
refId,
productId,
sellerName,
condition: item.condition ? item.condition : 'unspecified',
}
})
Expand Down
4 changes: 2 additions & 2 deletions node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6155,9 +6155,9 @@ verror@1.10.0:
version "8.132.4"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime#66bb41bd4d342e37c9d85172aad5f7eefebfb6dc"

"vtex.return-app@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.return-app@3.4.1/public/@types/vtex.return-app":
"vtex.return-app@https://seller--vtexspain.myvtex.com/_v/private/typings/linked/v1/vtex.return-app@3.4.1+build1661412341/public/@types/vtex.return-app":
version "3.4.1"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.return-app@3.4.1/public/@types/vtex.return-app#3ec50e68b1da9e99870e468775be93af77497e3e"
resolved "https://seller--vtexspain.myvtex.com/_v/private/typings/linked/v1/vtex.return-app@3.4.1+build1661412341/public/@types/vtex.return-app#da05ddd171ea3683f1679ff5195236f4d12ca4c2"

"vtex.store-graphql@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.155.32/public/@types/vtex.store-graphql":
version "2.155.32"
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"vtex.my-account": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account@1.25.0/public/@types/vtex.my-account",
"vtex.my-account-commons": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account-commons@1.6.0/public/@types/vtex.my-account-commons",
"vtex.render-runtime": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime",
"vtex.return-app": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.return-app@3.4.1/public/@types/vtex.return-app",
"vtex.return-app": "https://seller--vtexspain.myvtex.com/_v/private/typings/linked/v1/vtex.return-app@3.4.1+build1661412341/public/@types/vtex.return-app",
"vtex.store-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.155.32/public/@types/vtex.store-graphql",
"vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.146.1/public/@types/vtex.styleguide",
"vtex.tenant-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.tenant-graphql@0.1.2/public/@types/vtex.tenant-graphql"
Expand Down
4 changes: 2 additions & 2 deletions react/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5206,9 +5206,9 @@ verror@1.10.0:
version "8.132.4"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.132.4/public/@types/vtex.render-runtime#66bb41bd4d342e37c9d85172aad5f7eefebfb6dc"

"vtex.return-app@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.return-app@3.4.1/public/@types/vtex.return-app":
"vtex.return-app@https://seller--vtexspain.myvtex.com/_v/private/typings/linked/v1/vtex.return-app@3.4.1+build1661412341/public/@types/vtex.return-app":
version "3.4.1"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.return-app@3.4.1/public/@types/vtex.return-app#3ec50e68b1da9e99870e468775be93af77497e3e"
resolved "https://seller--vtexspain.myvtex.com/_v/private/typings/linked/v1/vtex.return-app@3.4.1+build1661412341/public/@types/vtex.return-app#da05ddd171ea3683f1679ff5195236f4d12ca4c2"

"vtex.store-graphql@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.155.32/public/@types/vtex.store-graphql":
version "2.155.32"
Expand Down