From 7f293bcdaa597b579a57a7cb4cee266bdf0a4dfc Mon Sep 17 00:00:00 2001 From: Alexandre Monjol Date: Mon, 9 Sep 2024 12:48:05 +0100 Subject: [PATCH] chore: change default table rowSize --- src/components/designSystem/Table/Table.tsx | 4 +- src/pages/__devOnly/DesignSystem.tsx | 54 ++++++++++++++++++++- src/pages/__devOnly/fixtures.ts | 50 +++++++++++++++++++ 3 files changed, 104 insertions(+), 4 deletions(-) diff --git a/src/components/designSystem/Table/Table.tsx b/src/components/designSystem/Table/Table.tsx index 947f2ffc4..245f038c5 100644 --- a/src/components/designSystem/Table/Table.tsx +++ b/src/components/designSystem/Table/Table.tsx @@ -57,7 +57,7 @@ export type ActionItem = { } type ContainerSize = 0 | 4 | 16 | 48 -type RowSize = 44 | 56 +type RowSize = 48 | 72 interface TableProps { name: string @@ -94,7 +94,7 @@ export const Table = ({ isLoading, hasError, containerSize = 48, - rowSize = 56, + rowSize = 48, placeholder, onRowAction, actionColumn, diff --git a/src/pages/__devOnly/DesignSystem.tsx b/src/pages/__devOnly/DesignSystem.tsx index 463f8a848..cabec9f89 100644 --- a/src/pages/__devOnly/DesignSystem.tsx +++ b/src/pages/__devOnly/DesignSystem.tsx @@ -1,5 +1,5 @@ /* eslint-disable no-alert */ -import { InputAdornment, Stack } from '@mui/material' +import { Box, InputAdornment, Stack } from '@mui/material' import { useFormik } from 'formik' import { useRef } from 'react' import { generatePath, Link } from 'react-router-dom' @@ -49,7 +49,12 @@ import { addToast } from '~/core/apolloClient' import { intlFormatNumber } from '~/core/formats/intlFormatNumber' import { ONLY_DEV_DESIGN_SYSTEM_ROUTE, ONLY_DEV_DESIGN_SYSTEM_TAB_ROUTE } from '~/core/router' import { CurrencyEnum } from '~/generated/graphql' -import { chargeTableData, POSSIBLE_TOAST, tableData } from '~/pages/__devOnly/fixtures' +import { + chargeTableData, + currentUsageTableData, + POSSIBLE_TOAST, + tableData, +} from '~/pages/__devOnly/fixtures' import Stripe from '~/public/images/stripe.svg' import { MenuPopper, PageHeader, theme } from '~/styles' @@ -612,6 +617,51 @@ const DesignSystem = () => { }, ]} /> + + ( + + + {row.chargeName} + + + {row.chargeCode} + {row.hasFilterBreakdown ? ' • with breakdown' : ''} + + + ), + }, + { + key: 'units', + title: 'Units', + content: (row) => ( + + {row.units} + + ), + }, + { + key: 'amount', + title: 'Amount', + textAlign: 'right', + content: (row) => ( + + {intlFormatNumber(row.amount)} + + ), + }, + ]} + onRowAction={(item) => alert(`You clicked on ${item.id}`)} + /> ), diff --git a/src/pages/__devOnly/fixtures.ts b/src/pages/__devOnly/fixtures.ts index 567c1d22d..e00be80d5 100644 --- a/src/pages/__devOnly/fixtures.ts +++ b/src/pages/__devOnly/fixtures.ts @@ -104,3 +104,53 @@ export const chargeTableData: Array<{ icon: 'company', }, ] + +export const currentUsageTableData: Array<{ + id: string + amount: number + chargeCode: string + chargeName: string + hasFilterBreakdown: boolean + units: number +}> = [ + { + id: '0', + chargeName: 'GiB Hours', + chargeCode: 'memory_heartbeat', + hasFilterBreakdown: true, + amount: 1000, + units: 123, + }, + { + id: '1', + chargeName: 'CPU Hours', + chargeCode: 'cpu_heartbeat', + hasFilterBreakdown: false, + amount: 1000, + units: 123, + }, + { + id: '2', + chargeName: 'SOC2 Compliance', + chargeCode: 'compliance', + hasFilterBreakdown: false, + amount: 1000, + units: 123, + }, + { + id: '3', + chargeName: 'Datastores', + chargeCode: 'datastores', + hasFilterBreakdown: false, + amount: 1000, + units: 123, + }, + { + id: '4', + chargeName: 'Multi Cluster', + chargeCode: 'multicluster', + hasFilterBreakdown: false, + amount: 1000, + units: 123, + }, +]