docbrown/app/javascript/listings/components/ExpireDate.jsx
Michael Kohl 7f75f99560
[deploy] Rename classified listings (#7910)
* Change models and related files

* Update controllers and specs

* More renaming

* Seek and destroy, I mean search and replace

* Round up the stragglers

* Ground control to Major Travis...

* More fixes

* PR feedback

* Various fixes

* Rename view

* Fix list query builder

* Unify request specs

* Fix some API spec errors

* Fix remaining API specs

* Make spec conform to API

* Fix leftover problems

* Fix JS tests

* Fix column name in select

* Fix API specs

* Fix search specs

* Paging Mr. Travis
2020-05-27 13:35:09 +00:00

37 lines
1,016 B
JavaScript

import PropTypes from 'prop-types';
import { h } from 'preact';
const ExpireDate = ({ onChange, defaultValue }) => {
let tomorrow = new Date();
let monthFromToday = new Date();
tomorrow.setDate(new Date().getDate() + 1);
[tomorrow] = tomorrow.toISOString().split('T');
monthFromToday.setDate(new Date().getDate() + 30);
[monthFromToday] = monthFromToday.toISOString().split('T');
return (
<div className="field">
<label className="listingform__label" htmlFor="expires_at">
Custom Expire Date (if applicable for time sensitive events, deadlines,
etc.)
</label>
<input
type="date"
className="listingform__input"
id="expires_at"
name="listing[expires_at]"
value={defaultValue}
onInput={onChange}
min={tomorrow}
max={monthFromToday}
/>
</div>
);
};
ExpireDate.propTypes = {
onChange: PropTypes.func.isRequired,
defaultValue: PropTypes.string.isRequired,
};
export default ExpireDate;