0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-06-22 04:58:40 +00:00

change prime to found

This commit is contained in:
Víctor Losada Hernández
2026-05-28 10:36:24 +02:00
parent e7680ef80b
commit 3b71f6fa0b
@@ -6,10 +6,10 @@ const BrewCleanup = ({})=>{
const [count, setCount] = useState(0); const [count, setCount] = useState(0);
const [brewCollection, setBrewCollection] = useState([]); const [brewCollection, setBrewCollection] = useState([]);
const [pending, setPending] = useState(false); const [pending, setPending] = useState(false);
const [primed, setPrimed] = useState(false); const [found, setFound] = useState(false);
const [error, setError] = useState(null); const [error, setError] = useState(null);
const prime = async ()=>{ const find = async ()=>{
setPending(true); setPending(true);
try { try {
@@ -17,7 +17,7 @@ const BrewCleanup = ({})=>{
setCount(res.body.count); setCount(res.body.count);
setBrewCollection(res.body.brewCollection); setBrewCollection(res.body.brewCollection);
setPrimed(true); setFound(true);
} catch (err) { } catch (err) {
setError(err); setError(err);
} finally { } finally {
@@ -36,7 +36,7 @@ const BrewCleanup = ({})=>{
setError(err); setError(err);
} finally { } finally {
setPending(false); setPending(false);
setPrimed(false); setFound(false);
} }
}; };
const renderBrewList = ()=>{ const renderBrewList = ()=>{
@@ -51,7 +51,6 @@ const BrewCleanup = ({})=>{
<thead> <thead>
<tr> <tr>
<th>Title</th> <th>Title</th>
<th>Share</th>
<th>Last Update</th> <th>Last Update</th>
<th>Created</th> <th>Created</th>
<th>Storage</th> <th>Storage</th>
@@ -66,7 +65,8 @@ const BrewCleanup = ({})=>{
.map((brew, idx)=>{ .map((brew, idx)=>{
return <tr key={idx}> return <tr key={idx}>
<td><strong>{brew.title || 'No Title'}</strong></td> <td><strong>{brew.title || 'No Title'}</strong></td>
<td><a href={`/share/${brew.shareId}`}>{brew.shareId}</a></td> {//<td><a href={`/share/${brew.shareId}`}>{brew.shareId}</a></td>
}
<td style={{ width: '200px' }}>{Moment(brew.updatedAt).fromNow()}</td> <td style={{ width: '200px' }}>{Moment(brew.updatedAt).fromNow()}</td>
<td>{brew.createdAt ? Moment(brew.createdAt).fromNow() : 'No creation date'}</td> <td>{brew.createdAt ? Moment(brew.createdAt).fromNow() : 'No creation date'}</td>
<td>{brew.googleId ? 'Google' : 'Homebrewery'}</td> <td>{brew.googleId ? 'Google' : 'Homebrewery'}</td>
@@ -76,8 +76,8 @@ const BrewCleanup = ({})=>{
</table> </table>
</>; </>;
}; };
const renderPrimed = ()=>{ const renderFound = ()=>{
if(!primed) return; if(!found) return;
if(!count) return <div className='result noBrews'>No Matching Brews found.</div>; if(!count) return <div className='result noBrews'>No Matching Brews found.</div>;
@@ -97,13 +97,13 @@ const BrewCleanup = ({})=>{
<h2> Brew Cleanup </h2> <h2> Brew Cleanup </h2>
<p>Removes very short brews to tidy up the database</p> <p>Removes very short brews to tidy up the database</p>
<button onClick={()=>prime()} className='query'> <button onClick={()=>find('lost')} className='query'>
{pending {pending
? <i className='fas fa-spin fa-spinner' /> ? <i className='fas fa-spin fa-spinner' />
: 'Query Brews' : 'Query Brews'
} }
</button> </button>
{renderPrimed()} {renderFound()}
{error && <div className='error noBrews'>{error.toString()}</div>} {error && <div className='error noBrews'>{error.toString()}</div>}
</div>; </div>;