Skip to content

The open alternative to Salesforce, designed for AI.

fix: can't set ARR of company to empty (#1474)

Jérémy M08b56ec7e2b9
diff --git a/front/src/modules/ui/editable-field/types/ViewField.ts b/front/src/modules/ui/editable-field/types/ViewField.ts
index 3a9a49f6c94..55288f2e607 100644
--- a/front/src/modules/ui/editable-field/types/ViewField.ts
+++ b/front/src/modules/ui/editable-field/types/ViewField.ts
@@ -130,7 +130,7 @@ export type ViewFieldDateValue = string;
export type ViewFieldPhoneValue = string;
export type ViewFieldEmailValue = string;
export type ViewFieldBooleanValue = boolean;
-export type ViewFieldMoneyValue = number;
+export type ViewFieldMoneyValue = number | null;
export type ViewFieldURLValue = string;
export type ViewFieldNumberValue = number | null;
export type ViewFieldProbabilityValue = number;
diff --git a/front/src/modules/ui/editable-field/types/guards/isViewFieldMoneyValue.ts b/front/src/modules/ui/editable-field/types/guards/isViewFieldMoneyValue.ts
index 11983b9e69c..db233d3b62c 100644
--- a/front/src/modules/ui/editable-field/types/guards/isViewFieldMoneyValue.ts
+++ b/front/src/modules/ui/editable-field/types/guards/isViewFieldMoneyValue.ts
@@ -3,5 +3,8 @@ import { ViewFieldMoneyValue } from '../ViewField';
export function isViewFieldMoneyValue(
fieldValue: unknown,
): fieldValue is ViewFieldMoneyValue {
- return typeof fieldValue === 'number';
+ return (
+ fieldValue === null ||
+ (fieldValue !== undefined && typeof fieldValue === 'number')
+ );
}
diff --git a/front/src/modules/ui/table/editable-cell/type/components/GenericEditableMoneyCellEditMode.tsx b/front/src/modules/ui/table/editable-cell/type/components/GenericEditableMoneyCellEditMode.tsx
index e4f153b2db9..d136f4b205b 100644
--- a/front/src/modules/ui/table/editable-cell/type/components/GenericEditableMoneyCellEditMode.tsx
+++ b/front/src/modules/ui/table/editable-cell/type/components/GenericEditableMoneyCellEditMode.tsx
@@ -31,17 +31,17 @@ export function GenericEditableMoneyCellEditMode({
if (newText === fieldValue) return;
try {
- const numberValue = parseInt(newText);
+ const numberValue = newText !== '' ? parseInt(newText) : null;
- if (isNaN(numberValue)) {
+ if (numberValue && isNaN(numberValue)) {
throw new Error('Not a number');
}
- if (numberValue > 2000000000) {
+ if (numberValue && numberValue > 2000000000) {
throw new Error('Number too big');
}
- setFieldValue(numberValue.toString());
+ setFieldValue(numberValue ? numberValue.toString() : '');
if (currentRowEntityId && updateField) {
updateField(currentRowEntityId, columnDefinition, numberValue);