|
|
|
|
@ -4,20 +4,44 @@ import {
|
|
|
|
|
INITIAL,
|
|
|
|
|
usePendingPointsFilters,
|
|
|
|
|
} from "../../../stores/usePendingPointsFilters";
|
|
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
|
|
|
import { api } from "../../../api.js";
|
|
|
|
|
import { STATUSES } from "../../../config.js";
|
|
|
|
|
import { Spin } from "antd";
|
|
|
|
|
|
|
|
|
|
export const PredictionSlider = ({ disabled, fullRange }) => {
|
|
|
|
|
const useGetPredictionRange = () => {
|
|
|
|
|
return useQuery(
|
|
|
|
|
["prediction-max-min"],
|
|
|
|
|
async () => {
|
|
|
|
|
const { data } = await api.get(
|
|
|
|
|
`/api/placement_points/filters?status[]=${STATUSES.pending}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
select: (data) => {
|
|
|
|
|
return [data.prediction_current[0], data.prediction_current[1]];
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const PredictionSlider = ({ disabled }) => {
|
|
|
|
|
const {
|
|
|
|
|
filters: { prediction },
|
|
|
|
|
setPrediction,
|
|
|
|
|
} = usePendingPointsFilters();
|
|
|
|
|
|
|
|
|
|
const { data: fullRange, isInitialLoading } = useGetPredictionRange();
|
|
|
|
|
|
|
|
|
|
const handleAfterChange = (range) => setPrediction(range);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!fullRange) return;
|
|
|
|
|
|
|
|
|
|
const min = fullRange.prediction[0];
|
|
|
|
|
const max = fullRange.prediction[1];
|
|
|
|
|
const min = fullRange[0];
|
|
|
|
|
const max = fullRange[1];
|
|
|
|
|
|
|
|
|
|
const shouldSetFullRange =
|
|
|
|
|
prediction[0] === INITIAL.prediction[0] &&
|
|
|
|
|
@ -28,13 +52,21 @@ export const PredictionSlider = ({ disabled, fullRange }) => {
|
|
|
|
|
}
|
|
|
|
|
}, [fullRange]);
|
|
|
|
|
|
|
|
|
|
if (isInitialLoading) {
|
|
|
|
|
return (
|
|
|
|
|
<div className={"flex justify-center items-center"}>
|
|
|
|
|
<Spin />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Slider
|
|
|
|
|
title={"Прогнозный трафик"}
|
|
|
|
|
value={prediction}
|
|
|
|
|
onAfterChange={handleAfterChange}
|
|
|
|
|
min={fullRange?.prediction[0]}
|
|
|
|
|
max={fullRange?.prediction[1]}
|
|
|
|
|
min={fullRange[0]}
|
|
|
|
|
max={fullRange[1]}
|
|
|
|
|
range
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
/>
|
|
|
|
|
|