frankcollins3 / Next-Water-App

Happy, Healthy Water Cycling App that tracks user/human fluid intake.
https://next-water-app.vercel.app
1 stars 0 forks source link

human error over remaining hours [11:34am] #102

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: port <timer> code over from react to next

error: no matter what is done the timer never gets set.

useEffect(() => { console.log("is this running?") const currentTime = new Date().getTime(); const currentHour = new Date().getHours();

// find the closest matching time

const remainingReminders = hydroSchedule.filter((time) => {
  console.log('time', time)
  // if time > currentHour, it's marked as a time for reminder.
  return time > currentHour;
});

**if (remainingReminders.length) {
  console.log('remainingReminders', remainingReminders)

  const nextHour = new Date();
  nextHour.setMinutes(0);
  nextHour.setSeconds(0);

  const timeToNextRemind = Math.ceil(
    (nextHour.setHours(remainingReminders[0]) - currentTime) / 1000
  );

  console.log('time to next remind', timeToNextRemind)

  setTimer(timeToNextRemind);
} else {
  console.log("no remainingReminders.length")
}**

proposed approach: tinker for 40 minutes.

solution: the reminders ran from 8am - 4pm there are no remaining hours. change settings to allow for midnight or wait 20 minutes or call it a day.

// going nuts looking everywhere for why logs never get set.

frankcollins3 commented 1 year ago

👍 that was the problem. [11:50am]