[WEB-4834] fix: range date picker weekStartsOn (#7699)
* fix: range date picker weekStartsOn * chore: code refactor
This commit is contained in:
parent
2d31b562d8
commit
779a96acb8
1 changed files with 8 additions and 2 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import { Placement } from "@popperjs/core";
|
import { Placement } from "@popperjs/core";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
import { DateRange, Matcher } from "react-day-picker";
|
import { DateRange, Matcher } from "react-day-picker";
|
||||||
import { usePopper } from "react-popper";
|
import { usePopper } from "react-popper";
|
||||||
import { ArrowRight, CalendarCheck2, CalendarDays, X } from "lucide-react";
|
import { ArrowRight, CalendarCheck2, CalendarDays, X } from "lucide-react";
|
||||||
|
|
@ -13,6 +14,7 @@ import { ComboDropDown, Calendar } from "@plane/ui";
|
||||||
import { cn, renderFormattedDate } from "@plane/utils";
|
import { cn, renderFormattedDate } from "@plane/utils";
|
||||||
// helpers
|
// helpers
|
||||||
// hooks
|
// hooks
|
||||||
|
import { useUserProfile } from "@/hooks/store/user";
|
||||||
import { useDropdown } from "@/hooks/use-dropdown";
|
import { useDropdown } from "@/hooks/use-dropdown";
|
||||||
// components
|
// components
|
||||||
import { DropdownButton } from "./buttons";
|
import { DropdownButton } from "./buttons";
|
||||||
|
|
@ -59,7 +61,7 @@ type Props = {
|
||||||
customTooltipHeading?: string;
|
customTooltipHeading?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DateRangeDropdown: React.FC<Props> = (props) => {
|
export const DateRangeDropdown: React.FC<Props> = observer((props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const {
|
const {
|
||||||
buttonClassName,
|
buttonClassName,
|
||||||
|
|
@ -95,6 +97,9 @@ export const DateRangeDropdown: React.FC<Props> = (props) => {
|
||||||
// states
|
// states
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [dateRange, setDateRange] = useState<DateRange>(value);
|
const [dateRange, setDateRange] = useState<DateRange>(value);
|
||||||
|
// hooks
|
||||||
|
const { data } = useUserProfile();
|
||||||
|
const startOfWeek = data?.start_of_the_week;
|
||||||
// refs
|
// refs
|
||||||
const dropdownRef = useRef<HTMLDivElement | null>(null);
|
const dropdownRef = useRef<HTMLDivElement | null>(null);
|
||||||
// popper-js refs
|
// popper-js refs
|
||||||
|
|
@ -274,6 +279,7 @@ export const DateRangeDropdown: React.FC<Props> = (props) => {
|
||||||
disabled={disabledDays}
|
disabled={disabledDays}
|
||||||
showOutsideDays
|
showOutsideDays
|
||||||
fixedWeeks
|
fixedWeeks
|
||||||
|
weekStartsOn={startOfWeek}
|
||||||
initialFocus
|
initialFocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -281,4 +287,4 @@ export const DateRangeDropdown: React.FC<Props> = (props) => {
|
||||||
)}
|
)}
|
||||||
</ComboDropDown>
|
</ComboDropDown>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue