refactor(FE-357): Use string weights and parse floats for filters

This commit is contained in:
rstubryan
2025-12-18 20:35:47 +07:00
parent 2f23755510
commit 00e0126e42
2 changed files with 8 additions and 16 deletions
@@ -117,7 +117,7 @@ const HppPerKandangTab = () => {
>( >(
(e) => { (e) => {
const val = e.target.value; const val = e.target.value;
updateFilter('weight_min', val ? String(parseInt(val, 10)) : ''); updateFilter('weight_min', val ? String(parseFloat(val) || 0) : '');
setIsSubmitted(false); setIsSubmitted(false);
}, },
[updateFilter] [updateFilter]
@@ -128,7 +128,7 @@ const HppPerKandangTab = () => {
>( >(
(e) => { (e) => {
const val = e.target.value; const val = e.target.value;
updateFilter('weight_max', val ? String(parseInt(val, 10)) : ''); updateFilter('weight_max', val ? String(parseFloat(val) || 0) : '');
setIsSubmitted(false); setIsSubmitted(false);
}, },
[updateFilter] [updateFilter]
@@ -189,12 +189,8 @@ const HppPerKandangTab = () => {
tableFilterState.kandang_id.length > 0 tableFilterState.kandang_id.length > 0
? tableFilterState.kandang_id.join(',') ? tableFilterState.kandang_id.join(',')
: undefined, : undefined,
weight_min: tableFilterState.weight_min weight_min: tableFilterState.weight_min || undefined,
? Number(tableFilterState.weight_min) weight_max: tableFilterState.weight_max || undefined,
: undefined,
weight_max: tableFilterState.weight_max
? Number(tableFilterState.weight_max)
: undefined,
period: tableFilterState.period || undefined, period: tableFilterState.period || undefined,
sort_by: tableFilterState.sort_by || undefined, sort_by: tableFilterState.sort_by || undefined,
show_unrecorded: tableFilterState.show_unrecorded, show_unrecorded: tableFilterState.show_unrecorded,
@@ -250,12 +246,8 @@ const HppPerKandangTab = () => {
tableFilterState.kandang_id.length > 0 tableFilterState.kandang_id.length > 0
? tableFilterState.kandang_id.join(',') ? tableFilterState.kandang_id.join(',')
: undefined, : undefined,
weight_min: tableFilterState.weight_min weight_min: tableFilterState.weight_min || undefined,
? Number(tableFilterState.weight_min) weight_max: tableFilterState.weight_max || undefined,
: undefined,
weight_max: tableFilterState.weight_max
? Number(tableFilterState.weight_max)
: undefined,
period: tableFilterState.period || undefined, period: tableFilterState.period || undefined,
sort_by: tableFilterState.sort_by || undefined, sort_by: tableFilterState.sort_by || undefined,
show_unrecorded: tableFilterState.show_unrecorded, show_unrecorded: tableFilterState.show_unrecorded,
+2 -2
View File
@@ -15,8 +15,8 @@ export class MarketingSaleReportService extends BaseApiService<
area_id?: string, area_id?: string,
location_id?: string, location_id?: string,
kandang_id?: string, kandang_id?: string,
weight_min?: number, weight_min?: string,
weight_max?: number, weight_max?: string,
period?: string, period?: string,
sort_by?: string, sort_by?: string,
show_unrecorded?: boolean, show_unrecorded?: boolean,