From 2150ed11cd8a06cdab0efba54c4aec2041d13562 Mon Sep 17 00:00:00 2001 From: gabrielHosino Date: Wed, 9 Mar 2022 11:50:17 -0300 Subject: [PATCH 1/4] Update graphql query to get totalizers variable and pass filters to it --- react/graphql/getAffiliatesOrders.graphql | 5 +++++ react/typings/tables.ts | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/react/graphql/getAffiliatesOrders.graphql b/react/graphql/getAffiliatesOrders.graphql index 43aeea2..33d3c48 100644 --- a/react/graphql/getAffiliatesOrders.graphql +++ b/react/graphql/getAffiliatesOrders.graphql @@ -24,5 +24,10 @@ query getAffiliatesOrders( pageSize total } + totalizers(filter: $filter) { + total + totalCommissionSum + totalOrderSum + } } } diff --git a/react/typings/tables.ts b/react/typings/tables.ts index b896cd7..6a2bb1f 100644 --- a/react/typings/tables.ts +++ b/react/typings/tables.ts @@ -15,6 +15,12 @@ type OrderItem = { commission: number } +type Totalizers = { + total: number + totalCommissionSum: number + totalOrderSum: number +} + export type AffiliatesOrdersData = { id: string orderId: string @@ -32,6 +38,7 @@ export type AffiliatesOrdersQueryReturnType = { affiliateOrders: { data: [AffiliatesOrdersData] pagination: Pagination + totalizers: Totalizers } } From f8a0814b717ec796f0f8c34beda25bbfa1372c9c Mon Sep 17 00:00:00 2001 From: gabrielHosino Date: Wed, 9 Mar 2022 12:36:07 -0300 Subject: [PATCH 2/4] Update messages --- messages/en.json | 3 ++- messages/pt.json | 3 ++- react/utils/messages.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/messages/en.json b/messages/en.json index 7bc4621..e9368c5 100644 --- a/messages/en.json +++ b/messages/en.json @@ -101,5 +101,6 @@ "admin/order.status.created.label": "Created", "admin/order.status.paid.label": "Payment approved", "admin/order.status.cancel.label": "Canceled", - "admin/order.status.invoiced.label": "Invoiced" + "admin/order.status.invoiced.label": "Invoiced", + "admin/total.orders.label": "Total orders" } diff --git a/messages/pt.json b/messages/pt.json index a48a1fe..d8d2948 100644 --- a/messages/pt.json +++ b/messages/pt.json @@ -101,5 +101,6 @@ "admin/order.status.created.label": "Criado", "admin/order.status.paid.label": "Pagamento aprovado", "admin/order.status.cancel.label": "Cancelado", - "admin/order.status.invoiced.label": "Faturado" + "admin/order.status.invoiced.label": "Faturado", + "admin/total.orders.label": "Total de pedidos" } diff --git a/react/utils/messages.ts b/react/utils/messages.ts index 61f6d62..aa70e9a 100644 --- a/react/utils/messages.ts +++ b/react/utils/messages.ts @@ -140,4 +140,5 @@ export const messages = defineMessages({ orderStatusPaidLabel: { id: 'admin/order.status.paid.label' }, orderStatusCancelLabel: { id: 'admin/order.status.cancel.label' }, orderStatusInvoicedLabel: { id: 'admin/order.status.invoiced.label' }, + totalOrdersLabel: { id: 'admin/total.orders.label' }, }) From 209acf7d67f6b6a455042d238d0a84074c3fcffb Mon Sep 17 00:00:00 2001 From: gabrielHosino Date: Wed, 9 Mar 2022 12:39:36 -0300 Subject: [PATCH 3/4] Add totalizers to the affiliate orders table --- .../admin/dashboard/AffiliateOrdersTable.tsx | 4 ++ .../components/admin/dashboard/Totalizers.tsx | 60 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 react/components/admin/dashboard/Totalizers.tsx diff --git a/react/components/admin/dashboard/AffiliateOrdersTable.tsx b/react/components/admin/dashboard/AffiliateOrdersTable.tsx index 6c84965..6f8c2c1 100644 --- a/react/components/admin/dashboard/AffiliateOrdersTable.tsx +++ b/react/components/admin/dashboard/AffiliateOrdersTable.tsx @@ -40,6 +40,7 @@ import ExportTableDataControl from '../shared/ExportTableDataControl' import StatusTableCell from './StatusTableCell' import TableActions from '../shared/TableActions' import { VIEW_DETAILS_ICON } from '../../../utils/icons' +import Totalizers from './Totalizers' type TableColumns = { id: string @@ -349,6 +350,9 @@ const AffiliateOrdersTable: FC = () => { return ( + {data && !loading && ( + + )} { + const intl = useIntl() + const { + culture: { currency }, + } = useRuntime() + + const { total, totalCommissionSum, totalOrderSum } = totalizers + + return ( + + + {intl.formatMessage(messages.totalOrdersLabel)} + {total} + + + + {intl.formatMessage( + messages.affiliatesOrdersTableOrderTotalColumnLabel + )} + + + {intl.formatNumber(totalOrderSum, { + style: 'currency', + currency, + })} + + + + + {intl.formatMessage( + messages.affiliatesOrdersTableOrderTotalCommissionColumnLabel + )} + + + {intl.formatNumber(totalCommissionSum, { + style: 'currency', + currency, + })} + + + + ) +} + +export default Totalizers From fbc18b0a565081013f89dab9296bdce001d2c777 Mon Sep 17 00:00:00 2001 From: gabrielHosino Date: Thu, 10 Mar 2022 10:15:30 -0300 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 616d297..b4397bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +- Totalizers area for the affiliate orders table +- Totalizers variable to affiliatesOrders query + ## [0.43.0] - 2022-03-10 ### Added