docbrown/app/javascript/listings/elements/expireDate.jsx
Mario See 47c2885810 Listings set custom expiry date (#3770)
* add expire_on column to classified_listings

* add expire_on to valid listing params

* add expire_on to model

* add expire date to new listing form

* add field in edit form

* add expiry dates to dashboard

* update expiry date in listing toolkit

* WIP unpublish job and test

test still has to run properly

* add job to class name

* change job to rake task

* revert snap change

* delete migration file

will add new one and revert schema changes to rename column

* reset schema

* add new migration to schema 'expires_at'

* change expire_on to expires_at
2019-08-23 17:33:50 -04:00

34 lines
1,007 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')[0];
monthFromToday.setDate(new Date().getDate() + 30);
monthFromToday = monthFromToday.toISOString().split('T')[0];
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="classified_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;