0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 06:42:45 +00:00

"Removed ArchivePage and related files, replaced with VaultPage, updated routes and API endpoints, and made minor changes to theme configuration and error handling."

This commit is contained in:
Víctor Losada Hernández
2024-06-11 00:33:36 +02:00
parent 99b0c2b54e
commit 90431efbc9
8 changed files with 43 additions and 37 deletions

View File

@@ -10,7 +10,7 @@ const UserPage = require('./pages/userPage/userPage.jsx');
const SharePage = require('./pages/sharePage/sharePage.jsx');
const NewPage = require('./pages/newPage/newPage.jsx');
const ErrorPage = require('./pages/errorPage/errorPage.jsx');
const PrintPage = require('./pages/printPage/printPage.jsx');
const VaultPage = require('./pages/vaultPage/vaultPage.jsx');
const AccountPage = require('./pages/accountPage/accountPage.jsx');
const WithRoute = (props)=>{
@@ -72,9 +72,8 @@ const Homebrew = createClass({
<Route path='/new/:id' element={<WithRoute el={NewPage} brew={this.props.brew} />} />
<Route path='/new' element={<WithRoute el={NewPage}/>} />
<Route path='/user/:username' element={<WithRoute el={UserPage} brews={this.props.brews} />} />
<Route path='/print/:id' element={<WithRoute el={PrintPage} brew={this.props.brew} />} />
<Route path='/print' element={<WithRoute el={PrintPage} />} />
<Route path='/changelog' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
<Route path='/vault' element={<WithRoute el={VaultPage}/>}/>
<Route path='/faq' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
<Route path='/account' element={<WithRoute el={AccountPage} brew={this.props.brew} accountDetails={this.props.brew.accountDetails} />} />
<Route path='/legacy' element={<WithRoute el={HomePage} brew={this.props.brew} />} />

View File

@@ -117,8 +117,6 @@ const BrewItem = createClass({
});
}
const dateFormatString = 'YYYY-MM-DD HH:mm:ss';
const authors = brew.authors.length > 0 ? brew.authors : 'No authors';
return <div className='brewItem'>
{brew.thumbnail &&

View File

@@ -1,4 +1,4 @@
require('./archivePage.less');
require('./vaultPage.less');
const React = require('react');
const { useState, useEffect, useRef } = React;
@@ -14,7 +14,7 @@ const BrewItem = require('../basePages/listPage/brewItem/brewItem.jsx');
const request = require('../../utils/request-middleware.js');
const ArchivePage = (props) => {
const VaultPage = (props) => {
const [title, setTitle] = useState(props.query.title || '');
const [legacy, setLegacy] = useState(props.query.legacy !== 'false');
const [v3, setV3] = useState(props.query.v3 !== 'false');
@@ -29,6 +29,7 @@ const ArchivePage = (props) => {
const countRef = useRef(null);
const v3Ref = useRef(null);
const legacyRef = useRef(null);
const totalBrewsSpanRef = useRef(null);
useEffect(() => {
validateInput();
@@ -38,6 +39,23 @@ const ArchivePage = (props) => {
!totalBrews && loadTotal();
}, []);
useEffect(() => {
console.log(totalBrewsSpanRef);
console.log(totalBrews);
if (totalBrewsSpanRef.current) {
if (title === '') {
totalBrewsSpanRef.current.innerHTML = '0';
} else {
if (!totalBrews) {
totalBrewsSpanRef.current.innerHTML =
'<span class="searchAnim"></span>';
} else {
totalBrewsSpanRef.current.innerHTML = `${totalBrews}`;
}
}
}
}, [totalBrews, title, () => totalBrewsSpanRef.current]);
const updateStateWithBrews = (brews, page) => {
setBrewCollection(brews || null);
setPage(parseInt(page) || 1);
@@ -65,7 +83,7 @@ const ArchivePage = (props) => {
if (title !== '') {
try {
const response = await request.get(
`/api/archive?title=${title}&page=${page}&count=${count}&v3=${v3}&legacy=${legacy}`
`/api/vault?title=${title}&page=${page}&count=${count}&v3=${v3}&legacy=${legacy}`
);
if (response.ok) {
updateStateWithBrews(response.body.brews, page);
@@ -112,7 +130,7 @@ const ArchivePage = (props) => {
if (title) {
try {
const response = await request.get(
`/api/archive/total?title=${title}&v3=${v3}&legacy=${legacy}`
`/api/vault/total?title=${title}&v3=${v3}&legacy=${legacy}`
);
if (response.ok) {
@@ -134,7 +152,7 @@ const ArchivePage = (props) => {
<Navbar>
<Nav.section>
<Nav.item className="brewTitle">
Archive: Search for brews
Vault: Search for brews
</Nav.item>
</Nav.section>
<Nav.section>
@@ -171,10 +189,7 @@ const ArchivePage = (props) => {
pattern=".{3,}"
onKeyDown={(e) => {
if (e.key === 'Enter') {
if (
e.target.validity.valid &&
e.target.value
) {
if (e.target.validity.valid && e.target.value) {
loadTotal();
loadPage(1, true);
}
@@ -362,13 +377,7 @@ const ArchivePage = (props) => {
<div className="foundBrews">
<span className="totalBrews">
{`Brews found: `}
{title === '' ? (
'0'
) : totalBrews ? (
totalBrews
) : (
<span className="searchAnim"></span>
)}
<span ref={totalBrewsSpanRef}></span>
</span>
{brewCollection.map((brew, index) => (
<BrewItem
@@ -383,7 +392,7 @@ const ArchivePage = (props) => {
};
return (
<div className="archivePage">
<div className="vaultPage">
<link href="/themes/V3/Blank/style.css" rel="stylesheet" />
<link href="/themes/V3/5ePHB/style.css" rel="stylesheet" />
{renderNavItems()}
@@ -398,4 +407,4 @@ const ArchivePage = (props) => {
);
};
module.exports = ArchivePage;
module.exports = VaultPage;

View File

@@ -25,7 +25,7 @@ body {
}
}
.archivePage {
.vaultPage {
overflow-y: hidden;
height: 100%;
background-color: #2C3E50;