daisycrego / jbg-admin

Admin app for Jill Biggs Group follow-up boss event management
1 stars 0 forks source link

`EventsTable` --> Add a date range picker #33

Closed daisycrego closed 3 years ago

daisycrego commented 3 years ago

Todo

Add created range as state to the EventsTable.

Plan

daisycrego commented 3 years ago

Found a datepicker: https://reactdatepicker.com/

() => { const [startDate, setStartDate] = useState(null); const [endDate, setEndDate] = useState(null); return ( <> <DatePicker selected={startDate} onChange={(date) => setStartDate(date)} /> <DatePicker selected={endDate} onChange={(date) => setEndDate(date)} /> </> ); };

daisycrego commented 3 years ago

Ended up using a styled Datepicker component from datepicker-react: https://www.npmjs.com/package/@datepicker-react/styled because that other approach resulted in some issues loading the CSS, whereas this is a styled component, there's no need to import a CSS file from the bundle.

daisycrego commented 3 years ago

I was using a different approach for the date pickers, but I don't love it. I'm going to use material UI before I get any further entrenched... https://material-ui-pickers.dev/getting-started/installation

@material-ui/pickers

Peer Library

Option: moment
Option: luxon
import { MuiPickersUtilsProvider } from '@material-ui/pickers';

// pick a date util library
import MomentUtils from '@date-io/moment';
import DateFnsUtils from '@date-io/date-fns';
import LuxonUtils from '@date-io/luxon';

function App() {
  return (
    <MuiPickersUtilsProvider utils={DateFnsUtils}>
      <Root />
    </MuiPickersUtilsProvider>
  );
}

ReactDOM.render(<App />, document.querySelector('#app'));

Usage

function App() { const [selectedDate, handleDateChange] = useState(new Date());

return (

); }