mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-14 23:42:41 +00:00
Remove redundant validation check
`performSearch()` and `loadTotal()` shouldn't need a separate check for valid items if `loadPage` already does it through `validateForm`
This commit is contained in:
@@ -60,8 +60,6 @@ const VaultPage = (props) => {
|
|||||||
|
|
||||||
const performSearch = async (title, author, count, v3, legacy, page) => {
|
const performSearch = async (title, author, count, v3, legacy, page) => {
|
||||||
updateUrl(title, author, count, v3, legacy, page);
|
updateUrl(title, author, count, v3, legacy, page);
|
||||||
if (!((title || author) && (v3 || legacy)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
const response = await request.get(
|
const response = await request.get(
|
||||||
`/api/vault?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}&count=${count}&page=${page}`
|
`/api/vault?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}&count=${count}&page=${page}`
|
||||||
@@ -80,8 +78,6 @@ const VaultPage = (props) => {
|
|||||||
|
|
||||||
const loadTotal = async (title, author, v3, legacy) => {
|
const loadTotal = async (title, author, v3, legacy) => {
|
||||||
setTotalBrews(null);
|
setTotalBrews(null);
|
||||||
if (!((title || author) && (v3 || legacy)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
const response = await request.get(
|
const response = await request.get(
|
||||||
`/api/vault/total?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}`
|
`/api/vault/total?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}`
|
||||||
@@ -135,7 +131,6 @@ const VaultPage = (props) => {
|
|||||||
|
|
||||||
const validateForm = () => {
|
const validateForm = () => {
|
||||||
//form validity: title or author must be written, and at least one renderer set
|
//form validity: title or author must be written, and at least one renderer set
|
||||||
|
|
||||||
const isTitleValid = titleRef.current.validity.valid && titleRef.current.value;
|
const isTitleValid = titleRef.current.validity.valid && titleRef.current.value;
|
||||||
const isAuthorValid = authorRef.current.validity.valid && authorRef.current.value;
|
const isAuthorValid = authorRef.current.validity.valid && authorRef.current.value;
|
||||||
const isCheckboxChecked = legacyRef.current.checked || v3Ref.current.checked;
|
const isCheckboxChecked = legacyRef.current.checked || v3Ref.current.checked;
|
||||||
|
|||||||
Reference in New Issue
Block a user