You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
1.0 KiB

// it has style inside index.scss ---> // Start SimpleCalendar && end SimpleCalendar
import React, { useEffect, useState } from "react";
import DatePicker from "../CalendarComponents";
import { utils } from "../CalendarComponents";
const SimpleDatePicker = ({returnValue,defaultValue,mode}) => {
const [selectedDay, setSelectedDay] = useState(defaultValue || null);
const gotoToday = () => {
setSelectedDay(utils("fa").getToday());
};
useEffect(() => {
if(mode){
returnValue(selectedDay, mode);
}
else{
returnValue(selectedDay);
}
// returnValue(selectedDay);
}, [selectedDay]);
return (
<div className="flex items-center justify-center w-full">
<DatePicker
value={selectedDay}
onChange={setSelectedDay}
inputPlaceholder="انتخاب تاریخ"
shouldHighlightWeekends
renderFooter={() => <button onClick={gotoToday}>برو به امروز</button>}
locale="fa"
/>
</div>
);
};
export default SimpleDatePicker;