Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: easypost integration #175

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion graphql/types/ReturnRequest.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ input PickupReturnDataInput {
country: String!
zipCode: String!
addressType: AddressType!
labelUrl: String!
}

enum AddressType {
Expand Down Expand Up @@ -110,7 +111,7 @@ type PickupReturnData {
country: String!
zipCode: String!
addressType: AddressType!
returnLabel: String
labelUrl: String
Copy link
Collaborator

Choose a reason for hiding this comment

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

This key coming from MD and mapped on schema.json under masterdata builder is called returnLabel. In order to be consistent we should either change how we are saving it on masterdata or how we are declaring it on schema. I think the first one is the preferred one since, since changing schema on md can have side effects in the indexation process.

}

type RefundPaymentData {
Expand Down
3 changes: 2 additions & 1 deletion messages/context.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
"return-app.return-request-details.order-id.link": "Order {orderId}",
"return-app.return-request-details.current-status.request-id": "<b>Request id:</b> {id}",
"return-app.return-request-details.current-status.status": "<b>Status:</b>",
"return-app.return-request-details.current-status.see-return-label": "See return label",
"admin/return-app.return-request-list.table-data.requestId.tooltip": "Tooltip with an explanation of how the customer can access the data",
"admin/return-app.settings.modal-warning.title": "Title of a modal to warn about max days settings",
"admin/return-app.settings.modal-warning.first-paragraph": "First parahraph describing the warning",
Expand All @@ -324,7 +325,7 @@
"admin/return-app.return-request-details.return-label.modal-message": "This action is irreversible. The created label will be sent via email to the customer.",
"admin/return-app.return-request-details.return-label.create-return-label": "Create return label",
"admin/return-app.return-request-details.return-label.see-return-label": "See return label",
"admin/return-app.return-request-details.return-label-info.tooltip": "Here you can create a return shipping label, this label will be send by email to the customer and he can paste it on the package. For this integration to work properly you must install and configure vtex.easypost.",
"admin/return-app.return-request-details.return-label-info.tooltip": "Create a return shipping label and send it to the customer via email. The request status has to be processing. For this integration to work properly you must install and configure vtex.easypost.",
"admin/return-app.return-request-details.return-label.alert.success": "The return label was created successfully",
"admin/return-app.return-request-details.return-label.alert.error": "There was an error creating the return label, please try again.",
"admin/return-app.settings.section.payment-options.refund-method-strategy.checkbox.label": "Automatically refund requests",
Expand Down
3 changes: 2 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
"return-app.return-request-details.order-id.link": "Order {orderId}",
"return-app.return-request-details.current-status.request-id": "<b>Request ID:</b> {id}",
"return-app.return-request-details.current-status.status": "<b>Status:</b>",
"return-app.return-request-details.current-status.see-return-label": "See return label",
"admin/return-app.return-request-list.table-data.requestId.tooltip": "Customers can see their request ID inside the request details",
"admin/return-app.settings.modal-warning.title": "Please review your settings",
"admin/return-app.settings.modal-warning.first-paragraph": "It looks like you are trying to save custom return options, none of which reach <b>{maxDays}</b>. This is the maximum days set for a return.",
Expand All @@ -324,7 +325,7 @@
"admin/return-app.return-request-details.return-label.modal-message": "This action is irreversible. The created label will be sent via email to the customer.",
"admin/return-app.return-request-details.return-label.create-return-label": "Create return label",
"admin/return-app.return-request-details.return-label.see-return-label": "See return label",
"admin/return-app.return-request-details.return-label-info.tooltip": "Here you can create a return shipping label, this label will be send by email to the customer and he can paste it on the package. For this integration to work properly you must install and configure vtex.easypost.",
"admin/return-app.return-request-details.return-label-info.tooltip": "Create a return shipping label and send it to the customer via email. The request status has to be processing. For this integration to work properly you must install and configure vtex.easypost.",
"admin/return-app.return-request-details.return-label.alert.success": "The return label was created successfully",
"admin/return-app.return-request-details.return-label.alert.error": "There was an error creating the return label, please try again.",
"admin/return-app.settings.section.payment-options.refund-method-strategy.checkbox.label": "Automatically refund requests",
Expand Down
4 changes: 2 additions & 2 deletions node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"vtex.my-account": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.my-account",
"vtex.my-account-commons": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.my-account-commons",
"vtex.render-runtime": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.render-runtime",
"vtex.return-app": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.return-app",
"vtex.return-app": "https://rraep--powerplanet.myvtex.com/_v/private/typings/linked/v1/[email protected]+build1662483831/public/@types/vtex.return-app",
"vtex.store-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.store-graphql",
"vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected].1/public/@types/vtex.styleguide",
"vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected].2/public/@types/vtex.styleguide",
"vtex.tenant-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.tenant-graphql"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions node/services/sendReturnLabelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export const sendReturnLabelService = async (
templateName: templateName('label', locale),
jsonData: {
data: {
name: customerProfileData?.name ?? '',
name: customerProfileData.name,
DocumentId: requestId,
email: customerProfileData?.email ?? '',
email: customerProfileData.email,
labelUrl,
},
},
Expand Down
17 changes: 12 additions & 5 deletions node/services/updateRequestStatusService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export const updateRequestStatusService = async (
// We add a try/catch here so we avoid sending an error to the browser only if the email fails.
try {
const templateExists = await mail.getTemplate(
templateName('status-update', cultureInfoData?.locale)
templateName('status-update', cultureInfoData.locale)
)

if (!templateExists) {
Expand All @@ -251,7 +251,7 @@ export const updateRequestStatusService = async (
} = updatedRequest

const mailData: StatusUpdateMailData = {
templateName: templateName('status-update', cultureInfoData?.locale),
templateName: templateName('status-update', cultureInfoData.locale),
jsonData: {
data: {
status: updatedStatus,
Expand All @@ -260,15 +260,22 @@ export const updateRequestStatusService = async (
email: customerProfileData?.email ?? '',
paymentMethod: refundPaymentData?.refundPaymentMethod ?? '',
iban: refundPaymentData?.iban ?? '',
refundedAmount:
Number(updatedRefundData?.refundedItemsValue) +
Number(updatedRefundData?.refundedShippingValue),
},
products: items,
refundStatusData: updatedRefundStatusData,
},
}

if (updatedRefundData?.refundedItemsValue) {
let refundedAmount = Number(updatedRefundData.refundedItemsValue)

if (updatedRefundData.refundedShippingValue) {
refundedAmount += Number(updatedRefundData.refundedShippingValue)
}

mailData.jsonData.data.refundedAmount = refundedAmount
}

await mail.sendMail(mailData)
} catch (error) {
logger.warn({
Expand Down
2 changes: 1 addition & 1 deletion node/typings/mailClient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface StatusUpdateData {
email: string
paymentMethod: string
iban: string
refundedAmount: number
refundedAmount?: number
}
products: ReturnRequest['items']
refundStatusData: RefundStatusData[]
Expand Down
10 changes: 5 additions & 5 deletions node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6159,17 +6159,17 @@ [email protected]:
version "8.132.4"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.render-runtime#66bb41bd4d342e37c9d85172aad5f7eefebfb6dc"

"vtex.return-app@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.return-app":
"vtex.return-app@https://rraep--powerplanet.myvtex.com/_v/private/typings/linked/v1/[email protected]+build1662483831/public/@types/vtex.return-app":
version "3.5.0"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.return-app#29e8ca8294b52af366586fcea7ae995870bc0271"
resolved "https://rraep--powerplanet.myvtex.com/_v/private/typings/linked/v1/[email protected]+build1662483831/public/@types/vtex.return-app#2a0c0e4df36fe5fcebd79598dd0df7a3ee62dee7"

"vtex.store-graphql@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.store-graphql":
version "2.155.32"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.store-graphql#abafbe1d80f453bbebc70024a829e4226bf6cc20"

"vtex.styleguide@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected].1/public/@types/vtex.styleguide":
version "9.146.1"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected].1/public/@types/vtex.styleguide#66db40ca1b78ad77ce4beedabecee320e1ef2ead"
"vtex.styleguide@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected].2/public/@types/vtex.styleguide":
version "9.146.2"
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected].2/public/@types/vtex.styleguide#b0f097f3fef06316a916d6782cf077349bb34a3b"

"vtex.tenant-graphql@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.tenant-graphql":
version "0.1.2"
Expand Down
2 changes: 1 addition & 1 deletion react/admin/ReturnDetails/ReturnDetailsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const ReturnDetailsContainer = () => {
{detailsPage !== 'return-details' ? null : (
<>
<CurrentRequestStatus />
<ReturnLabel />
<OrderLink />
<ReturnLabel />
<ItemDetailsList />
<ReturnValues />
<div className="flex-ns flex-wrap flex-row">
Expand Down
Loading