mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-27 00:42:40 +00:00
fix notitle search and catch 404?
This commit is contained in:
@@ -100,8 +100,8 @@ const ArchivePage = createClass({
|
||||
if(update === true) {
|
||||
this.updateStateWithForm();
|
||||
};
|
||||
|
||||
try {
|
||||
if (title !== '') {
|
||||
try {
|
||||
this.setState({ searching: true, error: null });
|
||||
|
||||
const title = encodeURIComponent(this.state.title);
|
||||
@@ -117,6 +117,12 @@ const ArchivePage = createClass({
|
||||
this.setState({ error: `${error.response.status}` })
|
||||
this.updateStateWithBrews([], 1, 1, 0);
|
||||
}
|
||||
console.log(!this.state.brewCollection || brewCollection.length === 0);
|
||||
if(!this.state.brewCollection) {
|
||||
this.setState({ error: '404'});
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
renderNavItems : function () {
|
||||
@@ -253,8 +259,16 @@ const ArchivePage = createClass({
|
||||
);
|
||||
};
|
||||
|
||||
if(title === '') {return (<div className='foundBrews noBrews'><h3>Whenever you want, just start typing...</h3></div>);}
|
||||
|
||||
|
||||
if(title === '') {return (<div className='foundBrews noBrews'><h3>Whenever you want, just start typing...</h3></div>);}
|
||||
if (!brewCollection || brewCollection.length === 0) {
|
||||
return (
|
||||
<div className='foundBrews noBrews'>
|
||||
<h3>No brews found</h3>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
if (error) {
|
||||
console.log('render Error: ', error);
|
||||
let errorMessage;
|
||||
@@ -277,13 +291,7 @@ const ArchivePage = createClass({
|
||||
);
|
||||
};
|
||||
|
||||
if (!brewCollection || brewCollection.length === 0) {
|
||||
return (
|
||||
<div className='foundBrews noBrews'>
|
||||
<h3>No brews found</h3>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div className='foundBrews'>
|
||||
|
||||
@@ -41,7 +41,7 @@ const archive = {
|
||||
.maxTimeMS(5000)
|
||||
.exec();
|
||||
|
||||
const totalBrews = await HomebrewModel.countDocuments(titleQuery, projection);
|
||||
const totalBrews = await HomebrewModel.countDocuments(titleQuery, projection).maxTimeMS(5000);
|
||||
|
||||
const totalPages = Math.ceil(totalBrews / pageSize);
|
||||
//console.log('Total brews: ', totalBrews);
|
||||
@@ -49,10 +49,6 @@ const archive = {
|
||||
return res.json({ brews, page, totalPages, totalBrews});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.log(error);
|
||||
if (error.response && error.response.status === 404) {
|
||||
return res.status(404).json({ errorCode: '404', message: 'Brews not found' });
|
||||
}
|
||||
if (error.response && error.response.status === 503) {
|
||||
return res.status(503).json({ errorCode: '503', message: 'Service Unavailable' });
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user