Added pet-not-found
This commit is contained in:
parent
8485efc47c
commit
786efc86fd
@ -20,6 +20,7 @@ const appRouter = createBrowserRouter(
|
||||
<Route path=":type" element={<HomePage />} />
|
||||
<Route path=":type/:id" element={<PetDetailsPage />} />
|
||||
<Route path="search" element={<SearchPage />} />
|
||||
<Route path="pet-details-not-found" element={<PetDetailsNotFound />} />
|
||||
</Route>
|
||||
)
|
||||
);
|
||||
|
@ -20,6 +20,8 @@ const Search = () => {
|
||||
const query = createSearchParams(searchQuery);
|
||||
|
||||
// imperatively redirect with useNavigate() returned function
|
||||
|
||||
//Dont really understand why I am passing an object to useNavigate
|
||||
navigate({ pathname: "/search", search: `${query}` });
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
|
||||
import { getPetDetails } from "../../api/petfinder";
|
||||
import Hero from "../../components/hero";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Navigate } from "react-router-dom";
|
||||
|
||||
// Import useParams
|
||||
// Import Navigate
|
||||
@ -33,7 +34,7 @@ const PetDetailsPage = () => {
|
||||
<h3>Loading...</h3>
|
||||
) : error ? (
|
||||
<div>
|
||||
{/* Redirect to /pet-details-not-found if there was an error! */}
|
||||
<Navigate to="/pet-details-not-found" />
|
||||
</div>
|
||||
) : (
|
||||
<main>
|
||||
|
@ -1,19 +1,21 @@
|
||||
import React from 'react';
|
||||
// import useNavigate here.
|
||||
import React from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
const PetDetailsNotFound = () => {
|
||||
|
||||
// get the navigate function from useNavigate
|
||||
const navigate = "REPLACE ME";
|
||||
const navigate = useNavigate();
|
||||
|
||||
const goHome = () => {
|
||||
// Go home!
|
||||
}
|
||||
navigate("/");
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<h3>404: Who let the dogs out?</h3>
|
||||
<p>Sorry, but the details for this pet have not been uploaded by the shelter yet. Check back later!</p>
|
||||
<p>
|
||||
Sorry, but the details for this pet have not been uploaded by the
|
||||
shelter yet. Check back later!
|
||||
</p>
|
||||
<img
|
||||
src="https://i.chzbgr.com/full/8362031616/h9EB970C5/weve-lost-our-corgination"
|
||||
alt=""
|
||||
|
Loading…
Reference in New Issue
Block a user