0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-11 11:12:44 +00:00
This commit is contained in:
Trevor Buckner
2024-09-04 01:06:56 -04:00
parent 4f39222724
commit d7d690a9d1
5 changed files with 132 additions and 133 deletions

View File

@@ -5,11 +5,11 @@ const Nav = require('naturalcrit/nav/nav.jsx');
module.exports = function (props) { module.exports = function (props) {
return ( return (
<Nav.item <Nav.item
color="purple" color='purple'
icon="fas fa-dungeon" icon='fas fa-dungeon'
href="/vault" href='/vault'
newTab={false} newTab={false}
rel="noopener noreferrer" rel='noopener noreferrer'
> >
Vault Vault
</Nav.item> </Nav.item>

View File

@@ -116,7 +116,7 @@ const VaultPage = (props) => {
const renderNavItems = ()=>( const renderNavItems = ()=>(
<Navbar> <Navbar>
<Nav.section> <Nav.section>
<Nav.item className="brewTitle"> <Nav.item className='brewTitle'>
Vault: Search for brews Vault: Search for brews
</Nav.item> </Nav.item>
</Nav.section> </Nav.section>
@@ -145,24 +145,24 @@ const VaultPage = (props) => {
}; };
const renderForm = ()=>( const renderForm = ()=>(
<div className="brewLookup"> <div className='brewLookup'>
<h2 className="formTitle">Brew Lookup</h2> <h2 className='formTitle'>Brew Lookup</h2>
<div className="formContents"> <div className='formContents'>
<label> <label>
Title of the brew Title of the brew
<input <input
ref={titleRef} ref={titleRef}
type="text" type='text'
name="title" name='title'
defaultValue={props.query.title || ''} defaultValue={props.query.title || ''}
onKeyUp={disableSubmitIfFormInvalid} onKeyUp={disableSubmitIfFormInvalid}
pattern=".{3,}" pattern='.{3,}'
title="At least 3 characters" title='At least 3 characters'
onKeyDown={(e)=>{ onKeyDown={(e)=>{
if(e.key === 'Enter' && !submitButtonRef.current.disabled) if(e.key === 'Enter' && !submitButtonRef.current.disabled)
loadPage(1, true); loadPage(1, true);
}} }}
placeholder="v3 Reference Document" placeholder='v3 Reference Document'
/> />
</label> </label>
@@ -170,34 +170,34 @@ const VaultPage = (props) => {
Author of the brew Author of the brew
<input <input
ref={authorRef} ref={authorRef}
type="text" type='text'
name="author" name='author'
pattern=".{1,}" pattern='.{1,}'
defaultValue={props.query.author || ''} defaultValue={props.query.author || ''}
onKeyUp={disableSubmitIfFormInvalid} onKeyUp={disableSubmitIfFormInvalid}
onKeyDown={(e)=>{ onKeyDown={(e)=>{
if(e.key === 'Enter' && !submitButtonRef.current.disabled) if(e.key === 'Enter' && !submitButtonRef.current.disabled)
loadPage(1, true); loadPage(1, true);
}} }}
placeholder="Username" placeholder='Username'
/> />
</label> </label>
<label> <label>
Results per page Results per page
<select ref={countRef} name="count" defaultValue={props.query.count || 20}> <select ref={countRef} name='count' defaultValue={props.query.count || 20}>
<option value="10">10</option> <option value='10'>10</option>
<option value="20">20</option> <option value='20'>20</option>
<option value="40">40</option> <option value='40'>40</option>
<option value="60">60</option> <option value='60'>60</option>
</select> </select>
</label> </label>
<label> <label>
<input <input
className="renderer" className='renderer'
ref={v3Ref} ref={v3Ref}
type="checkbox" type='checkbox'
defaultChecked={props.query.v3 !== 'false'} defaultChecked={props.query.v3 !== 'false'}
onChange={disableSubmitIfFormInvalid} onChange={disableSubmitIfFormInvalid}
/> />
@@ -206,9 +206,9 @@ const VaultPage = (props) => {
<label> <label>
<input <input
className="renderer" className='renderer'
ref={legacyRef} ref={legacyRef}
type="checkbox" type='checkbox'
defaultChecked={props.query.legacy !== 'false'} defaultChecked={props.query.legacy !== 'false'}
onChange={disableSubmitIfFormInvalid} onChange={disableSubmitIfFormInvalid}
/> />
@@ -216,7 +216,7 @@ const VaultPage = (props) => {
</label> </label>
<button <button
id="searchButton" id='searchButton'
ref={submitButtonRef} ref={submitButtonRef}
onClick={()=>{ onClick={()=>{
loadPage(1, true); loadPage(1, true);
@@ -244,7 +244,7 @@ const VaultPage = (props) => {
<li> <li>
Some common words like "a", "after", "through", "itself", "here", etc., Some common words like "a", "after", "through", "itself", "here", etc.,
are ignored in searches. The full list can be found &nbsp; are ignored in searches. The full list can be found &nbsp;
<a href="https://github.com/mongodb/mongo/blob/0e3b3ca8480ddddf5d0105d11a94bd4698335312/src/mongo/db/fts/stop_words_english.txt"> <a href='https://github.com/mongodb/mongo/blob/0e3b3ca8480ddddf5d0105d11a94bd4698335312/src/mongo/db/fts/stop_words_english.txt'>
here here
</a> </a>
</li> </li>
@@ -286,18 +286,18 @@ const VaultPage = (props) => {
)); ));
return ( return (
<div className="paginationControls"> <div className='paginationControls'>
<button <button
className="previousPage" className='previousPage'
onClick={()=>loadPage(pageState - 1, false)} onClick={()=>loadPage(pageState - 1, false)}
disabled={pageState === startPage} disabled={pageState === startPage}
> >
<i className="fa-solid fa-chevron-left"></i> <i className='fa-solid fa-chevron-left'></i>
</button> </button>
<ol className="pages"> <ol className='pages'>
{startPage > 1 && ( {startPage > 1 && (
<a <a
className="pageNumber firstPage" className='pageNumber firstPage'
onClick={()=>loadPage(1, false)} onClick={()=>loadPage(1, false)}
> >
1 ... 1 ...
@@ -306,7 +306,7 @@ const VaultPage = (props) => {
{pagesAroundCurrent} {pagesAroundCurrent}
{endPage < totalPages && ( {endPage < totalPages && (
<a <a
className="pageNumber lastPage" className='pageNumber lastPage'
onClick={()=>loadPage(totalPages, false)} onClick={()=>loadPage(totalPages, false)}
> >
... {totalPages} ... {totalPages}
@@ -314,11 +314,11 @@ const VaultPage = (props) => {
)} )}
</ol> </ol>
<button <button
className="nextPage" className='nextPage'
onClick={()=>loadPage(pageState + 1, false)} onClick={()=>loadPage(pageState + 1, false)}
disabled={pageState === totalPages} disabled={pageState === totalPages}
> >
<i className="fa-solid fa-chevron-right"></i> <i className='fa-solid fa-chevron-right'></i>
</button> </button>
</div> </div>
); );
@@ -327,8 +327,8 @@ const VaultPage = (props) => {
const renderFoundBrews = ()=>{ const renderFoundBrews = ()=>{
if(searching) { if(searching) {
return ( return (
<div className="foundBrews searching"> <div className='foundBrews searching'>
<h3 className="searchAnim">Searching</h3> <h3 className='searchAnim'>Searching</h3>
</div> </div>
); );
} }
@@ -338,7 +338,7 @@ const VaultPage = (props) => {
console.log('render Error: ', error); console.log('render Error: ', error);
return ( return (
<div className="foundBrews noBrews"> <div className='foundBrews noBrews'>
<h3>Error: {errorText}</h3> <h3>Error: {errorText}</h3>
</div> </div>
); );
@@ -346,7 +346,7 @@ const VaultPage = (props) => {
if(!brewCollection) { if(!brewCollection) {
return ( return (
<div className="foundBrews noBrews"> <div className='foundBrews noBrews'>
<h3>No search yet</h3> <h3>No search yet</h3>
</div> </div>
); );
@@ -354,15 +354,15 @@ const VaultPage = (props) => {
if(brewCollection.length === 0) { if(brewCollection.length === 0) {
return ( return (
<div className="foundBrews noBrews"> <div className='foundBrews noBrews'>
<h3>No brews found</h3> <h3>No brews found</h3>
</div> </div>
); );
} }
return ( return (
<div className="foundBrews"> <div className='foundBrews'>
<span className="totalBrews"> <span className='totalBrews'>
{`Brews found: `} {`Brews found: `}
<span>{totalBrews}</span> <span>{totalBrews}</span>
</span> </span>
@@ -381,15 +381,15 @@ const VaultPage = (props) => {
}; };
return ( return (
<div className="vaultPage"> <div className='vaultPage'>
<link href="/themes/V3/Blank/style.css" rel="stylesheet" /> <link href='/themes/V3/Blank/style.css' rel='stylesheet' />
<link href="/themes/V3/5ePHB/style.css" rel="stylesheet" /> <link href='/themes/V3/5ePHB/style.css' rel='stylesheet' />
{renderNavItems()} {renderNavItems()}
<div className="content"> <div className='content'>
<SplitPane hideMoveArrows> <SplitPane hideMoveArrows>
<div className="form dataGroup">{renderForm()}</div> <div className='form dataGroup'>{renderForm()}</div>
<div className="resultsContainer dataGroup"> <div className='resultsContainer dataGroup'>
{renderFoundBrews()} {renderFoundBrews()}
</div> </div>
</SplitPane> </SplitPane>

View File

@@ -62,15 +62,14 @@ const findBrews = async (req, res) => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const processedBrews = brews.map((brew)=>{ const processedBrews = brews.map((brew)=>{
brew.authors = brew.authors.map(author => brew.authors = brew.authors.map((author)=>emailRegex.test(author) ? 'hidden' : author
emailRegex.test(author) ? 'hidden' : author
); );
return brew; return brew;
}); });
res.json({ brews: processedBrews, page }); res.json({ brews: processedBrews, page });
}) })
.catch((error)=>{ .catch((error)=>{
throw {...error, message: "Error finding brews in Vault search", HBErrorCode: 90}; throw { ...error, message: 'Error finding brews in Vault search', HBErrorCode: 90 };
}); });
}; };
@@ -93,7 +92,7 @@ const findTotal = async (req, res) => {
res.json({ totalBrews }); res.json({ totalBrews });
}) })
.catch((error)=>{ .catch((error)=>{
throw {...error, message: "Error finding brews in Vault search findTotal function", HBErrorCode: 91}; throw { ...error, message: 'Error finding brews in Vault search findTotal function', HBErrorCode: 91 };
}); });
}; };