-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
103 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { useContext, useEffect, useState } from "react" | ||
import { HOST_URL } from "../common/urls" | ||
import { UserContext } from "../context/UserContext" | ||
|
||
interface CatInfo { | ||
photo_url: string; | ||
name: string; | ||
breed: string; | ||
microchip_id: string; | ||
passport_id: string; | ||
create_on: string | ||
} | ||
|
||
const catInfoInitialState = { | ||
photo_url: "", | ||
name: "", | ||
breed: "", | ||
microchip_id: "", | ||
passport_id: "", | ||
create_on: "" | ||
} | ||
|
||
const CatReview: React.FC = () => { | ||
const [catInfo, setCatInfo] = useState<CatInfo>(catInfoInitialState) | ||
|
||
const { user } = useContext(UserContext) | ||
|
||
console.log(user.token) | ||
|
||
const fetchCatInfo = () => { | ||
if (!user.token) return | ||
fetch(`${HOST_URL}/cat`, { | ||
headers: { | ||
"Authorization": `Bearer ${user.token}` | ||
} | ||
}) | ||
.then(resp => resp.json()) | ||
.then(json => { | ||
console.log(json) | ||
setCatInfo(json) | ||
}) | ||
} | ||
|
||
useEffect(fetchCatInfo, [user.token]) | ||
|
||
return ( | ||
<div> | ||
<h2>Review</h2> | ||
<section className="voting-image-section"> | ||
<img src={catInfo.photo_url} alt="" /> | ||
</section> | ||
<section> | ||
<article className="flex"> | ||
<p>Name:</p> | ||
<p>{catInfo.name}</p> | ||
</article> | ||
<article className="flex"> | ||
<p>Breed:</p> | ||
<p>{catInfo.breed}</p> | ||
</article> | ||
<article className="flex"> | ||
<p>Microchip ID:</p> | ||
<p>{catInfo.microchip_id}</p> | ||
</article> | ||
<article className="flex"> | ||
<p>Passport ID:</p> | ||
<p>{catInfo.passport_id}</p> | ||
</article> | ||
<article className="flex"> | ||
<p>Added on:</p> | ||
<p>{catInfo.create_on}</p> | ||
</article> | ||
</section> | ||
</div> | ||
) | ||
} | ||
|
||
export default CatReview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// const LOCAL_HOST = "http://127.0.0.1:5000" | ||
const LOCAL_HOST = "http://127.0.0.1:5000" | ||
|
||
const AZURE_HOST = "https://cat-of-the-day-back-end.azurewebsites.net/" | ||
// const AZURE_HOST = "https://cat-of-the-day-back-end.azurewebsites.net/" | ||
|
||
export const HOST_URL = AZURE_HOST | ||
export const HOST_URL = LOCAL_HOST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React, { createContext } from "react"; | ||
|
||
type CatExists = boolean | ||
|
||
export const CatExistsContext: React.Context<boolean> = createContext<boolean>(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters