0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-01 13:02:43 +00:00

fix valid check

This commit is contained in:
Víctor Losada Hernández
2024-05-22 19:49:06 +02:00
parent 34d37b24f1
commit 43f77dc525

View File

@@ -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;