mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-09 13:35:19 +00:00
feat: set default date range to last 3 days in ShowRequests component
- Introduced a function to automatically set the date range to the last 3 days upon component initialization. - Updated the reset button to restore the default date range instead of clearing the dates.
This commit is contained in:
@@ -51,13 +51,19 @@ export const ShowRequests = () => {
|
|||||||
const { mutateAsync: updateLogCleanup } =
|
const { mutateAsync: updateLogCleanup } =
|
||||||
api.settings.updateLogCleanup.useMutation();
|
api.settings.updateLogCleanup.useMutation();
|
||||||
const [cronExpression, setCronExpression] = useState<string | null>(null);
|
const [cronExpression, setCronExpression] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Set default date range to last 3 days
|
||||||
|
const getDefaultDateRange = () => {
|
||||||
|
const to = new Date();
|
||||||
|
const from = new Date();
|
||||||
|
from.setDate(from.getDate() - 3);
|
||||||
|
return { from, to };
|
||||||
|
};
|
||||||
|
|
||||||
const [dateRange, setDateRange] = useState<{
|
const [dateRange, setDateRange] = useState<{
|
||||||
from: Date | undefined;
|
from: Date | undefined;
|
||||||
to: Date | undefined;
|
to: Date | undefined;
|
||||||
}>({
|
}>(getDefaultDateRange());
|
||||||
from: undefined,
|
|
||||||
to: undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (logCleanupStatus) {
|
if (logCleanupStatus) {
|
||||||
@@ -169,17 +175,13 @@ export const ShowRequests = () => {
|
|||||||
{isActive ? (
|
{isActive ? (
|
||||||
<>
|
<>
|
||||||
<div className="flex justify-end mb-4 gap-2">
|
<div className="flex justify-end mb-4 gap-2">
|
||||||
{(dateRange.from || dateRange.to) && (
|
<Button
|
||||||
<Button
|
variant="outline"
|
||||||
variant="outline"
|
onClick={() => setDateRange(getDefaultDateRange())}
|
||||||
onClick={() =>
|
className="px-3"
|
||||||
setDateRange({ from: undefined, to: undefined })
|
>
|
||||||
}
|
Reset to Last 3 Days
|
||||||
className="px-3"
|
</Button>
|
||||||
>
|
|
||||||
Clear dates
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Popover>
|
<Popover>
|
||||||
<PopoverTrigger asChild>
|
<PopoverTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user