mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 23:22:42 +00:00
from admin to archive api
This commit is contained in:
@@ -3,7 +3,6 @@ const React = require('react');
|
||||
const createClass = require('create-react-class');
|
||||
const _ = require('lodash');
|
||||
const cx = require('classnames');
|
||||
const Moment = require('moment');
|
||||
|
||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||
const Navbar = require('../../navbar/navbar.jsx');
|
||||
@@ -11,6 +10,7 @@ const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||
const Account = require('../../navbar/account.navitem.jsx');
|
||||
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
||||
const ListPage = require('../basePages/listPage/listPage.jsx');
|
||||
|
||||
const request = require('superagent');
|
||||
|
||||
@@ -22,7 +22,7 @@ const ArchivePage = createClass({
|
||||
getInitialState: function () {
|
||||
return {
|
||||
query : '',
|
||||
foundBrews : null,
|
||||
brewCollection : null,
|
||||
searching : false,
|
||||
error : null,
|
||||
};
|
||||
@@ -34,80 +34,20 @@ const ArchivePage = createClass({
|
||||
this.setState({ searching: true, error: null });
|
||||
|
||||
request
|
||||
.get(`/admin/archive/${this.state.query}`)
|
||||
.then((res) => this.setState({ foundBrews: res.body }))
|
||||
.get(`/archive/${this.state.query}`)
|
||||
.then((res) => this.setState({ brewCollection: res.body }))
|
||||
.catch((err) => this.setState({ error: err }))
|
||||
.finally(() => this.setState({ searching: false }));
|
||||
},
|
||||
renderFoundBrews() {
|
||||
const brews = this.state.foundBrews;
|
||||
const brews = this.state.brewCollection;
|
||||
|
||||
if (!brews || brews.length === 0) {
|
||||
return <div>No brews found.</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='foundBrews'>
|
||||
{brews.map((brew, index) => (
|
||||
<div key={index} className='brewItem'>
|
||||
<dl>
|
||||
<dt>Title:</dt>
|
||||
<dd>{brew.title}</dd>
|
||||
|
||||
<dt>Authors:</dt>
|
||||
<dd>
|
||||
{brew.authors.map((author, index) => (
|
||||
<span key={index}>
|
||||
<a
|
||||
href={`/user/${author}`}
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
>
|
||||
{author}
|
||||
</a>
|
||||
{index < brew.authors.length - 1 && ', '}
|
||||
</span>
|
||||
))}
|
||||
</dd>
|
||||
|
||||
<a href={`/share/${brew.shareId}`}>
|
||||
Check the brew <i className='fas fa-external-link-alt'></i>
|
||||
</a>
|
||||
|
||||
<dt>Systems:</dt>
|
||||
<dd>{brew.systems.join(', ')}</dd>
|
||||
|
||||
{brew.tags?.length ? (
|
||||
<>
|
||||
<div
|
||||
className='brewTags'
|
||||
title={`Tags:\n${brew.tags.join('\n')}`}
|
||||
>
|
||||
<i className='fas fa-tags' />
|
||||
{brew.tags.map((tag, idx) => {
|
||||
const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/);
|
||||
return (
|
||||
<span key={idx} className={matches[1]}>
|
||||
{matches[2]}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
|
||||
<dt>Last Updated:</dt>
|
||||
<dd>{Moment(brew.updatedAt).fromNow()}</dd>
|
||||
|
||||
<dt>Num of Views:</dt>
|
||||
<dd>{brew.views}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
return <ListPage brewCollection={this.state.brewCollection} /*navItems={this.navItems()}*/ reportError={this.errorReported}></ListPage>;
|
||||
|
||||
},
|
||||
|
||||
renderForm: function () {
|
||||
|
||||
Reference in New Issue
Block a user