From 4ed9fc7d0e4a3a6aaa3453e36f71d1e905323e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Tue, 23 Jan 2024 18:35:09 +0100 Subject: [PATCH] fix url params --- client/homebrew/homebrew.jsx | 1 - .../pages/archivePage/archivePage.jsx | 38 +++++++++---------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/client/homebrew/homebrew.jsx b/client/homebrew/homebrew.jsx index 039d81e2c..257128766 100644 --- a/client/homebrew/homebrew.jsx +++ b/client/homebrew/homebrew.jsx @@ -76,7 +76,6 @@ const Homebrew = createClass({ } /> } /> }/> - }/> } /> } /> } /> diff --git a/client/homebrew/pages/archivePage/archivePage.jsx b/client/homebrew/pages/archivePage/archivePage.jsx index e79b8bf34..10c1afb03 100644 --- a/client/homebrew/pages/archivePage/archivePage.jsx +++ b/client/homebrew/pages/archivePage/archivePage.jsx @@ -10,7 +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 BrewItem = require('../basePages/listPage/brewItem/brewItem.jsx'); const request = require('superagent'); @@ -21,34 +21,26 @@ const ArchivePage = createClass({ }, getInitialState: function () { return { - query : '', + title : this.props.query.title || '', brewCollection : null, searching : false, error : null, }; }, - componentDidMount: function () { - const url = new URL(window.location.href); - const pathSegments = url.pathname.split('/'); - - // Check if there's a path parameter after /archive/ - if (pathSegments.length > 2 && pathSegments[1] === 'archive') { - const pathQuery = pathSegments[2]; - console.log(pathQuery); - this.setState({ query: pathQuery }, () => { - this.lookup(); - }); - } + componentDidMount : function() { + console.log(this.state.title); + this.lookup(); }, + handleChange(e) { - this.setState({ query: e.target.value }); + this.setState({ title: e.target.value }); }, lookup() { this.setState({ searching: true, error: null }); request - .get(`/archive/${this.state.query}`) + .get(`/archive/${this.state.title}`) .then((res) => this.setState({ brewCollection: res.body })) .catch((err) => this.setState({ error: err })) .finally(() => this.setState({ searching: false })); @@ -61,8 +53,8 @@ const ArchivePage = createClass({ urlParams.delete('dir'); urlParams.delete('filter'); - // Set the pathname to '/archive/query' - url.pathname = `/archive/${this.state.query}`; + // Set the pathname to '/archive/?query' + urlParams.set('title', this.state.title); url.search = urlParams; window.history.replaceState(null, null, url); @@ -73,9 +65,13 @@ const ArchivePage = createClass({ if (!brews || brews.length === 0) { return
No brews found.
; } - console.table(brews); this.updateUrl(); - return ; + return
+ {brews.map((brew, index) => ( + + ))} +
+ }, @@ -86,7 +82,7 @@ const ArchivePage = createClass({