mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-01 17:22:42 +00:00
fix valid check
This commit is contained in:
@@ -127,21 +127,22 @@ const ArchivePage = createClass({
|
|||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
totalBrews: null,
|
totalBrews: null,
|
||||||
|
error: null
|
||||||
});
|
});
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
try {
|
try {
|
||||||
await request
|
const response = await request.get(
|
||||||
.get(
|
`/api/archive/total?title=${title}&v3=${v3}&legacy=${legacy}`
|
||||||
`/api/archive/total?title=${title}&v3=${v3}&legacy=${legacy}`
|
);
|
||||||
)
|
|
||||||
.then((response) => {
|
if (response.ok) {
|
||||||
if (response.ok) {
|
this.setState({
|
||||||
this.setState({
|
totalBrews: response.body.totalBrews,
|
||||||
totalBrews: response.body.totalBrews,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw new Error(`Failed to load total brews: ${response.statusText}`);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('error at loadTotal: ', error);
|
console.log('error at loadTotal: ', error);
|
||||||
this.setState({ error: `${error.response.status}` });
|
this.setState({ error: `${error.response.status}` });
|
||||||
@@ -171,7 +172,7 @@ const ArchivePage = createClass({
|
|||||||
validateInput: function () {
|
validateInput: function () {
|
||||||
const textInput = document.getElementById('title');
|
const textInput = document.getElementById('title');
|
||||||
const submitButton = document.getElementById('searchButton');
|
const submitButton = document.getElementById('searchButton');
|
||||||
if (textInput.valid) {
|
if (textInput.validity.valid && textInput.value) {
|
||||||
submitButton.disabled = false;
|
submitButton.disabled = false;
|
||||||
} else {
|
} else {
|
||||||
submitButton.disabled = true;
|
submitButton.disabled = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user