Compare commits
	
		
			2 Commits
		
	
	
		
			c1a31e6b3e
			...
			475f7b564e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 475f7b564e | |||
| e85dfb3922 | 
@ -3,7 +3,7 @@ import React, { useEffect, useRef } from "react";
 | 
				
			|||||||
const DateRangePicker = ({
 | 
					const DateRangePicker = ({
 | 
				
			||||||
  onRangeChange,
 | 
					  onRangeChange,
 | 
				
			||||||
  DateDifference = 7, 
 | 
					  DateDifference = 7, 
 | 
				
			||||||
  endDateMode = "yesterday", // "today" or "yesterday"
 | 
					  endDateMode = "yesterday",
 | 
				
			||||||
}) => {
 | 
					}) => {
 | 
				
			||||||
  const inputRef = useRef(null);
 | 
					  const inputRef = useRef(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -13,8 +13,11 @@ const DateRangePicker = ({
 | 
				
			|||||||
      endDate.setDate(endDate.getDate() - 1); 
 | 
					      endDate.setDate(endDate.getDate() - 1); 
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const startDate = new Date();
 | 
					    endDate.setHours(0, 0, 0, 0);
 | 
				
			||||||
    startDate.setDate(endDate.getDate() - DateDifference);
 | 
					
 | 
				
			||||||
 | 
					    const startDate = new Date(endDate); 
 | 
				
			||||||
 | 
					    startDate.setDate(endDate.getDate() - (DateDifference - 1));
 | 
				
			||||||
 | 
					    startDate.setHours(0, 0, 0, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const fp = flatpickr(inputRef.current, {
 | 
					    const fp = flatpickr(inputRef.current, {
 | 
				
			||||||
      mode: "range",
 | 
					      mode: "range",
 | 
				
			||||||
@ -25,8 +28,8 @@ const DateRangePicker = ({
 | 
				
			|||||||
      static: true,       
 | 
					      static: true,       
 | 
				
			||||||
      clickOpens: true,   
 | 
					      clickOpens: true,   
 | 
				
			||||||
      onChange: (selectedDates, dateStr) => {
 | 
					      onChange: (selectedDates, dateStr) => {
 | 
				
			||||||
        const [startDate, endDate] = dateStr.split(" to ");
 | 
					        const [startDateString, endDateString] = dateStr.split(" to ");
 | 
				
			||||||
        onRangeChange?.({ startDate, endDate });
 | 
					        onRangeChange?.({ startDate: startDateString, endDate: endDateString });
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user