From 0eba05abc47233a37c955b24069fb169ccd2e65d Mon Sep 17 00:00:00 2001 From: Rafaella Date: Thu, 4 Mar 2021 17:06:27 -0300 Subject: [PATCH 1/8] Add order type to access shippingEstimateDate and trackingUrl fields --- .../react/graphql/queries/detailsPage.gql | 14 ++++++++++++ .../queries/subscriptionExecutions.gql | 14 ++++++++++++ .../react/mocks/subscriptionFactory.tsx | 18 +++++++++++++++ .../graphql/queries/detailsPage.gql.d.ts | 7 +++++- .../queries/subscriptionExecutions.gql.d.ts | 22 +++++++++++++++++++ 5 files changed, 74 insertions(+), 1 deletion(-) diff --git a/vtex-my-subscriptions-3/react/graphql/queries/detailsPage.gql b/vtex-my-subscriptions-3/react/graphql/queries/detailsPage.gql index b3ff126c..7f41a2fe 100644 --- a/vtex-my-subscriptions-3/react/graphql/queries/detailsPage.gql +++ b/vtex-my-subscriptions-3/react/graphql/queries/detailsPage.gql @@ -46,6 +46,20 @@ query SubscriptionDetailsPage($id: ID!) { lastExecution { id status + order { + orderId + status + packageAttachment { + packages { + trackingUrl + } + } + shippingData { + logisticsInfo { + shippingEstimateDate + } + } + } } totals { id diff --git a/vtex-my-subscriptions-3/react/graphql/queries/subscriptionExecutions.gql b/vtex-my-subscriptions-3/react/graphql/queries/subscriptionExecutions.gql index 0794e7b2..1fa09d77 100644 --- a/vtex-my-subscriptions-3/react/graphql/queries/subscriptionExecutions.gql +++ b/vtex-my-subscriptions-3/react/graphql/queries/subscriptionExecutions.gql @@ -9,6 +9,20 @@ query Executions($subscriptionId: ID!, $page: Int, $perPage: Int) { id status date + order { + orderId + status + packageAttachment { + packages { + trackingUrl + } + } + shippingData { + logisticsInfo { + shippingEstimateDate + } + } + } } } totalCount diff --git a/vtex-my-subscriptions-3/react/mocks/subscriptionFactory.tsx b/vtex-my-subscriptions-3/react/mocks/subscriptionFactory.tsx index 288746b1..a4a677e2 100644 --- a/vtex-my-subscriptions-3/react/mocks/subscriptionFactory.tsx +++ b/vtex-my-subscriptions-3/react/mocks/subscriptionFactory.tsx @@ -121,6 +121,24 @@ export function generateSubscription({ lastExecution: { id: '3748EAF9A6F44F72B899359C92DF6C81', status: lastExecutionStatus, + order: { + orderId: '1112620108352-01', + status: 'ready-for-handling', + shippingData: { + logisticsInfo: [ + { + shippingEstimateDate: '2021-03-02T14:02:01.8879259+00:00', + }, + ], + }, + packageAttachment: { + packages: [ + { + trackingUrl: 'www.google.com.br', + }, + ], + }, + }, }, estimatedDeliveryDate, addressId: 'b3665b68c9714441bdea54c35a4d0cd6', diff --git a/vtex-my-subscriptions-3/react/typings/graphql/queries/detailsPage.gql.d.ts b/vtex-my-subscriptions-3/react/typings/graphql/queries/detailsPage.gql.d.ts index 6b107f2b..970f9e12 100644 --- a/vtex-my-subscriptions-3/react/typings/graphql/queries/detailsPage.gql.d.ts +++ b/vtex-my-subscriptions-3/react/typings/graphql/queries/detailsPage.gql.d.ts @@ -7,6 +7,7 @@ declare module '*/detailsPage.gql' { PaymentMethod, QuerySubscriptionArgs as Args, SubscriptionItem, + Order, } from 'vtex.subscriptions-graphql' type Item = Pick @@ -27,7 +28,11 @@ declare module '*/detailsPage.gql' { | 'paymentAccountId' > & { items: Item[] - lastExecution: Pick | null + lastExecution: Pick< + SubscriptionExecution, + 'id' | 'status' | 'order', + Pick + > | null purchaseSettings: { currencyCode: string paymentMethod: PaymentMethod | null diff --git a/vtex-my-subscriptions-3/react/typings/graphql/queries/subscriptionExecutions.gql.d.ts b/vtex-my-subscriptions-3/react/typings/graphql/queries/subscriptionExecutions.gql.d.ts index 5c284277..071caef2 100644 --- a/vtex-my-subscriptions-3/react/typings/graphql/queries/subscriptionExecutions.gql.d.ts +++ b/vtex-my-subscriptions-3/react/typings/graphql/queries/subscriptionExecutions.gql.d.ts @@ -6,6 +6,7 @@ declare module '*/subscriptionExecutions.gql' { id: string status: SubscriptionExecutionStatus date: string + order: Order } interface Result { @@ -18,6 +19,27 @@ declare module '*/subscriptionExecutions.gql' { perPage: number } + interface ItemLogistics { + shippingEstimateDate: string + } + + interface ShippingData { + logisticsInfo: Array + } + interface Package { + trackingUrl: string + } + interface PackageAttachment { + packages: Array + } + + interface Order { + orderId: string + packageAttachment: !PackageAttachment + shippingData: !ShippingData + status: string + } + export { SubscriptionExecution, Result, Args } const value: DocumentNode From bc071e3f53f53c08d7b0843959411ffd502d135d Mon Sep 17 00:00:00 2001 From: Rafaella Date: Thu, 4 Mar 2021 17:49:56 -0300 Subject: [PATCH 2/8] Add order's action bar - with/without trackingUrl --- .../components/DetailsPage/ActionBar.tsx | 117 +++++++++++++++++- .../react/components/DetailsPage/index.tsx | 36 +++++- .../react/components/DetailsPage/utils.tsx | 2 + 3 files changed, 149 insertions(+), 6 deletions(-) diff --git a/vtex-my-subscriptions-3/react/components/DetailsPage/ActionBar.tsx b/vtex-my-subscriptions-3/react/components/DetailsPage/ActionBar.tsx index 55ae2344..c2bf6cef 100644 --- a/vtex-my-subscriptions-3/react/components/DetailsPage/ActionBar.tsx +++ b/vtex-my-subscriptions-3/react/components/DetailsPage/ActionBar.tsx @@ -43,11 +43,64 @@ defineMessages({ changePaymentButton: { id: 'details-page.action-bar.button.changePayment', }, + orderDispatchedLabel: { + id: 'details-page.action-bar.label.orderDispatched', + }, + orderDeliveryDateBody: { + id: 'details-page.action-bar.text.orderDeliveryDate', + }, + orderDeliveryDetailBody: { + id: 'details-page.action-bar.text.orderDeliveryDetail', + }, + trackOrderButton: { + id: 'details-page.action-bar.button.trackOrder', + }, + viewOrderButton: { + id: 'details-page.action-bar.button.viewOrder', + }, + nextPurchaseLabel: { + id: 'details-page.action-bar.label.nextPurchase', + }, + nextPurchaseText: { + id: 'details-page.action-bar.text.nextPurchase', + }, + nextPurchaseButton: { + id: 'details-page.action-bar.button.nextPurchase', + }, }) class ActionBarContainer extends Component { + private calculateDaysUntilSpecificDate = (specificDate: string) => { + const today = new Date() + const diffTime = Math.abs(+new Date(specificDate) - +today) + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + + return diffDays + } + + private getOrderDispatchedAction = ( + deliveryDate: string | undefined, + trackingUrl: string | undefined + ) => { + const orderDispatchedBody = deliveryDate + ? 'orderDeliveryDate' + : 'orderDeliveryDetail' + const orderDispatchedButton = trackingUrl ? 'trackOrder' : 'viewOrder' + + return { body: orderDispatchedBody, button: orderDispatchedButton } + } + private getSuggestedAction = () => { - const { status, address, isSkipped, payment, onUpdateAction } = this.props + const { + status, + address, + isSkipped, + payment, + orderDeliveryDate, + orderTrackingUrl, + nextPurchaseDate, + onUpdateAction, + } = this.props let action: SubscriptionAction | null = null let buttonVariation: 'primary' | 'secondary' = 'primary' @@ -62,6 +115,11 @@ class ActionBarContainer extends Component { } else if (isSkipped) { action = 'unskip' buttonVariation = 'secondary' + } else if (!!orderDeliveryDate || !!orderTrackingUrl) { + action = 'orderDispatched' + } else if (nextPurchaseDate) { + action = 'nextPurchase' + buttonVariation = 'secondary' } if (action === 'changeAddress' || action === 'changePayment') { @@ -71,7 +129,14 @@ class ActionBarContainer extends Component { let onClick if ( action && - ['restore', 'unskip', 'changeAddress', 'changePayment'].includes(action) + [ + 'restore', + 'unskip', + 'changeAddress', + 'changePayment', + 'orderDispatched', + 'nextPurchase', + ].includes(action) ) { onClick = () => onUpdateAction(action as SubscriptionAction) } @@ -97,12 +162,30 @@ class ActionBarContainer extends Component { displayDanger ? 'c-danger fw5' : 'c-muted-1' }`} > - +
{ day="2-digit" /> ), + nextPurchaseDate: ( + + ), + numberOfDaysNextDelivery: + this.props.orderDeliveryDate && + this.calculateDaysUntilSpecificDate( + this.props.orderDeliveryDate + ), }} />
@@ -134,6 +239,8 @@ type Props = { nextPurchaseDate: string address: Subscription['shippingAddress'] payment: Subscription['purchaseSettings']['paymentMethod'] + orderDeliveryDate: string | undefined + orderTrackingUrl: string | undefined onUpdateAction: (action: SubscriptionAction) => void } diff --git a/vtex-my-subscriptions-3/react/components/DetailsPage/index.tsx b/vtex-my-subscriptions-3/react/components/DetailsPage/index.tsx index 4a0c95fb..b598659a 100644 --- a/vtex-my-subscriptions-3/react/components/DetailsPage/index.tsx +++ b/vtex-my-subscriptions-3/react/components/DetailsPage/index.tsx @@ -96,9 +96,26 @@ class SubscriptionsDetailsContainer extends Component { } private handleUpdateAction = (action: SubscriptionAction) => { + const { history, subscription } = this.props + + const orderPackages = + subscription?.lastExecution?.order?.packageAttachment.packages + const orderTrackingUrl = + orderPackages.length > 0 ? orderPackages[0].trackingUrl : undefined + if (action === 'changeAddress' || action === 'changePayment') { this.setState({ isEditMode: true }) goToElement({ id: PREFERENCES_ID }) + } else if (action === 'orderDispatched' && !!orderTrackingUrl) { + window.open(orderTrackingUrl) + } else if ( + action === 'orderDispatched' && + !orderTrackingUrl && + subscription?.lastExecution?.order?.orderId + ) { + history.push(`/orders/${subscription.lastExecution.order.orderId}`) + } else if (action === 'nextPurchase') { + this.handleChangeEdit(true) } else { this.setState({ isModalOpen: true, actionType: action }) } @@ -189,6 +206,11 @@ class SubscriptionsDetailsContainer extends Component { errorMessage, }) + const orderPackages = + subscription.lastExecution?.order?.packageAttachment.packages + const orderLogisticsInfo = + subscription.lastExecution?.order?.shippingData.logisticsInfo + return (
{ payment={subscription.purchaseSettings.paymentMethod} onUpdateAction={this.handleUpdateAction} nextPurchaseDate={subscription.nextPurchaseDate} + orderDeliveryDate={ + subscription.lastExecution?.order?.status === 'invoiced' + ? orderLogisticsInfo.length > 0 && + orderLogisticsInfo[0].shippingEstimateDate + : undefined + } + orderTrackingUrl={ + subscription.lastExecution?.order?.status === 'invoiced' + ? orderPackages.length > 0 && orderPackages[0].trackingUrl + : undefined + } /> ) => Promise } & InjectedRuntimeContext & WrappedComponentProps & - ChildProps + ChildProps & + RouteComponentProps type InputProps = RouteComponentProps<{ subscriptionId: string }> diff --git a/vtex-my-subscriptions-3/react/components/DetailsPage/utils.tsx b/vtex-my-subscriptions-3/react/components/DetailsPage/utils.tsx index 25325d85..d21f95ae 100644 --- a/vtex-my-subscriptions-3/react/components/DetailsPage/utils.tsx +++ b/vtex-my-subscriptions-3/react/components/DetailsPage/utils.tsx @@ -36,6 +36,8 @@ export type SubscriptionAction = | 'orderNow' | 'changeAddress' | 'changePayment' + | 'orderDispatched' + | 'nextPurchase' export function retrieveModalConfig({ intl, From ce58b8e94c02ddaa85c0243f0e31a68770839295 Mon Sep 17 00:00:00 2001 From: Rafaella Date: Thu, 4 Mar 2021 18:16:19 -0300 Subject: [PATCH 3/8] Add translations - order's action bar --- vtex-my-subscriptions-3/messages/en.json | 8 ++++++++ vtex-my-subscriptions-3/messages/es.json | 8 ++++++++ vtex-my-subscriptions-3/messages/pt.json | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/vtex-my-subscriptions-3/messages/en.json b/vtex-my-subscriptions-3/messages/en.json index dabe7669..2a59883c 100644 --- a/vtex-my-subscriptions-3/messages/en.json +++ b/vtex-my-subscriptions-3/messages/en.json @@ -102,6 +102,14 @@ "details-page.action-bar.label.changePayment": "Payment Error", "details-page.action-bar.text.changePayment": "Please, change your payment method", "details-page.action-bar.button.changePayment": "Change", + "details-page.action-bar.label.orderDispatched": "Your order is already on the way", + "details-page.action-bar.text.orderDeliveryDate": "Arrives in until {numberOfDaysNextDelivery, plural, one {1 day} other {# days}}", + "details-page.action-bar.text.orderDeliveryDetail": "See details on the order page", + "details-page.action-bar.button.trackOrder": "Track order", + "details-page.action-bar.button.viewOrder": "View order", + "details-page.action-bar.label.nextPurchase": "Next purchase in {numberOfDaysNextPurchase, plural, one {1 day} other {# days}}", + "details-page.action-bar.text.nextPurchase": "{nextPurchaseDate}", + "details-page.action-bar.button.nextPurchase": "Change date", "details-page.preferences.title": "Preferences", "display-address.label": "Shipping address", "display-address.deleted-error-message": "Your address was removed, please select another one.", diff --git a/vtex-my-subscriptions-3/messages/es.json b/vtex-my-subscriptions-3/messages/es.json index 38b7ce6b..3cca1022 100644 --- a/vtex-my-subscriptions-3/messages/es.json +++ b/vtex-my-subscriptions-3/messages/es.json @@ -102,6 +102,14 @@ "details-page.action-bar.label.changePayment": "Error en el pago", "details-page.action-bar.text.changePayment": "Por favor, cambie su método de pago", "details-page.action-bar.button.changePayment": "Cambio", + "details-page.action-bar.label.orderDispatched": "Tu pedido ya está en camino", + "details-page.action-bar.text.orderDeliveryDate": "Llega hasta {numberOfDaysNextDelivery, plural, one {1 día} other {# dias}}", + "details-page.action-bar.text.orderDeliveryDetail": "Ver detalles en la página de pedido", + "details-page.action-bar.button.trackOrder": "Rastrear pedido", + "details-page.action-bar.button.viewOrder": "Ver pedido", + "details-page.action-bar.label.nextPurchase": "Próxima compra en {numberOfDaysNextPurchase, plural, one {1 día} other {# dias}}", + "details-page.action-bar.text.nextPurchase": "{nextPurchaseDate}", + "details-page.action-bar.button.nextPurchase": "Cambiar fecha", "details-page.preferences.title": "Preferencias", "display-address.label": "Dirección de Envío", "display-address.deleted-error-message": "Su dirección fue eliminada, seleccione otra.", diff --git a/vtex-my-subscriptions-3/messages/pt.json b/vtex-my-subscriptions-3/messages/pt.json index 35eb6789..a2d1df15 100644 --- a/vtex-my-subscriptions-3/messages/pt.json +++ b/vtex-my-subscriptions-3/messages/pt.json @@ -102,6 +102,14 @@ "details-page.action-bar.label.changePayment": "Erro de pagamento", "details-page.action-bar.text.changePayment": "Por favor, altere seu método de pagamento", "details-page.action-bar.button.changePayment": "Alterar", + "details-page.action-bar.label.orderDispatched": "Seu pedido já está a caminho", + "details-page.action-bar.text.orderDeliveryDate": "Chega em até {numberOfDaysNextDelivery, plural, one {1 dia} other {# dias}}", + "details-page.action-bar.text.orderDeliveryDetail": "Veja os detalhes na página de pedidos", + "details-page.action-bar.button.trackOrder": "Rastrear pedido", + "details-page.action-bar.button.viewOrder": "Ver pedido", + "details-page.action-bar.label.nextPurchase": "Próxima compra em {numberOfDaysNextPurchase, plural, one {1 dia} other {# dias}}", + "details-page.action-bar.text.nextPurchase": "{nextPurchaseDate}", + "details-page.action-bar.button.nextPurchase": "Alterar data", "details-page.preferences.title": "Preferências", "display-address.label": "Endereço de entrega", "display-address.deleted-error-message": "Seu endereço foi removido, por favor selecione outro.", From 0b89fadaa58acff59c8109d0960abcd93fb11992 Mon Sep 17 00:00:00 2001 From: Rafaella Date: Thu, 4 Mar 2021 18:23:06 -0300 Subject: [PATCH 4/8] Add translations - TODO (de, fr, it, ro) --- vtex-my-subscriptions-3/messages/de.json | 8 ++++++++ vtex-my-subscriptions-3/messages/fr.json | 8 ++++++++ vtex-my-subscriptions-3/messages/it.json | 8 ++++++++ vtex-my-subscriptions-3/messages/ro.json | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/vtex-my-subscriptions-3/messages/de.json b/vtex-my-subscriptions-3/messages/de.json index eeb8600a..1c9a73f7 100644 --- a/vtex-my-subscriptions-3/messages/de.json +++ b/vtex-my-subscriptions-3/messages/de.json @@ -102,6 +102,14 @@ "details-page.action-bar.label.changePayment": "Zahlungsfehler", "details-page.action-bar.text.changePayment": "Bitte ändern Sie Ihre Zahlungsmethode", "details-page.action-bar.button.changePayment": "Veränderung", + "details-page.action-bar.label.orderDispatched": "TODO", + "details-page.action-bar.text.orderDeliveryDate": "TODO", + "details-page.action-bar.text.orderDeliveryDetail": "TODO", + "details-page.action-bar.button.trackOrder": "TODO", + "details-page.action-bar.button.viewOrder": "TODO", + "details-page.action-bar.label.nextPurchase": "TODO", + "details-page.action-bar.text.nextPurchase": "TODO", + "details-page.action-bar.button.nextPurchase": "TODO", "details-page.preferences.title": "Einstellungen", "display-address.label": "Lieferanschrift", "display-address.deleted-error-message": "Ihre Adresse wurde entfernt, bitte wählen Sie eine andere aus.", diff --git a/vtex-my-subscriptions-3/messages/fr.json b/vtex-my-subscriptions-3/messages/fr.json index 1a993ae8..bbda3409 100644 --- a/vtex-my-subscriptions-3/messages/fr.json +++ b/vtex-my-subscriptions-3/messages/fr.json @@ -102,6 +102,14 @@ "details-page.action-bar.label.changePayment": "Erreur de paiement", "details-page.action-bar.text.changePayment": "Veuillez changer votre mode de paiement", "details-page.action-bar.button.changePayment": "Changer", + "details-page.action-bar.label.orderDispatched": "TODO", + "details-page.action-bar.text.orderDeliveryDate": "TODO", + "details-page.action-bar.text.orderDeliveryDetail": "TODO", + "details-page.action-bar.button.trackOrder": "TODO", + "details-page.action-bar.button.viewOrder": "TODO", + "details-page.action-bar.label.nextPurchase": "TODO", + "details-page.action-bar.text.nextPurchase": "TODO", + "details-page.action-bar.button.nextPurchase": "TODO", "details-page.preferences.title": "Préférences", "display-address.label": "Adresse de livraison", "display-address.deleted-error-message": "Votre adresse a été supprimée, veuillez en sélectionner une autre.", diff --git a/vtex-my-subscriptions-3/messages/it.json b/vtex-my-subscriptions-3/messages/it.json index 29c4a868..cf8a6170 100644 --- a/vtex-my-subscriptions-3/messages/it.json +++ b/vtex-my-subscriptions-3/messages/it.json @@ -102,6 +102,14 @@ "details-page.action-bar.label.changePayment": "Errore di pagamento", "details-page.action-bar.text.changePayment": "Per favore, cambia il tuo metodo di pagamento", "details-page.action-bar.button.changePayment": "Modificare", + "details-page.action-bar.label.orderDispatched": "TODO", + "details-page.action-bar.text.orderDeliveryDate": "TODO", + "details-page.action-bar.text.orderDeliveryDetail": "TODO", + "details-page.action-bar.button.trackOrder": "TODO", + "details-page.action-bar.button.viewOrder": "TODO", + "details-page.action-bar.label.nextPurchase": "TODO", + "details-page.action-bar.text.nextPurchase": "TODO", + "details-page.action-bar.button.nextPurchase": "TODO", "details-page.preferences.title": "Preferenze", "display-address.label": "Indirizzo di spedizione", "display-address.deleted-error-message": "Il tuo indirizzo è stato rimosso, selezionane un altro.", diff --git a/vtex-my-subscriptions-3/messages/ro.json b/vtex-my-subscriptions-3/messages/ro.json index 54b8807f..0f26c450 100644 --- a/vtex-my-subscriptions-3/messages/ro.json +++ b/vtex-my-subscriptions-3/messages/ro.json @@ -102,6 +102,14 @@ "details-page.action-bar.label.changePayment": "Eroare de plata", "details-page.action-bar.text.changePayment": "Vă rugăm, schimbați metoda de plată", "details-page.action-bar.button.changePayment": "Schimbare", + "details-page.action-bar.label.orderDispatched": "TODO", + "details-page.action-bar.text.orderDeliveryDate": "TODO", + "details-page.action-bar.text.orderDeliveryDetail": "TODO", + "details-page.action-bar.button.trackOrder": "TODO", + "details-page.action-bar.button.viewOrder": "TODO", + "details-page.action-bar.label.nextPurchase": "TODO", + "details-page.action-bar.text.nextPurchase": "TODO", + "details-page.action-bar.button.nextPurchase": "TODO", "details-page.preferences.title": "Preferințe", "display-address.label": "Adresa de transport", "display-address.deleted-error-message": "Adresa dvs. a fost eliminată, vă rugăm să selectați alta.", From 5c430994a80cc41260b4c2ce09f9eea5425cc044 Mon Sep 17 00:00:00 2001 From: Rafaella Date: Fri, 5 Mar 2021 10:28:24 -0300 Subject: [PATCH 5/8] Add all translations - order action bar --- vtex-my-subscriptions-3/messages/de.json | 2 +- vtex-my-subscriptions-3/messages/es.json | 2 +- vtex-my-subscriptions-3/messages/fr.json | 2 +- vtex-my-subscriptions-3/messages/it.json | 2 +- vtex-my-subscriptions-3/messages/pt.json | 2 +- vtex-my-subscriptions-3/messages/ro.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vtex-my-subscriptions-3/messages/de.json b/vtex-my-subscriptions-3/messages/de.json index 1c9a73f7..5ea812d9 100644 --- a/vtex-my-subscriptions-3/messages/de.json +++ b/vtex-my-subscriptions-3/messages/de.json @@ -129,4 +129,4 @@ "creation-page.frequency-section.next-purchase-date": "Erster Kauf:", "creation-page.frequency-section.add-expiration-date": "Ablaufdatum hinzufügen", "creation-page.frequency-section.expiration-date": "Verfällt in:" -} +} \ No newline at end of file diff --git a/vtex-my-subscriptions-3/messages/es.json b/vtex-my-subscriptions-3/messages/es.json index 3cca1022..a421e039 100644 --- a/vtex-my-subscriptions-3/messages/es.json +++ b/vtex-my-subscriptions-3/messages/es.json @@ -129,4 +129,4 @@ "creation-page.frequency-section.next-purchase-date": "Primera compra:", "creation-page.frequency-section.add-expiration-date": "Agregar fecha de vencimiento", "creation-page.frequency-section.expiration-date": "Expira en:" -} +} \ No newline at end of file diff --git a/vtex-my-subscriptions-3/messages/fr.json b/vtex-my-subscriptions-3/messages/fr.json index bbda3409..803254a7 100644 --- a/vtex-my-subscriptions-3/messages/fr.json +++ b/vtex-my-subscriptions-3/messages/fr.json @@ -129,4 +129,4 @@ "creation-page.frequency-section.next-purchase-date": "Premier achat:", "creation-page.frequency-section.add-expiration-date": "Ajouter une date d'expiration", "creation-page.frequency-section.expiration-date": "Expire dans:" -} +} \ No newline at end of file diff --git a/vtex-my-subscriptions-3/messages/it.json b/vtex-my-subscriptions-3/messages/it.json index cf8a6170..c3559e3b 100644 --- a/vtex-my-subscriptions-3/messages/it.json +++ b/vtex-my-subscriptions-3/messages/it.json @@ -129,4 +129,4 @@ "creation-page.frequency-section.next-purchase-date": "Primo acquisto:", "creation-page.frequency-section.add-expiration-date": "Aggiungi la data di scadenza", "creation-page.frequency-section.expiration-date": "Scade tra:" -} +} \ No newline at end of file diff --git a/vtex-my-subscriptions-3/messages/pt.json b/vtex-my-subscriptions-3/messages/pt.json index a2d1df15..b5b5be38 100644 --- a/vtex-my-subscriptions-3/messages/pt.json +++ b/vtex-my-subscriptions-3/messages/pt.json @@ -129,4 +129,4 @@ "creation-page.frequency-section.next-purchase-date": "Data da primeira compra:", "creation-page.frequency-section.add-expiration-date": "Adicionar data de expiração", "creation-page.frequency-section.expiration-date": "Expira em:" -} +} \ No newline at end of file diff --git a/vtex-my-subscriptions-3/messages/ro.json b/vtex-my-subscriptions-3/messages/ro.json index 0f26c450..7354a431 100644 --- a/vtex-my-subscriptions-3/messages/ro.json +++ b/vtex-my-subscriptions-3/messages/ro.json @@ -129,4 +129,4 @@ "creation-page.frequency-section.next-purchase-date": "Prima achiziție:", "creation-page.frequency-section.add-expiration-date": "Adăugați o dată de expirare", "creation-page.frequency-section.expiration-date": "Expira in:" -} +} \ No newline at end of file From 59c6153e4f0494f3f179761b72ef46c41c379a37 Mon Sep 17 00:00:00 2001 From: Rafaella Date: Fri, 5 Mar 2021 12:36:10 -0300 Subject: [PATCH 6/8] Al translations - print bank slip --- vtex-my-subscriptions-3/messages/de.json | 5 ++++- vtex-my-subscriptions-3/messages/en.json | 3 +++ vtex-my-subscriptions-3/messages/es.json | 5 ++++- vtex-my-subscriptions-3/messages/fr.json | 5 ++++- vtex-my-subscriptions-3/messages/it.json | 5 ++++- vtex-my-subscriptions-3/messages/pt.json | 5 ++++- vtex-my-subscriptions-3/messages/ro.json | 5 ++++- 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/vtex-my-subscriptions-3/messages/de.json b/vtex-my-subscriptions-3/messages/de.json index 5ea812d9..ed6a106a 100644 --- a/vtex-my-subscriptions-3/messages/de.json +++ b/vtex-my-subscriptions-3/messages/de.json @@ -110,6 +110,9 @@ "details-page.action-bar.label.nextPurchase": "TODO", "details-page.action-bar.text.nextPurchase": "TODO", "details-page.action-bar.button.nextPurchase": "TODO", + "details-page.action-bar.label.printBankSlip": "TODO", + "details-page.action-bar.text.printBankSlip": "TODO", + "details-page.action-bar.button.printBankSlip": "TODO", "details-page.preferences.title": "Einstellungen", "display-address.label": "Lieferanschrift", "display-address.deleted-error-message": "Ihre Adresse wurde entfernt, bitte wählen Sie eine andere aus.", @@ -129,4 +132,4 @@ "creation-page.frequency-section.next-purchase-date": "Erster Kauf:", "creation-page.frequency-section.add-expiration-date": "Ablaufdatum hinzufügen", "creation-page.frequency-section.expiration-date": "Verfällt in:" -} \ No newline at end of file +} diff --git a/vtex-my-subscriptions-3/messages/en.json b/vtex-my-subscriptions-3/messages/en.json index 2a59883c..a60f8736 100644 --- a/vtex-my-subscriptions-3/messages/en.json +++ b/vtex-my-subscriptions-3/messages/en.json @@ -110,6 +110,9 @@ "details-page.action-bar.label.nextPurchase": "Next purchase in {numberOfDaysNextPurchase, plural, one {1 day} other {# days}}", "details-page.action-bar.text.nextPurchase": "{nextPurchaseDate}", "details-page.action-bar.button.nextPurchase": "Change date", + "details-page.action-bar.label.printBankSlip": "Bank slip generated", + "details-page.action-bar.text.printBankSlip": "Awaiting payment confirmation", + "details-page.action-bar.button.printBankSlip": "Print bank slip", "details-page.preferences.title": "Preferences", "display-address.label": "Shipping address", "display-address.deleted-error-message": "Your address was removed, please select another one.", diff --git a/vtex-my-subscriptions-3/messages/es.json b/vtex-my-subscriptions-3/messages/es.json index a421e039..902c9f95 100644 --- a/vtex-my-subscriptions-3/messages/es.json +++ b/vtex-my-subscriptions-3/messages/es.json @@ -110,6 +110,9 @@ "details-page.action-bar.label.nextPurchase": "Próxima compra en {numberOfDaysNextPurchase, plural, one {1 día} other {# dias}}", "details-page.action-bar.text.nextPurchase": "{nextPurchaseDate}", "details-page.action-bar.button.nextPurchase": "Cambiar fecha", + "details-page.action-bar.label.printBankSlip": "Recibo gerado", + "details-page.action-bar.text.printBankSlip": "Esperando la confirmación del pago", + "details-page.action-bar.button.printBankSlip": "Imprimir recibo", "details-page.preferences.title": "Preferencias", "display-address.label": "Dirección de Envío", "display-address.deleted-error-message": "Su dirección fue eliminada, seleccione otra.", @@ -129,4 +132,4 @@ "creation-page.frequency-section.next-purchase-date": "Primera compra:", "creation-page.frequency-section.add-expiration-date": "Agregar fecha de vencimiento", "creation-page.frequency-section.expiration-date": "Expira en:" -} \ No newline at end of file +} diff --git a/vtex-my-subscriptions-3/messages/fr.json b/vtex-my-subscriptions-3/messages/fr.json index 803254a7..34956291 100644 --- a/vtex-my-subscriptions-3/messages/fr.json +++ b/vtex-my-subscriptions-3/messages/fr.json @@ -110,6 +110,9 @@ "details-page.action-bar.label.nextPurchase": "TODO", "details-page.action-bar.text.nextPurchase": "TODO", "details-page.action-bar.button.nextPurchase": "TODO", + "details-page.action-bar.label.printBankSlip": "TODO", + "details-page.action-bar.text.printBankSlip": "TODO", + "details-page.action-bar.button.printBankSlip": "TODO", "details-page.preferences.title": "Préférences", "display-address.label": "Adresse de livraison", "display-address.deleted-error-message": "Votre adresse a été supprimée, veuillez en sélectionner une autre.", @@ -129,4 +132,4 @@ "creation-page.frequency-section.next-purchase-date": "Premier achat:", "creation-page.frequency-section.add-expiration-date": "Ajouter une date d'expiration", "creation-page.frequency-section.expiration-date": "Expire dans:" -} \ No newline at end of file +} diff --git a/vtex-my-subscriptions-3/messages/it.json b/vtex-my-subscriptions-3/messages/it.json index c3559e3b..161d3a7d 100644 --- a/vtex-my-subscriptions-3/messages/it.json +++ b/vtex-my-subscriptions-3/messages/it.json @@ -110,6 +110,9 @@ "details-page.action-bar.label.nextPurchase": "TODO", "details-page.action-bar.text.nextPurchase": "TODO", "details-page.action-bar.button.nextPurchase": "TODO", + "details-page.action-bar.label.printBankSlip": "TODO", + "details-page.action-bar.text.printBankSlip": "TODO", + "details-page.action-bar.button.printBankSlip": "TODO", "details-page.preferences.title": "Preferenze", "display-address.label": "Indirizzo di spedizione", "display-address.deleted-error-message": "Il tuo indirizzo è stato rimosso, selezionane un altro.", @@ -129,4 +132,4 @@ "creation-page.frequency-section.next-purchase-date": "Primo acquisto:", "creation-page.frequency-section.add-expiration-date": "Aggiungi la data di scadenza", "creation-page.frequency-section.expiration-date": "Scade tra:" -} \ No newline at end of file +} diff --git a/vtex-my-subscriptions-3/messages/pt.json b/vtex-my-subscriptions-3/messages/pt.json index b5b5be38..457738a8 100644 --- a/vtex-my-subscriptions-3/messages/pt.json +++ b/vtex-my-subscriptions-3/messages/pt.json @@ -110,6 +110,9 @@ "details-page.action-bar.label.nextPurchase": "Próxima compra em {numberOfDaysNextPurchase, plural, one {1 dia} other {# dias}}", "details-page.action-bar.text.nextPurchase": "{nextPurchaseDate}", "details-page.action-bar.button.nextPurchase": "Alterar data", + "details-page.action-bar.label.printBankSlip": "Boleto gerado", + "details-page.action-bar.text.printBankSlip": "Aguardando confirmação de pagamento", + "details-page.action-bar.button.printBankSlip": "Imprimir boleto", "details-page.preferences.title": "Preferências", "display-address.label": "Endereço de entrega", "display-address.deleted-error-message": "Seu endereço foi removido, por favor selecione outro.", @@ -129,4 +132,4 @@ "creation-page.frequency-section.next-purchase-date": "Data da primeira compra:", "creation-page.frequency-section.add-expiration-date": "Adicionar data de expiração", "creation-page.frequency-section.expiration-date": "Expira em:" -} \ No newline at end of file +} diff --git a/vtex-my-subscriptions-3/messages/ro.json b/vtex-my-subscriptions-3/messages/ro.json index 7354a431..a2c1f123 100644 --- a/vtex-my-subscriptions-3/messages/ro.json +++ b/vtex-my-subscriptions-3/messages/ro.json @@ -110,6 +110,9 @@ "details-page.action-bar.label.nextPurchase": "TODO", "details-page.action-bar.text.nextPurchase": "TODO", "details-page.action-bar.button.nextPurchase": "TODO", + "details-page.action-bar.label.printBankSlip": "TODO", + "details-page.action-bar.text.printBankSlip": "TODO", + "details-page.action-bar.button.printBankSlip": "TODO", "details-page.preferences.title": "Preferințe", "display-address.label": "Adresa de transport", "display-address.deleted-error-message": "Adresa dvs. a fost eliminată, vă rugăm să selectați alta.", @@ -129,4 +132,4 @@ "creation-page.frequency-section.next-purchase-date": "Prima achiziție:", "creation-page.frequency-section.add-expiration-date": "Adăugați o dată de expirare", "creation-page.frequency-section.expiration-date": "Expira in:" -} \ No newline at end of file +} From 27f073f8d4f8f15baf9c59c75c306941790f8b02 Mon Sep 17 00:00:00 2001 From: Rafaella Date: Mon, 8 Mar 2021 19:02:33 -0300 Subject: [PATCH 7/8] Add order status condition to change payments and bank slip visualization --- .../react/components/DetailsPage/ActionBar.tsx | 18 +++++++++++++++++- .../react/components/DetailsPage/index.tsx | 14 +++++++++++++- .../react/components/DetailsPage/utils.tsx | 1 + .../graphql/queries/subscriptionExecutions.gql | 7 +++++++ .../react/mocks/subscriptionFactory.tsx | 11 +++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/vtex-my-subscriptions-3/react/components/DetailsPage/ActionBar.tsx b/vtex-my-subscriptions-3/react/components/DetailsPage/ActionBar.tsx index c2bf6cef..eabd8acd 100644 --- a/vtex-my-subscriptions-3/react/components/DetailsPage/ActionBar.tsx +++ b/vtex-my-subscriptions-3/react/components/DetailsPage/ActionBar.tsx @@ -67,6 +67,15 @@ defineMessages({ nextPurchaseButton: { id: 'details-page.action-bar.button.nextPurchase', }, + printBankSlipLabel: { + id: 'details-page.action-bar.label.printBankSlip', + }, + printBankSlipText: { + id: 'details-page.action-bar.text.printBankSlip', + }, + printBankSlipButton: { + id: 'details-page.action-bar.button.printBankSlip', + }, }) class ActionBarContainer extends Component { @@ -96,9 +105,11 @@ class ActionBarContainer extends Component { address, isSkipped, payment, + orderStatus, orderDeliveryDate, orderTrackingUrl, nextPurchaseDate, + bankSlipUrl, onUpdateAction, } = this.props @@ -110,13 +121,15 @@ class ActionBarContainer extends Component { action = 'restore' } else if (!address) { action = 'changeAddress' - } else if (!payment) { + } else if (!payment || orderStatus === 'payment-denied') { action = 'changePayment' } else if (isSkipped) { action = 'unskip' buttonVariation = 'secondary' } else if (!!orderDeliveryDate || !!orderTrackingUrl) { action = 'orderDispatched' + } else if (bankSlipUrl) { + action = 'printBankSlip' } else if (nextPurchaseDate) { action = 'nextPurchase' buttonVariation = 'secondary' @@ -136,6 +149,7 @@ class ActionBarContainer extends Component { 'changePayment', 'orderDispatched', 'nextPurchase', + 'printBankSlip', ].includes(action) ) { onClick = () => onUpdateAction(action as SubscriptionAction) @@ -239,8 +253,10 @@ type Props = { nextPurchaseDate: string address: Subscription['shippingAddress'] payment: Subscription['purchaseSettings']['paymentMethod'] + orderStatus: string | undefined orderDeliveryDate: string | undefined orderTrackingUrl: string | undefined + bankSlipUrl: string | undefined onUpdateAction: (action: SubscriptionAction) => void } diff --git a/vtex-my-subscriptions-3/react/components/DetailsPage/index.tsx b/vtex-my-subscriptions-3/react/components/DetailsPage/index.tsx index b598659a..57309af1 100644 --- a/vtex-my-subscriptions-3/react/components/DetailsPage/index.tsx +++ b/vtex-my-subscriptions-3/react/components/DetailsPage/index.tsx @@ -101,7 +101,13 @@ class SubscriptionsDetailsContainer extends Component { const orderPackages = subscription?.lastExecution?.order?.packageAttachment.packages const orderTrackingUrl = - orderPackages.length > 0 ? orderPackages[0].trackingUrl : undefined + orderPackages.length > 0 && orderPackages[0].trackingUrl + + const orderTransactions = + subscription?.lastExecution?.order?.paymentData.transactions + const orderPayments = + orderTransactions.length > 0 && orderTransactions[0].payments + const bankSlipUrl = orderPayments.length > 0 && orderPayments[0].url if (action === 'changeAddress' || action === 'changePayment') { this.setState({ isEditMode: true }) @@ -116,6 +122,8 @@ class SubscriptionsDetailsContainer extends Component { history.push(`/orders/${subscription.lastExecution.order.orderId}`) } else if (action === 'nextPurchase') { this.handleChangeEdit(true) + } else if (action === 'printBankSlip' && !!bankSlipUrl) { + window.open(bankSlipUrl) } else { this.setState({ isModalOpen: true, actionType: action }) } @@ -210,6 +218,8 @@ class SubscriptionsDetailsContainer extends Component { subscription.lastExecution?.order?.packageAttachment.packages const orderLogisticsInfo = subscription.lastExecution?.order?.shippingData.logisticsInfo + const orderTransactions = + subscription?.lastExecution?.order?.paymentData?.transactions return (
@@ -241,6 +251,7 @@ class SubscriptionsDetailsContainer extends Component { payment={subscription.purchaseSettings.paymentMethod} onUpdateAction={this.handleUpdateAction} nextPurchaseDate={subscription.nextPurchaseDate} + orderStatus={subscription.lastExecution?.order?.status} orderDeliveryDate={ subscription.lastExecution?.order?.status === 'invoiced' ? orderLogisticsInfo.length > 0 && @@ -252,6 +263,7 @@ class SubscriptionsDetailsContainer extends Component { ? orderPackages.length > 0 && orderPackages[0].trackingUrl : undefined } + bankSlipUrl={orderTransactions?.[0].payments?.[0]?.url} /> Date: Tue, 9 Mar 2021 11:39:38 -0300 Subject: [PATCH 8/8] Update subscriptions-graphql version --- vtex-my-subscriptions-3/react/package.json | 8 ++++---- vtex-my-subscriptions-3/react/yarn.lock | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/vtex-my-subscriptions-3/react/package.json b/vtex-my-subscriptions-3/react/package.json index 0ad40dfd..33b7cd63 100644 --- a/vtex-my-subscriptions-3/react/package.json +++ b/vtex-my-subscriptions-3/react/package.json @@ -39,16 +39,16 @@ "graphql-tag": "^2.10.1", "react-router-dom": "4.x", "typescript": "3.9.7", - "vtex.address-form": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-form@4.6.5/public/_types/react", + "vtex.address-form": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-form@4.6.6/public/_types/react", "vtex.my-account": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account@1.17.1/public/@types/vtex.my-account", "vtex.my-account-commons": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account-commons@1.5.2/public/@types/vtex.my-account-commons", "vtex.my-subscriptions-portal-connector": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-subscriptions-portal-connector@0.1.1/public/@types/vtex.my-subscriptions-portal-connector", "vtex.payment-flags": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.payment-flags@2.5.1/public/@types/vtex.payment-flags", "vtex.render-runtime": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.126.11/public/@types/vtex.render-runtime", "vtex.store-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.138.0/public/@types/vtex.store-graphql", - "vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.135.1/public/@types/vtex.styleguide", - "vtex.subscriptions-commons": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-commons@1.1.0/public/@types/vtex.subscriptions-commons", - "vtex.subscriptions-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-graphql@3.9.2/public/@types/vtex.subscriptions-graphql", + "vtex.styleguide": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.135.4/public/@types/vtex.styleguide", + "vtex.subscriptions-commons": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-commons@1.2.1/public/@types/vtex.subscriptions-commons", + "vtex.subscriptions-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-graphql@3.11.0/public/@types/vtex.subscriptions-graphql", "vtex.totalizer-translator": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.totalizer-translator@2.2.0/public/_types/react" }, "version": "3.7.2" diff --git a/vtex-my-subscriptions-3/react/yarn.lock b/vtex-my-subscriptions-3/react/yarn.lock index 1f9da069..c4a675f8 100644 --- a/vtex-my-subscriptions-3/react/yarn.lock +++ b/vtex-my-subscriptions-3/react/yarn.lock @@ -6141,9 +6141,9 @@ vtex-tachyons@^3.2.0: resolved "https://registry.yarnpkg.com/vtex-tachyons/-/vtex-tachyons-3.2.2.tgz#e9e39d939778ef7d80a92c476cecf7417f79a6e8" integrity sha512-4M53uuvV+2XEjplVYiPgpBuaI5dtGksVgz/20NNjbZkXklJM7Lwgod/hOoh3PtIn36+95zZVVgXYfs3e6EU8YA== -"vtex.address-form@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-form@4.6.5/public/_types/react": +"vtex.address-form@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-form@4.6.6/public/_types/react": version "0.0.0" - resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-form@4.6.5/public/_types/react#fa7a0347e046eab3dd768998fc9252b2c0dd5aef" + resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.address-form@4.6.6/public/_types/react#fa7a0347e046eab3dd768998fc9252b2c0dd5aef" "vtex.my-account-commons@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.my-account-commons@1.5.2/public/@types/vtex.my-account-commons": version "1.5.2" @@ -6169,17 +6169,17 @@ vtex-tachyons@^3.2.0: version "2.138.0" resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-graphql@2.138.0/public/@types/vtex.store-graphql#a802ff0193cfaf1d9bca8d2cf36134977ac1f40e" -"vtex.styleguide@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.135.1/public/@types/vtex.styleguide": - version "9.135.1" - resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.135.1/public/@types/vtex.styleguide#ed8d203eff74ed072b6e2f6ddb66d0c92b797ade" +"vtex.styleguide@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.135.4/public/@types/vtex.styleguide": + version "9.135.4" + resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.135.4/public/@types/vtex.styleguide#f2143f2cbf61b3b01851be37e188b84edc65eb9a" -"vtex.subscriptions-commons@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-commons@1.1.0/public/@types/vtex.subscriptions-commons": - version "1.1.0" - resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-commons@1.1.0/public/@types/vtex.subscriptions-commons#f122e45f2e94c7efdd49cc9cee45c69f9d350535" +"vtex.subscriptions-commons@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-commons@1.2.1/public/@types/vtex.subscriptions-commons": + version "1.2.1" + resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-commons@1.2.1/public/@types/vtex.subscriptions-commons#2c0893b2254010713e907bd2a0d290856c00c43e" -"vtex.subscriptions-graphql@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-graphql@3.9.2/public/@types/vtex.subscriptions-graphql": - version "3.9.2" - resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-graphql@3.9.2/public/@types/vtex.subscriptions-graphql#ef9d257f171ee0290d024b6345caaaa7dfbc1050" +"vtex.subscriptions-graphql@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-graphql@3.11.0/public/@types/vtex.subscriptions-graphql": + version "3.11.0" + resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.subscriptions-graphql@3.11.0/public/@types/vtex.subscriptions-graphql#1682bd8071241f8aa03f77801fca22d458df0720" "vtex.totalizer-translator@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.totalizer-translator@2.2.0/public/_types/react": version "0.0.0"