Fixed the bug of mismatch dates where dates showing one day earlier than expected
This commit is contained in:
parent
8d4c9e4f39
commit
68b23c8d5e
@ -12,8 +12,9 @@ const AttendanceLog = ({ attendance, handleModalData, projectId }) => {
|
||||
const { data, loading, error } = useSelector((store) => store.attendanceLogs);
|
||||
|
||||
// Set the default selected date to the current date
|
||||
const currentDate = new Date().toISOString().split("T")[0]; // "YYYY-MM-DD"
|
||||
|
||||
|
||||
// const currentDate = new Date().toISOString().split("T")[0]; // "YYYY-MM-DD"
|
||||
const currentDate = new Date().toLocaleDateString('en-CA');
|
||||
const handleDateChange = (e) => {
|
||||
const date = e.target.value;
|
||||
setSelectedDate(date);
|
||||
|
@ -35,7 +35,6 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
||||
|
||||
const onSubmit = ( data ) =>
|
||||
{
|
||||
console.log(data)
|
||||
let record = {...data, date: new Date().toLocaleDateString(),latitude:coords.latitude,longitude:coords.longitude,employeeId:modeldata.employeeId,action:modeldata.action,id:modeldata?.id || null}
|
||||
if(modeldata.forWhichTab === 1){
|
||||
handleSubmitForm(record)
|
||||
@ -134,7 +133,8 @@ export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{
|
||||
|
||||
const getCurrentDate = () => {
|
||||
const today = new Date();
|
||||
return today.toISOString().split("T")[0];
|
||||
// return today.toISOString().split("T")[0];
|
||||
return today.toLocaleDateString('en-CA');
|
||||
};
|
||||
|
||||
|
||||
@ -143,7 +143,6 @@ export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{
|
||||
|
||||
let record = {...data, date: new Date().toLocaleDateString(),latitude:coords.latitude,longitude:coords.longitude, }
|
||||
|
||||
console.log(record)
|
||||
handleSubmitForm(record)
|
||||
closeModal()
|
||||
};
|
||||
|
@ -37,7 +37,8 @@ const Dashboard = () => {
|
||||
|
||||
const days = getDaysFromRange(range);
|
||||
const today = new Date();
|
||||
const FromDate = today.toISOString().split("T")[0]; // Always today
|
||||
// const FromDate = today.toISOString().split("T")[0];
|
||||
const FromDate = today.toLocaleDateString('en-CA'); // Always today
|
||||
|
||||
const { projectsCardData } = useDashboardProjectsCardData();
|
||||
const { teamsCardData } = useDashboardTeamsCardData();
|
||||
|
@ -3,7 +3,8 @@ import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
|
||||
const currentDate = new Date().toISOString().split("T")[0];
|
||||
// const currentDate = new Date().toISOString().split("T")[0];
|
||||
const currentDate = new Date().toLocaleDateString('en-CA');
|
||||
const formatDate = (date) => {
|
||||
if (!date) {
|
||||
return currentDate;
|
||||
@ -12,7 +13,8 @@ const formatDate = (date) => {
|
||||
if (isNaN(d.getTime())) {
|
||||
return currentDate;
|
||||
}
|
||||
return d.toISOString().split("T")[0];
|
||||
// return d.toISOString().split("T")[0];
|
||||
return d.toLocaleDateString('en-CA');
|
||||
};
|
||||
const ManageProjectInfo = ({ project, handleSubmitForm, onClose }) => {
|
||||
const [CurrentProject, setCurrentProject] = useState();
|
||||
|
@ -20,10 +20,12 @@ const DateRangePicker = ({ onRangeChange }) => {
|
||||
onRangeChange?.({ startDate, endDate });
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
onRangeChange?.({
|
||||
startDate: fifteenDaysAgo.toISOString().split("T")[0],
|
||||
endDate: today.toISOString().split("T")[0],
|
||||
// startDate: fifteenDaysAgo.toISOString().split("T")[0],
|
||||
// endDate: today.toISOString().split("T")[0],
|
||||
startDate: fifteenDaysAgo.toLocaleDateString('en-CA'),
|
||||
endDate: today.toLocaleDateString('en-CA'),
|
||||
});
|
||||
|
||||
return () => {
|
||||
|
@ -23,7 +23,8 @@ export const getDateDifferenceInDays = (startDate, endDate) => {
|
||||
export const formatDate = (date) => {
|
||||
if (!date) return ""; // Return an empty string if no date
|
||||
const dateObj = new Date(date);
|
||||
return dateObj.toISOString().split("T")[0]; // Get the date in YYYY-MM-DD format
|
||||
// return dateObj.toISOString().split("T")[0];
|
||||
return dateObj.toLocaleDateString('en-CA'); // Get the date in YYYY-MM-DD format
|
||||
};
|
||||
|
||||
export const convertShortTime = (dateString) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user