Unified · Split
| @@ -82,7 +82,10 @@ export const EndpointSpecForm = ({ id, type }: EndpointSpecFormProps) => { · 81 unmodified lines | ||
| 82 | 82 | setIsLoading(true); |
| 83 | 83 | try { |
| 84 | 84 | // Check if all values are empty, if so, send null to clear the database |
| 85 | − const hasAnyValue = formData.Mode !== undefined && formData.Mode !== null && formData.Mode !== ""; | |
| 85 | + const hasAnyValue = | |
| 86 | + formData.Mode !== undefined && | |
| 87 | + formData.Mode !== null && | |
| 88 | + formData.Mode !== ""; | |
| 86 | 89 | |
| 87 | 90 | await mutateAsync({ |
| 88 | 91 | applicationId: id || "", |
| @@ -90,7 +90,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => { · 89 unmodified lines | ||
| 90 | 90 | setIsLoading(true); |
| 91 | 91 | try { |
| 92 | 92 | // Check if all values are empty, if so, send null to clear the database |
| 93 | − const hasAnyValue = | |
| 93 | + const hasAnyValue = | |
| 94 | 94 | (formData.Test && formData.Test.length > 0) || |
| 95 | 95 | formData.Interval !== undefined || |
| 96 | 96 | formData.Timeout !== undefined || |
| @@ -103,7 +103,7 @@ export const PlacementForm = ({ id, type }: PlacementFormProps) => { · 102 unmodified lines | ||
| 103 | 103 | setIsLoading(true); |
| 104 | 104 | try { |
| 105 | 105 | // Check if all values are empty, if so, send null to clear the database |
| 106 | − const hasAnyValue = | |
| 106 | + const hasAnyValue = | |
| 107 | 107 | (formData.Constraints && formData.Constraints.length > 0) || |
| 108 | 108 | (formData.Preferences && formData.Preferences.length > 0) || |
| 109 | 109 | (formData.Platforms && formData.Platforms.length > 0) || |
| @@ -94,7 +94,7 @@ export const RestartPolicyForm = ({ id, type }: RestartPolicyFormProps) => { · 93 unmodified lines | ||
| 94 | 94 | try { |
| 95 | 95 | // Check if all values are empty, if so, send null to clear the database |
| 96 | 96 | const hasAnyValue = Object.values(formData).some( |
| 97 | − value => value !== undefined && value !== null && value !== "" | |
| 97 | + (value) => value !== undefined && value !== null && value !== "", | |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | 100 | await mutateAsync({ |
| @@ -93,7 +93,7 @@ export const RollbackConfigForm = ({ id, type }: RollbackConfigFormProps) => { · 92 unmodified lines | ||
| 93 | 93 | try { |
| 94 | 94 | // Check if all values are empty, if so, send null to clear the database |
| 95 | 95 | const hasAnyValue = Object.values(formData).some( |
| 96 | − value => value !== undefined && value !== null && value !== "" | |
| 96 | + (value) => value !== undefined && value !== null && value !== "", | |
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | 99 | await mutateAsync({ |
| @@ -119,9 +119,15 @@ export const StopGracePeriodForm = ({ id, type }: StopGracePeriodFormProps) => { · 118 unmodified lines | ||
| 119 | 119 | type="number" |
| 120 | 120 | placeholder="30000000000" |
| 121 | 121 | {...field} |
| 122 | − value={field?.value !== null && field?.value !== undefined ? field.value.toString() : ""} | |
| 122 | + value={ | |
| 123 | + field?.value !== null && field?.value !== undefined | |
| 124 | + ? field.value.toString() | |
| 125 | + : "" | |
| 126 | + } | |
| 123 | 127 | onChange={(e) => |
| 124 | − field.onChange(e.target.value ? BigInt(e.target.value) : null) | |
| 128 | + field.onChange( | |
| 129 | + e.target.value ? BigInt(e.target.value) : null, | |
| 130 | + ) | |
| 125 | 131 | } |
| 126 | 132 | /> |
| 127 | 133 | </FormControl> |
| @@ -99,7 +99,7 @@ export const UpdateConfigForm = ({ id, type }: UpdateConfigFormProps) => { · 98 unmodified lines | ||
| 99 | 99 | try { |
| 100 | 100 | // Check if all values are empty, if so, send null to clear the database |
| 101 | 101 | const hasAnyValue = Object.values(formData).some( |
| 102 | − value => value !== undefined && value !== null && value !== "" | |
| 102 | + (value) => value !== undefined && value !== null && value !== "", | |
| 103 | 103 | ); |
| 104 | 104 | |
| 105 | 105 | await mutateAsync({ |
| @@ -2,20 +2,25 @@ · 1 unmodified line | ||
| 2 | 2 | * Filters out undefined, null, and empty string values from form data |
| 3 | 3 | * Only returns fields that have actual values |
| 4 | 4 | */ |
| 5 | −export const filterEmptyValues = (formData: Record<string, any>): Record<string, any> => { | |
| 6 | − return Object.entries(formData).reduce((acc, [key, value]) => { | |
| 7 | − // Keep arrays even if empty (they might be intentionally cleared) | |
| 8 | − if (Array.isArray(value)) { | |
| 9 | − if (value.length > 0) { | |
| 5 | +export const filterEmptyValues = ( | |
| 6 | + formData: Record<string, any>, | |
| 7 | +): Record<string, any> => { | |
| 8 | + return Object.entries(formData).reduce( | |
| 9 | + (acc, [key, value]) => { | |
| 10 | + // Keep arrays even if empty (they might be intentionally cleared) | |
| 11 | + if (Array.isArray(value)) { | |
| 12 | + if (value.length > 0) { | |
| 13 | + acc[key] = value; | |
| 14 | + } | |
| 15 | + } | |
| 16 | + // For other values, filter out undefined, null, and empty strings | |
| 17 | + else if (value !== undefined && value !== null && value !== "") { | |
| 10 | 18 | acc[key] = value; |
| 11 | 19 | } |
| 12 | − } | |
| 13 | − // For other values, filter out undefined, null, and empty strings | |
| 14 | − else if (value !== undefined && value !== null && value !== "") { | |
| 15 | − acc[key] = value; | |
| 16 | − } | |
| 17 | − return acc; | |
| 18 | − }, {} as Record<string, any>); | |
| 20 | + return acc; | |
| 21 | + }, | |
| 22 | + {} as Record<string, any>, | |
| 23 | + ); | |
| 19 | 24 | }; |
| 20 | 25 | |
| 21 | 26 | /** |