Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back to results feature #376

Merged
merged 3 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/elements/ReviewEventMainSection.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { imageUrlForEvent } from 'utils/urls';
import defaultThumbnail from 'assets/ui/thumbnail.png';
import { useNavigate } from 'react-router-dom';

const styleClasses = {
mainSectionContainer: `
Expand All @@ -25,6 +25,7 @@ const styleClasses = {

function ReviewEventMainSection({ evt, editEvent }) {
const imageUrl = imageUrlForEvent(evt);
const navigate = useNavigate();

const handleImageError = (event) => {
event.target.src = defaultThumbnail;
Expand All @@ -34,7 +35,7 @@ function ReviewEventMainSection({ evt, editEvent }) {
<section>
<div className="mb-12">
<p className="text-xl">
<Link to="/"> &#8592; Back to Results</Link>
<button onClick={() => navigate(-1)}>Back to Results</button>
</p>
</div>

Expand Down
12 changes: 6 additions & 6 deletions src/components/elements/SearchForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ function SearchFormComponent({ clearFilters, setFieldValue, values }) {
*/
export function mapPropsToValues (props) {
return {
search: props.search || '',
search: props.search,
startDate: props.startDate,
endDate: props.endDate,
price: props.price || '',
eventType: props.eventType || '',
topic: props.topic || '',
language: props.language || '',
region: props.region || '',
price: props.price,
eventType: props.eventType,
topic: props.topic,
language: props.language,
region: props.region,
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/components/pages/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ function HomePage() {
clearFilters={clearFilters}
startDate={searchFilters.startDate}
endDate={searchFilters.endDate}
eventType={searchFilters.eventType}
search={searchFilters.search}
topic={searchFilters.topic}
language={searchFilters.language}
region={searchFilters.region}
price={searchFilters.price}
/>
<SearchEvents
events={results || []}
Expand Down
20 changes: 19 additions & 1 deletion src/hooks/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,24 @@ export function useSearchEvents() {
const page = searchParams.get('page') || 1;
const startDate = searchParams.get('startDate') || moment().subtract(2, 'weeks').format(DATE_PICKER_STRING_FORMAT);
const endDate = searchParams.get('endDate') || moment().add(6, 'months').format(DATE_PICKER_STRING_FORMAT);
const search = searchParams.get('search')
const eventType = searchParams.get('eventType')
const topic = searchParams.get('topic')
const language = searchParams.get('language')
const price = searchParams.get('price')
const region = searchParams.get('region')

const [searchFilters, setSearchFilters] = useState({
startDate,
endDate,
search: '',
eventType,
pageSize,
page,
search,
topic,
language,
price,
region
});
const [searchResultEvents, setSearchResultEvents] = useState([]);

Expand Down Expand Up @@ -106,6 +118,12 @@ export function useSearchEvents() {
startDate: moment().subtract(2, 'weeks').format(DATE_PICKER_STRING_FORMAT),
endDate: moment().add(5, 'months').format(DATE_PICKER_STRING_FORMAT),
search: '',
eventType: '',
topic: '',
language: '',
price: '',
region: '',

}

setSearchFilters({ ...clearedFilters });
Expand Down