You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
import { SliderComponent as Slider } from "../../components/SliderComponent";
|
|
import { useFilters } from "../../stores/useFilters";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { api } from "../../api";
|
|
import { useEffect } from "react";
|
|
import { useHasManualEdits } from "../../stores/usePointSelection";
|
|
|
|
export const PredictionSlider = () => {
|
|
const { filters, setPrediction } = useFilters();
|
|
const hasManualEdits = useHasManualEdits();
|
|
const { data } = useQuery(["max-min"], async () => {
|
|
const { data } = await api.get(`/api/placement_points/filters`);
|
|
|
|
return data;
|
|
});
|
|
|
|
const handleAfterChange = (range) => setPrediction(range);
|
|
|
|
useEffect(() => {
|
|
if (!data) return;
|
|
|
|
const min = data.prediction_current[0];
|
|
const max = data.prediction_current[1];
|
|
|
|
setPrediction([min, max]);
|
|
}, [data]);
|
|
|
|
// if (!data) return null;
|
|
|
|
return (
|
|
<Slider
|
|
title={"Прогнозный трафик, чел."}
|
|
value={filters.prediction}
|
|
onAfterChange={handleAfterChange}
|
|
min={200}
|
|
max={299}
|
|
range
|
|
disabled={hasManualEdits}
|
|
/>
|
|
);
|
|
};
|