Skip to content

Commit

Permalink
Fix feeback rating for no search results as negative
Browse files Browse the repository at this point in the history
  • Loading branch information
lunars97 committed Jan 10, 2025
1 parent 5536887 commit 9cef14f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
15 changes: 13 additions & 2 deletions native/src/components/FeedbackContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ export type FeedbackContainerProps = {
cityCode: string
query?: string
slug?: string
noResults: boolean
}

const FeedbackContainer = ({ query, language, routeType, cityCode, slug }: FeedbackContainerProps): ReactElement => {
const FeedbackContainer = ({
query,
language,
routeType,
cityCode,
slug,
noResults,
}: FeedbackContainerProps): ReactElement => {
const [comment, setComment] = useState<string>('')
const [contactMail, setContactMail] = useState<string>('')
const [isPositiveRating, setIsPositiveRating] = useState<boolean | null>(null)
Expand All @@ -33,7 +41,10 @@ const FeedbackContainer = ({ query, language, routeType, cityCode, slug }: Feedb

useEffect(() => {
setSearchTerm(query)
}, [query])
if (noResults === true) {
setIsPositiveRating(false)
}
}, [query, noResults])

const handleSubmit = () => {
setSendingStatus('sending')
Expand Down
8 changes: 7 additions & 1 deletion native/src/routes/SearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ const SearchModal = ({
accessibilityLabel={t('searchResultsCount', { count: searchResults.length })}
style={{ flex: 1 }}
noItemsMessage={
<FeedbackContainer routeType={SEARCH_ROUTE} language={languageCode} cityCode={cityCode} query={query} />
<FeedbackContainer
routeType={SEARCH_ROUTE}
language={languageCode}
cityCode={cityCode}
noResults={searchResults.length === 0}
query={query}
/>
}
/>
</>
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/FeedbackContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export const FeedbackContainer = ({

useEffect(() => {
setSearchTerm(query)
}, [query])
if (noResults === true) {
isPositiveRating = false
}
}, [query, noResults])

const handleSubmit = () => {
setSendingStatus('sending')
Expand Down

0 comments on commit 9cef14f

Please sign in to comment.