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