0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-04 21:12:41 +00:00

last changes, linted

This commit is contained in:
Víctor Losada Hernández
2024-09-20 20:52:30 +02:00
parent b53b279241
commit 235e3f484f

View File

@@ -1,3 +1,5 @@
/*eslint max-lines: ["warn", {"max": 400, "skipBlankLines": true, "skipComments": true}]*/
/*eslint max-params:["warn", { max: 10 }], */
require('./vaultPage.less'); require('./vaultPage.less');
const React = require('react'); const React = require('react');
@@ -27,7 +29,6 @@ const VaultPage = (props)=>{
const [searching, setSearching] = useState(false); const [searching, setSearching] = useState(false);
const [error, setError] = useState(null); const [error, setError] = useState(null);
const titleRef = useRef(null); const titleRef = useRef(null);
const authorRef = useRef(null); const authorRef = useRef(null);
const countRef = useRef(null); const countRef = useRef(null);
@@ -67,9 +68,7 @@ const VaultPage = (props)=>{
updateUrl(title, author, count, v3, legacy, page, sort, dir); updateUrl(title, author, count, v3, legacy, page, sort, dir);
const response = await request const response = await request
.get( .get(`/api/vault?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}&count=${count}&page=${page}&sort=${sort}&dir=${dir}`)
`/api/vault?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}&count=${count}&page=${page}&sort=${sort}&dir=${dir}`
)
.catch((error)=>{ .catch((error)=>{
console.log('error at loadPage: ', error); console.log('error at loadPage: ', error);
setError(error); setError(error);
@@ -83,9 +82,8 @@ const VaultPage = (props)=>{
const loadTotal = async (title, author, v3, legacy)=>{ const loadTotal = async (title, author, v3, legacy)=>{
setTotalBrews(null); setTotalBrews(null);
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}` .catch((error)=>{
).catch((error)=>{
console.log('error at loadTotal: ', error); console.log('error at loadTotal: ', error);
setError(error); setError(error);
updateStateWithBrews([], 1); updateStateWithBrews([], 1);
@@ -260,27 +258,23 @@ const VaultPage = (props)=>{
</div> </div>
); );
const renderSortOption = ( optionTitle, optionValue)=>{ const renderSortOption = (optionTitle, optionValue)=>{
const oppositeDir = dirState === 'asc' ? 'desc' : 'asc'; const oppositeDir = dirState === 'asc' ? 'desc' : 'asc';
return ( return (
<div <div className={`sort-option ${sortState === optionValue ? `active` : ''}`}>
className={`sort-option ${ <button onClick={()=>loadPage(1, false, optionValue, oppositeDir)}>
sortState === optionValue ? `active` : '' {optionTitle}
}`} </button>
> {sortState === optionValue && (
<button onClick={() => loadPage(1, false, optionValue, oppositeDir)}> <i className={`sortDir fas ${dirState === 'asc' ? 'fa-sort-up' : 'fa-sort-down'}`} />
{optionTitle} )}
</button>
{sortState === optionValue && (
<i className={`sortDir fas ${dirState === 'asc' ? 'fa-sort-up' : 'fa-sort-down'}`} />
)}
</div> </div>
); );
}; };
const renderSortBar = ()=>{ const renderSortBar = ()=>{
return ( return (
<div className='sort-container'> <div className='sort-container'>
{renderSortOption('Title', 'title', props.query.dir)} {renderSortOption('Title', 'title', props.query.dir)}
@@ -314,9 +308,7 @@ const VaultPage = (props)=>{
.map((_, index)=>( .map((_, index)=>(
<a <a
key={startPage + index} key={startPage + index}
className={`pageNumber ${ className={`pageNumber ${pageState === startPage + index ? 'currentPage' : ''}`}
pageState === startPage + index ? 'currentPage' : ''
}`}
onClick={()=>loadPage(startPage + index, false, sortState, dirState)} onClick={()=>loadPage(startPage + index, false, sortState, dirState)}
> >
{startPage + index} {startPage + index}
@@ -373,7 +365,7 @@ const VaultPage = (props)=>{
if(error) { if(error) {
const errorText = ErrorIndex()[error.HBErrorCode.toString()] || ''; const errorText = ErrorIndex()[error.HBErrorCode.toString()] || '';
return ( return (
<div className='foundBrews noBrews'> <div className='foundBrews noBrews'>
<h3>Error: {errorText}</h3> <h3>Error: {errorText}</h3>