Skip to content

Commit

Permalink
feat(front): error badge when no results
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonestla committed Aug 19, 2024
1 parent 388192a commit e5c2644
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
9 changes: 0 additions & 9 deletions project/front/src/components/home/index.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion project/front/src/components/input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const YEARS = Array.from({ length: (2011 - 2023) / -1 + 1 }, (_, i) => 2023 + i

export default function Input() {
const { currentQuery, currentMatcher, currentYear, handleQueryChange, handleMatcherChange, handleYearChange } = useUrl()
const enableYear: boolean = MATCHER_TYPES.find((matcher) => matcher.key == currentMatcher).year
const enableYear: boolean = MATCHER_TYPES.find((matcher) => matcher.key == currentMatcher)?.year || false

return (
<Container className="bg-input">
Expand Down
7 changes: 3 additions & 4 deletions project/front/src/components/results/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useEffect, useState } from "react"
import { Container, Text } from "@dataesr/dsfr-plus"
import { Container, Text, Badge } from "@dataesr/dsfr-plus"
import useMatch from "../../hooks/useMatch"
import useUrl from "../../hooks/useUrl"
import Error from "../error"
import Result from "./result"
import Fetching from "../fetching"
import Home from "../home"
import { MatchIds } from "../../types/data"

export default function Results() {
Expand All @@ -15,7 +14,7 @@ export default function Results() {

useEffect(() => setTitle(currentQuery), [currentQuery])

if (!currentQuery || !currentMatcher) return <Home />
if (!currentQuery || !currentMatcher) return null

if (error) return <Error error={error} />

Expand All @@ -30,7 +29,7 @@ export default function Results() {
return (
<Container>
<Text size="lead">{currentTitle}</Text>
<Text>NO RESULTS</Text>
<Badge color="error">{`${currentMatcher} : no results`}</Badge>
</Container>
)

Expand Down

0 comments on commit e5c2644

Please sign in to comment.