parent
46782ec139
commit
4326a46dd0
1 changed files with 10 additions and 5 deletions
|
@ -60,11 +60,6 @@ export const TimeSelector = ({
|
||||||
}: TimeSelectorProps) => {
|
}: TimeSelectorProps) => {
|
||||||
const { t } = useTranslation("common");
|
const { t } = useTranslation("common");
|
||||||
|
|
||||||
const times = useMemo(
|
|
||||||
() => units.map((unit) => allTimes.find((time) => time.unit === unit)!),
|
|
||||||
[units]
|
|
||||||
);
|
|
||||||
|
|
||||||
const defaultMultiplier = useMemo(
|
const defaultMultiplier = useMemo(
|
||||||
() => allTimes.find((time) => time.unit === units[0])?.multiplier,
|
() => allTimes.find((time) => time.unit === units[0])?.multiplier,
|
||||||
[units]
|
[units]
|
||||||
|
@ -74,6 +69,16 @@ export const TimeSelector = ({
|
||||||
const [multiplier, setMultiplier] = useState(defaultMultiplier);
|
const [multiplier, setMultiplier] = useState(defaultMultiplier);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const times = useMemo(() => {
|
||||||
|
const filteredUnits = units.map(
|
||||||
|
(unit) => allTimes.find((time) => time.unit === unit)!
|
||||||
|
);
|
||||||
|
if (!filteredUnits.every((u) => u.multiplier === multiplier)) {
|
||||||
|
filteredUnits.unshift(allTimes[0]);
|
||||||
|
}
|
||||||
|
return filteredUnits;
|
||||||
|
}, [units, multiplier]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const multiplier = getTimeUnit(value).multiplier;
|
const multiplier = getTimeUnit(value).multiplier;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue