Compare commits

..

2 Commits

Author SHA1 Message Date
Pramod Mahajan
777b8d8d0b set up deafult dates 2025-04-14 17:30:29 +05:30
Pramod Mahajan
c83161d5ab Breadcrumb changed 2025-04-14 17:23:36 +05:30
2 changed files with 19 additions and 12 deletions

View File

@ -1,22 +1,29 @@
import React, { useEffect, useRef } from 'react'; import React, { useEffect, useRef } from "react";
const DateRangePicker = ({ onRangeChange }) => { const DateRangePicker = ({ onRangeChange }) => {
const inputRef = useRef(null); const inputRef = useRef(null);
useEffect(() => { useEffect(() => {
const today = new Date();
const fifteenDaysAgo = new Date();
fifteenDaysAgo.setDate(today.getDate() - 15);
const fp = flatpickr(inputRef.current, { const fp = flatpickr(inputRef.current, {
mode: "range", mode: "range",
dateFormat: "Y-m-d", dateFormat: "Y-m-d",
static: true, defaultDate: [fifteenDaysAgo, today], // set default range
clickOpens: true, static: true,
onChange: (selectedDates, dateStr) => { clickOpens: true,
const [startDate, endDate] = dateStr.split(" to "); onChange: (selectedDates, dateStr) => {
onRangeChange?.({ startDate, endDate }); const [startDate, endDate] = dateStr.split(" to ");
} onRangeChange?.({ startDate, endDate });
}); },
});
return () => { return () => {
// Cleanup Flatpickr instance
fp.destroy(); fp.destroy();
}; };
}, [onRangeChange]); }, [onRangeChange]);

View File

@ -91,7 +91,7 @@ const DailyTask = () => {
<Breadcrumb <Breadcrumb
data={[ data={[
{ label: "Home", link: "/dashboard" }, { label: "Home", link: "/dashboard" },
{ label: "Attendance", link: null }, { label: "Daily Task", link: null },
]} ]}
></Breadcrumb> ></Breadcrumb>
<div className="card card-action mb-6"> <div className="card card-action mb-6">