frankcollins3 / fill_container

codecamp team project updated with new icon screen menu + puppeteer icon search, GraphQL, redux, relational psql !mongo, and accuweatherAPI
1 stars 0 forks source link

date format and moment deprecation [2:23am] #237

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: nothing. make old working code new working code. map over psql.table.data correspondent to currentUser by users_id and format dates so the calendar is ready to handle data

error: Screen Shot 2023-06-20 at 2 22 31 AM

import React, { useState, useEffect } from 'react';
import moment from 'moment-timezone';
import Calendar from 'react-calendar';
import './dashboard.css';
import 'react-calendar/dist/Calendar.css';
// import WAPPRequest from '../../utils';
import currentuserJSONparse from '../../../utility/currentuserJSONparse'
import getAllUserData from '../../../utility/fetch/getAllUserData'
import { set } from 'date-fns';
import Spinner from '../Spinner';
import $ from 'jquery';

export default function Dashboard() {
  const [value, onChange] = useState(new Date());
  const [hydroData, setHydroData] = useState();
  const [hydroDays, setHydroDays] = useState([]);
  const [selectedDay, setSelectedDay] = useState();
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState();
  $('*').css('cursor', `url('/water_img/mouse_droplet.png'), auto`)
  $('*').on('mouseenter', (event) => {
    $(event.target).css('cursor', `normal`)
  })

  useEffect(() => {
    (async() => {
       let currentUser = await currentuserJSONparse()
       let currentuserID = currentUser.id

       let currentUserDataArray = await getAllUserData(currentuserID)
       let dataLength = currentUserDataArray.length
       console.log('currentUserDataArray')
       console.log(currentUserDataArray)

       if (currentUserDataArray) {
         setHydroData(currentUserDataArray)
         const getDates = currentUserDataArray.map( (day, index) => {
          return moment(day.date).tz('UTC').format('MM-DD-YYYY')
         })
       } else { return }

    })()

   }, []);

proposed approach: possibly look into another library or look into current library documentation / ask chatGPT for clues

[2:27am]

frankcollins3 commented 1 year ago

👍 useEffect(() => { (async() => { let currentUser = await currentuserJSONparse() let currentuserID = currentUser.id

   let currentUserDataArray = await getAllUserData(currentuserID)
   let dataLength = currentUserDataArray.length
   console.log('currentUserDataArray')
   console.log(currentUserDataArray)

   if (currentUserDataArray) {
    setHydroData(currentUserDataArray);
    const getDates = currentUserDataArray.map((day, index) => {
      const formattedDate = moment(day.date, 'YYYY-M-D').format('MM-DD-YYYY');
      return formattedDate;
    });
    // ...
  } else {
    return;
  }

})()

}, []);

👍 https://momentjs.com/docs/ 👍 👍 👍 https://chat.openai.com/

app was supposed to be done weeks ago had to do it

[2:31am]