Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
guillim authored Dec 9, 2024
1 parent 8d469b9 commit 310bba7
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { useNumberFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useNumberFieldDisplay';
import { NumberDisplay } from '@/ui/field/display/components/NumberDisplay';
import { isDefined } from 'twenty-ui';
import { formatNumber } from '~/utils/format/number';

export const NumberFieldDisplay = () => {
const { fieldValue, fieldDefinition } = useNumberFieldDisplay();
const decimals = fieldDefinition.metadata.settings?.decimals;
const type = fieldDefinition.metadata.settings?.type;

if (!isDefined(fieldValue))
return <NumberDisplay value={null} decimals={decimals} />;
const value =
type === 'percentage' && fieldValue
type === 'percentage'
? `${formatNumber(Number(fieldValue) * 100, decimals)}%`
: fieldValue
? formatNumber(Number(fieldValue), decimals)
: null;
: formatNumber(Number(fieldValue), decimals);

return <NumberDisplay value={value} decimals={decimals} />;
};

0 comments on commit 310bba7

Please sign in to comment.