File tree Expand file tree Collapse file tree
packages/components/src/ui Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,15 +211,38 @@ function FilterBuilder({
211211 }
212212
213213 // Default input for text, number, date
214+ const inputType = getInputType ( condition . field )
215+
216+ // Format value based on field type
217+ const formatValue = ( ) => {
218+ if ( ! condition . value ) return ""
219+ if ( inputType === "date" && typeof condition . value === "string" ) {
220+ // Ensure date is in YYYY-MM-DD format
221+ return condition . value . split ( 'T' ) [ 0 ]
222+ }
223+ return String ( condition . value )
224+ }
225+
226+ // Handle value change with proper type conversion
227+ const handleValueChange = ( newValue : string ) => {
228+ let convertedValue : string | number | boolean = newValue
229+
230+ if ( field ?. type === "number" && newValue !== "" ) {
231+ convertedValue = parseFloat ( newValue ) || 0
232+ } else if ( field ?. type === "date" ) {
233+ convertedValue = newValue // Keep as ISO string
234+ }
235+
236+ updateCondition ( condition . id , { value : convertedValue } )
237+ }
238+
214239 return (
215240 < Input
216- type = { getInputType ( condition . field ) }
241+ type = { inputType }
217242 className = "h-9 text-sm"
218243 placeholder = "Value"
219- value = { String ( condition . value || "" ) }
220- onChange = { ( e ) =>
221- updateCondition ( condition . id , { value : e . target . value } )
222- }
244+ value = { formatValue ( ) }
245+ onChange = { ( e ) => handleValueChange ( e . target . value ) }
223246 />
224247 )
225248 }
You can’t perform that action at this time.
0 commit comments