diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx
index 8cec5c4b0..d569e4d02 100644
--- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx
+++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx
@@ -144,12 +144,10 @@ const BrewItem = createClass({
{brew.authors?.map((author, index) => (
- {author === 'hidden' ? (
- {author}
- ) : (
- {author}
- )}
- {index < brew.authors.length - 1 && ', '}
+ {author === 'hidden'
+ ? {author}
+ : {author}
+ }
))}
diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js
index 3f4ecb969..3df1fc7ae 100644
--- a/client/homebrew/pages/errorPage/errors/errorIndex.js
+++ b/client/homebrew/pages/errorPage/errors/errorIndex.js
@@ -172,8 +172,8 @@ const errorIndex = (props)=>{
**Brew Title:** ${props.brew.brewTitle}`,
- '99' : dedent` An unexpected error ocurred while looking for these brews, try again in a few minutes, if this error persists,
- contact the developers at the subreddit or discord provided in the home page.`,
+ '90' : dedent` An unexpected error occurred while looking for these brews.
+ Try again in a few minutes.`,
};
};
diff --git a/client/homebrew/pages/vaultPage/vaultPage.jsx b/client/homebrew/pages/vaultPage/vaultPage.jsx
index b48a38360..67d7c9fe0 100644
--- a/client/homebrew/pages/vaultPage/vaultPage.jsx
+++ b/client/homebrew/pages/vaultPage/vaultPage.jsx
@@ -2,7 +2,6 @@ require('./vaultPage.less');
const React = require('react');
const { useState, useEffect, useRef } = React;
-const cx = require('classnames');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
@@ -63,69 +62,57 @@ const VaultPage = (props) => {
window.history.replaceState(null, null, url);
};
+ const performSearch = async ({ title, author, count, v3, legacy }) => {
+ updateUrl(title, author, count, v3, legacy, page);
+ console.log(title, author, count, v3, legacy);
+ if ((title || author) && (v3 || legacy)) {
+ const response = await request.get(
+ `/api/vault?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}&count=${count}&page=${page}`
+ ).catch((error)=>{
+ console.log('error at loadPage: ', error);
+ setError(`${error.response
+ ? error.response.status
+ : error.message}`
+ );
+ updateStateWithBrews([], 1);
+ });
+
+ if (response.ok)
+ updateStateWithBrews(response.body.brews, page);
+ } else {
+ setError('404');
+ }
+ };
+
+ const loadTotal = async ({ title, v3, legacy }) => {
+ setTotalBrews(null);
+ setError(null);
+ if ((title || author) && (v3 || legacy)) {
+ const response = await request.get(
+ `/api/vault/total?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}`
+ ).catch((error)=>{
+ console.log('error at loadTotal: ', error);
+ setError(`${error.response
+ ? error.response.status
+ : error.message}`
+ );
+ updateStateWithBrews([], 1);
+ });
+
+ if (response.ok)
+ updateStateWithBrews(response.body.brews, page);
+ }
+ };
+
const loadPage = async (page, update, total) => {
//Different searches use the update or total props to make only the necessary queries and functions
if (!validateForm()) {
return;
}
-
setSearching(true);
setError(null);
- const performSearch = async ({ title, author, count, v3, legacy }) => {
- updateUrl(title, author, count, v3, legacy, page);
- console.log(title, author, count, v3, legacy);
- if ((title || author) && (v3 || legacy)) {
- try {
- const response = await request.get(
- `/api/vault?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}&count=${count}&page=${page}`
- );
- if (response.ok) {
- updateStateWithBrews(response.body.brews, page);
- } else {
- throw new Error(`Error: ${response.status}`);
- }
- } catch (error) {
- console.log('error at loadPage: ', error);
- setError(
- `${
- error.response
- ? error.response.status
- : error.message
- }`
- );
- updateStateWithBrews([], 1);
- }
- } else {
- setError('404');
- }
- };
-
- const loadTotal = async ({ title, v3, legacy }) => {
- setTotalBrews(null);
- setError(null);
- if ((title || author) && (v3 || legacy)) {
- try {
- const response = await request.get(
- `/api/vault/total?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}`
- );
-
- if (response.ok) {
- setTotalBrews(response.body.totalBrews);
- } else {
- throw new Error(
- `Failed to load total brews: ${response.statusText}`
- );
- }
- } catch (error) {
- console.log('error at loadTotal: ', error);
- setError(`${error.response.status}`);
- updateStateWithBrews([], 1);
- }
- }
- };
-
const title = titleRef.current.value || '';
const author = authorRef.current.value || '';
const count = countRef.current.value || 10;
@@ -167,25 +154,18 @@ const VaultPage = (props) => {
const validateForm = () => {
//form validity: title or author must be written, and at least one renderer set
- const { current: titleInput } = titleRef;
- const { current: legacyCheckbox } = legacyRef;
- const { current: v3Checkbox } = v3Ref;
- const { current: authorInput } = authorRef;
- const isTitleValid = titleInput.validity.valid && titleInput.value;
- //because a pattern attr is set in the input, title must be over 2 chars long
- const isAuthorValid = authorInput.validity.valid && authorInput.value;
- const isCheckboxChecked = legacyCheckbox.checked || v3Checkbox.checked;
+ const isTitleValid = titleRef.current.validity.valid && titleRef.current.value;
+ const isAuthorValid = authorRef.current.validity.valid && authorRef.current.value;
+ const isCheckboxChecked = legacyRef.current.checked || v3Ref.current.checked;
- const isFormValid =
- (isTitleValid || isAuthorValid) && isCheckboxChecked;
+ const isFormValid = (isTitleValid || isAuthorValid) && isCheckboxChecked;
return isFormValid;
};
const disableSubmitIfFormInvalid = () => {
- const { current: submitButton } = searchButtonRef;
- submitButton.disabled = !validateForm();
+ submitButtonRef.current.disabled = !validateForm();
};
const renderForm = () => (
@@ -274,10 +254,7 @@ const VaultPage = (props) => {
>
Search
@@ -285,30 +262,27 @@ const VaultPage = (props) => {
Tips and tricks
-
- You can only search brews with this tool if they are
- published
+ Only published brews are searchable via this tool
-
Usernames are case sensitive, make sure you are writing
it correctly
-
- You can use
- to negate words, assuming
- there is any word not negated, and "word"
- to specify an exact string.
+ Use "word" to match an exact string, and
+ - to exclude words (at least one word
+ must not be negated).
-
- Some words like a, after, through, itself, or here, are
- ignored in searches, make sure your search has relevant
- words. The full list can be found
-
- here
-
+ Some common words like "a", "after", "through", "itself", "here", etc.,
+ are ignored in searches. The full list can be found
+
+ here
+
-
);
diff --git a/server/vault.api.js b/server/vault.api.js
index 7c489efd7..2b25779a3 100644
--- a/server/vault.api.js
+++ b/server/vault.api.js
@@ -76,7 +76,7 @@ const findBrews = async (req, res) => {
})
.catch((error) => {
console.error(error);
- throw {...err, message: "Error finding brews in Vault search", HBErrorCode: '99'};
+ throw {...err, message: "Error finding brews in Vault search", HBErrorCode: 90};
});
};
@@ -109,7 +109,7 @@ const findTotal = async (req, res) => {
})
.catch((error) => {
console.error(error);
- throw {...err, message: "Error finding brews in Vault search", HBErrorCode: '99'};
+ throw {...err, message: "Error finding brews in Vault search", HBErrorCode: 90};
});
};