From 796b03f15dd706e18bd27f90cd60de208ed2a71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C6=B0=E1=BB=9Dng=20An?= Date: Mon, 13 Jul 2020 16:50:06 +0700 Subject: [PATCH 1/6] fix: update cost explorer (#2051) --- .../__test__/cost-explorer-table.test.tsx | 33 +++++++++++++++++++ .../cost-explorer-table.tsx | 15 ++++++--- .../src/tests/badges/badge-branches.svg | 2 +- .../src/tests/badges/badge-functions.svg | 2 +- .../src/tests/badges/badge-statements.svg | 2 +- 5 files changed, 47 insertions(+), 7 deletions(-) diff --git a/packages/developer-portal/src/components/pages/analytics/cost-explorer/cost-explorer-component/__test__/cost-explorer-table.test.tsx b/packages/developer-portal/src/components/pages/analytics/cost-explorer/cost-explorer-component/__test__/cost-explorer-table.test.tsx index a36f46b574..4f3a35dbc4 100644 --- a/packages/developer-portal/src/components/pages/analytics/cost-explorer/cost-explorer-component/__test__/cost-explorer-table.test.tsx +++ b/packages/developer-portal/src/components/pages/analytics/cost-explorer/cost-explorer-component/__test__/cost-explorer-table.test.tsx @@ -31,4 +31,37 @@ describe('prepareTableData', () => { const { services = [] } = monthlyBillingData expect(prepareTableData(services)).toEqual(tableData) }) + + it('should return correct data', () => { + const { services = [] } = monthlyBillingData + const input = [ + ...services, + { + cost: 7.975, + itemCount: 7, + amount: 638, + items: [{ name: 'contacts', amount: 157, cost: 1.9625, itemCount: 2 }], + name: 'TEST', + }, + ] + + const expected = [ + { + amount: 638, + cost: 7.975, + itemCount: 7, + name: 'API Requests', + subRows: [{ name: 'contacts', amount: 157, cost: 1.9625, itemCount: 2, subRows: [] }], + }, + { + cost: 7.975, + itemCount: null, + amount: 638, + subRows: [{ name: 'contacts', amount: 157, cost: 1.9625, itemCount: null, subRows: [] }], + name: 'TEST', + }, + ] + + expect(prepareTableData(input)).toEqual(expected) + }) }) diff --git a/packages/developer-portal/src/components/pages/analytics/cost-explorer/cost-explorer-component/cost-explorer-table.tsx b/packages/developer-portal/src/components/pages/analytics/cost-explorer/cost-explorer-component/cost-explorer-table.tsx index 76f463e1da..3f07c9e0c4 100644 --- a/packages/developer-portal/src/components/pages/analytics/cost-explorer/cost-explorer-component/cost-explorer-table.tsx +++ b/packages/developer-portal/src/components/pages/analytics/cost-explorer/cost-explorer-component/cost-explorer-table.tsx @@ -5,11 +5,19 @@ import { useSelector } from 'react-redux' import { selectMonthlyBilling, selectMonthlyBillingLoading } from '@/selector/developer' import { BillingBreakdownForMonthV2Model, ServiceItemBillingV2Model } from '@reapit/foundations-ts-definitions' -export const prepareTableData = (data: ServiceItemBillingV2Model[]) => { +export const prepareTableData = (data: ServiceItemBillingV2Model[], serviceName?: string) => { if (!data || !data.length) return [] - return data.map(({ items = [], ...row }) => { - return { ...row, subRows: prepareTableData(items) } + return data.map(({ items = [], itemCount, ...row }) => { + const service = serviceName || row.name + const isApiRequests = service === 'API Requests' + + const rowData = { + ...row, + itemCount: isApiRequests && itemCount ? itemCount : null, + subRows: prepareTableData(items, service), + } + return rowData }) } @@ -21,7 +29,6 @@ export const prepareTableColumns = (monthlyBilling?: BillingBreakdownForMonthV2M Header: 'Services', accessor: 'name', columnProps: { - className: 'capitalize', width: 200, }, Footer: 'Total', diff --git a/packages/developer-portal/src/tests/badges/badge-branches.svg b/packages/developer-portal/src/tests/badges/badge-branches.svg index bc9049555a..71bec2ae8d 100644 --- a/packages/developer-portal/src/tests/badges/badge-branches.svg +++ b/packages/developer-portal/src/tests/badges/badge-branches.svg @@ -1 +1 @@ -Coverage:branchesCoverage:branches68.64%68.64% \ No newline at end of file +Coverage:branchesCoverage:branches68.64%68.64% diff --git a/packages/developer-portal/src/tests/badges/badge-functions.svg b/packages/developer-portal/src/tests/badges/badge-functions.svg index c5dbd4c6b6..fdd5a0dcb5 100644 --- a/packages/developer-portal/src/tests/badges/badge-functions.svg +++ b/packages/developer-portal/src/tests/badges/badge-functions.svg @@ -1 +1 @@ -Coverage:functionsCoverage:functions79.36%79.36% \ No newline at end of file +Coverage:functionsCoverage:functions79.36%79.36% diff --git a/packages/developer-portal/src/tests/badges/badge-statements.svg b/packages/developer-portal/src/tests/badges/badge-statements.svg index 9b15b3d0ec..6bde774ac5 100644 --- a/packages/developer-portal/src/tests/badges/badge-statements.svg +++ b/packages/developer-portal/src/tests/badges/badge-statements.svg @@ -1 +1 @@ -Coverage:statementsCoverage:statements88.79%88.79% \ No newline at end of file +Coverage:statementsCoverage:statements88.79%88.79% From 5412dbfb9f43ce82407681f1c0c8e17ef4eea43c Mon Sep 17 00:00:00 2001 From: Pham Hai Duong Date: Mon, 13 Jul 2020 16:54:09 +0700 Subject: [PATCH 2/6] fix: #1037 initial default for travel mode and time (#2048) --- .../src/components/pages/login/__styles__/index.ts | 2 +- .../components/ui/appointment-time/appointment-time.tsx | 7 ++++--- .../src/components/ui/list-and-map-tab/__styles__/index.ts | 2 +- .../src/components/ui/travel-mode/travel-mode.tsx | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/geo-diary-v2/src/components/pages/login/__styles__/index.ts b/packages/geo-diary-v2/src/components/pages/login/__styles__/index.ts index 8aa3aa2145..a2dbb4f8b8 100644 --- a/packages/geo-diary-v2/src/components/pages/login/__styles__/index.ts +++ b/packages/geo-diary-v2/src/components/pages/login/__styles__/index.ts @@ -7,7 +7,7 @@ export const loginPageContainer = css` justify-content: flex-end; align-items: center; flex-direction: row; - + background-color: white; @media screen and (max-width: 900px) { flex-direction: column-reverse; } diff --git a/packages/geo-diary-v2/src/components/ui/appointment-time/appointment-time.tsx b/packages/geo-diary-v2/src/components/ui/appointment-time/appointment-time.tsx index 311f1f6ed4..64b8052843 100644 --- a/packages/geo-diary-v2/src/components/ui/appointment-time/appointment-time.tsx +++ b/packages/geo-diary-v2/src/components/ui/appointment-time/appointment-time.tsx @@ -1,5 +1,6 @@ import * as React from 'react' import { ButtonGroup, Button } from '@reapit/elements' +import { cx } from 'linaria' import { History } from 'history' import qs from 'query-string' import { ROUTES } from '@/core/router' @@ -26,7 +27,7 @@ export const AppointmentTime = ({ queryParams, history }: AppointmentTimeProps)