diff --git a/frontend/appflowy_web_app/src/components/database/components/calendar/toolbar/Toolbar.tsx b/frontend/appflowy_web_app/src/components/database/components/calendar/toolbar/Toolbar.tsx index f63014253a..9b8f41d398 100644 --- a/frontend/appflowy_web_app/src/components/database/components/calendar/toolbar/Toolbar.tsx +++ b/frontend/appflowy_web_app/src/components/database/components/calendar/toolbar/Toolbar.tsx @@ -23,7 +23,7 @@ export function Toolbar({ return (
-
{dateStr}
+
{dateStr}
onNavigate('PREV')}> diff --git a/frontend/appflowy_web_app/src/components/database/components/grid/grid-calculation-cell/CalculationCell.tsx b/frontend/appflowy_web_app/src/components/database/components/grid/grid-calculation-cell/CalculationCell.tsx index 1ddb4e2d32..dc01492f2d 100644 --- a/frontend/appflowy_web_app/src/components/database/components/grid/grid-calculation-cell/CalculationCell.tsx +++ b/frontend/appflowy_web_app/src/components/database/components/grid/grid-calculation-cell/CalculationCell.tsx @@ -1,4 +1,8 @@ +import { YjsDatabaseKey } from '@/application/collab.type'; +import { currencyFormaterMap, FieldType, parseNumberTypeOptions, useFieldSelector } from '@/application/database-yjs'; import { CalculationType } from '@/application/database-yjs/database.type'; +import Decimal from 'decimal.js'; +import { isNaN } from 'lodash-es'; import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -16,6 +20,16 @@ export interface CalculationCellProps { export function CalculationCell({ cell }: CalculationCellProps) { const { t } = useTranslation(); + const fieldId = cell?.fieldId || ''; + const { field } = useFieldSelector(fieldId); + const format = useMemo( + () => + field && Number(field?.get(YjsDatabaseKey.type)) === FieldType.Number + ? parseNumberTypeOptions(field).format + : undefined, + [field] + ); + const prefix = useMemo(() => { if (!cell) return ''; @@ -39,10 +53,22 @@ export function CalculationCell({ cell }: CalculationCellProps) { } }, [cell, t]); + const num = useMemo(() => { + const value = cell?.value; + + if (value === undefined || isNaN(value)) return ''; + + if (format && currencyFormaterMap[format]) { + return currencyFormaterMap[format](new Decimal(value).toNumber()); + } + + return parseFloat(value); + }, [cell?.value, format]); + return ( -
- {prefix} - {cell?.value ?? ''} +
+ {prefix} + {num}
); } diff --git a/frontend/appflowy_web_app/src/components/database/components/grid/grid-header/GridHeader.tsx b/frontend/appflowy_web_app/src/components/database/components/grid/grid-header/GridHeader.tsx index 2f269f823a..d08b060d2d 100644 --- a/frontend/appflowy_web_app/src/components/database/components/grid/grid-header/GridHeader.tsx +++ b/frontend/appflowy_web_app/src/components/database/components/grid/grid-header/GridHeader.tsx @@ -1,3 +1,4 @@ +import { DEFAULT_ROW_HEIGHT } from '@/application/database-yjs'; import React, { memo, useCallback, useEffect, useRef } from 'react'; import { areEqual, GridChildComponentProps, VariableSizeGrid } from 'react-window'; import AutoSizer from 'react-virtualized-auto-sizer'; @@ -53,7 +54,7 @@ export const GridHeader = ({ scrollLeft, onScrollLeft, columnWidth, columns }: G className={'grid-sticky-header w-full text-text-title'} height={height} width={width} - rowHeight={() => 36} + rowHeight={() => DEFAULT_ROW_HEIGHT} rowCount={1} columnCount={columns.length} columnWidth={(index) => {