Skip to content

Commit

Permalink
#27 Correction d'une erreur au niveau de la redirection lorsqu'il n'y…
Browse files Browse the repository at this point in the history
… avait aucune difficulté de sélectionnée
  • Loading branch information
BluedyRimuru committed Mar 3, 2024
1 parent a54e994 commit 925b479
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/components/DifficultyRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default function DifficultyRules ({ answer }: DifficultyRulesProps) {
const [consonants, setConsonants] = useState(0)
const [vowels, setVowels] = useState(0)
const locationDifficulty = new LocationDifficulty(useLocation())
locationDifficulty.checkLocationState(useLocation())

const compterSyllabesEtVoyelles = (word: string) => {
word = word.toLowerCase().trim()
Expand Down
9 changes: 1 addition & 8 deletions src/entities/LocationDifficulty.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type Location, Navigate } from 'react-router-dom'
import React from 'react'
import { type Location } from 'react-router-dom'

export class LocationDifficulty {
private _difficulty: string
Expand All @@ -16,12 +15,6 @@ export class LocationDifficulty {
this._location = location
}

checkLocationState (location: Location) {
if (location.state === undefined || location.state === null) {
return <Navigate to="/motus"/> // Rediriger vers la page de base
}
}

getDifficulty (): string {
return this._difficulty
}
Expand Down
8 changes: 6 additions & 2 deletions src/home/Motus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import DictionaryRuleProcessor from '../components/DictionaryRuleProcessor'
import WordHistory from '../components/WordHistory'
import InputAnswer from '../components/InputAnswer'
import DifficultyRules from '../components/DifficultyRules'
import { Link, useLocation } from 'react-router-dom'
import { Link, Navigate, useLocation } from 'react-router-dom'
import HealthTry from '../components/HealthTry'
import { LocationDifficulty } from '../entities/LocationDifficulty'

export default function Motus () {
const [answer, setAnswer] = useState('')
const [historyInput, setHistoryInput] = useState<string[]>([])
const [inputValue, setInputValue] = useState<string>('')
const locationDifficulty = new LocationDifficulty(useLocation())
const location = useLocation()
if (location.state === undefined || location.state === null) {
return <Navigate to="/motus"/> // Rediriger vers la page de base
}
const locationDifficulty = new LocationDifficulty(location)

const reloadPage = () => {
window.location.reload()
Expand Down

0 comments on commit 925b479

Please sign in to comment.