diff --git a/nest_frontend/components/interactive/FormInlineTimeRay.js b/nest_frontend/components/interactive/FormInlineTimeRay.js index 6aa1a04..7e4cce7 100644 --- a/nest_frontend/components/interactive/FormInlineTimeRay.js +++ b/nest_frontend/components/interactive/FormInlineTimeRay.js @@ -37,19 +37,21 @@ export default function FormInlineTimeRay( ) { const [isBefore, setBefore] = useState(false) const [value, setValue] = useState("") + const [disabled, setDisabled] = useState(true) const _onSubmit = event => { event.preventDefault() if(!value) { return } - console.debug(value) submit(new TimeRay(isBefore, new Date(value))) setValue("") } const _onChange = event => { - setValue(validate(event.target.value.toUpperCase().replace(INVALID_CHARACTERS, ""))) + const newValue = validate(event.target.value.toUpperCase().replace(INVALID_CHARACTERS, "")) + setValue(newValue) + setDisabled(!value || isNaN(new Date(newValue).getDate())) } return ( @@ -71,7 +73,7 @@ export default function FormInlineTimeRay( icon={buttonIcon} color={buttonColor} onClick={_onSubmit} - disabled={!value} + disabled={disabled} /> ) diff --git a/nest_frontend/objects/Filter.js b/nest_frontend/objects/Filter.js index 7b096fb..45af9b0 100644 --- a/nest_frontend/objects/Filter.js +++ b/nest_frontend/objects/Filter.js @@ -211,7 +211,6 @@ export class FilterInsideTimeRay extends Filter { } check(tweet) { - console.debug(this.timeRay.date, tweet["post_time"]) return this.timeRay.includes(new Date(tweet["post_time"])) } diff --git a/nest_frontend/objects/TimeRay.js b/nest_frontend/objects/TimeRay.js index b3779ef..a0b64ec 100644 --- a/nest_frontend/objects/TimeRay.js +++ b/nest_frontend/objects/TimeRay.js @@ -38,8 +38,6 @@ export default class TimeRay { } includes(date) { - return Boolean(( - this.date > date - ) ^ this.isBefore) + return Boolean((date > this.date) ^ this.isBefore) } }