feat: enhance dual-range-slider handling in DynamicFilter component
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 12m44s

This commit is contained in:
2025-07-04 23:11:01 +05:00
parent f6e60c0188
commit f4c34d3b7b

View File

@ -315,25 +315,14 @@ export default function DynamicFilter<
}> = [];
for (const input of inputs) {
const urlValue = searchParams.get(input.name);
if (urlValue) {
if (input.type === "checkbox-group") {
const deserialize = input.deserialize || defaultDeserialize;
const deserialized = deserialize(urlValue);
if (deserialized.length > 0) {
filters.push({
key: input.name,
value: deserialized,
label: input.label,
config: input,
});
}
} else if (input.type === "dual-range-slider") {
const minValue = searchParams.get(`${input.name}_min`);
const maxValue = searchParams.get(`${input.name}_max`);
if (minValue && maxValue) {
const parsedMin = Number(minValue);
const parsedMax = Number(maxValue);
if (input.type === "dual-range-slider") {
const minValue = searchParams.get(`${input.name}_min`);
const maxValue = searchParams.get(`${input.name}_max`);
if (minValue && maxValue) {
const parsedMin = Number(minValue);
const parsedMax = Number(maxValue);
// Only show as applied filter if values are different from defaults
if (parsedMin !== input.min || parsedMax !== input.max) {
filters.push({
key: input.name,
value: [parsedMin, parsedMax],
@ -341,13 +330,29 @@ export default function DynamicFilter<
config: input,
});
}
} else {
filters.push({
key: input.name,
value: urlValue,
label: input.label,
config: input,
});
}
} else {
const urlValue = searchParams.get(input.name);
if (urlValue) {
if (input.type === "checkbox-group") {
const deserialize = input.deserialize || defaultDeserialize;
const deserialized = deserialize(urlValue);
if (deserialized.length > 0) {
filters.push({
key: input.name,
value: deserialized,
label: input.label,
config: input,
});
}
} else {
filters.push({
key: input.name,
value: urlValue,
label: input.label,
config: input,
});
}
}
}
}
@ -577,4 +582,4 @@ export default function DynamicFilter<
</div>
</div>
);
}
}