-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated img urls in seed data | view current user pets functionality …
…| started user homepage views
- Loading branch information
1 parent
608aeeb
commit 89511eb
Showing
9 changed files
with
164 additions
and
17 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
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,10 +1,21 @@ | ||
import firebase from "firebase/app"; | ||
import "firebase/auth"; | ||
import { VetHomePage } from "./VetHomePage"; | ||
import { OwnerHomePage } from "./OwnerHomePage"; | ||
|
||
export const HomePage = () => { | ||
|
||
var homePage; | ||
|
||
if (!firebase.auth().currentUser.isVet) { | ||
homePage = <OwnerHomePage />; | ||
} else { | ||
homePage = <VetHomePage />; | ||
} | ||
|
||
return ( | ||
<> | ||
<VetHomePage /> | ||
</> | ||
) | ||
<nav> | ||
{homePage} | ||
</nav> | ||
); | ||
} |
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,32 @@ | ||
import "firebase/auth"; | ||
import { getUserPets } from "../../modules/petManager"; | ||
import React, { useEffect, useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { Card } from "reactstrap"; | ||
|
||
export const OwnerHomePage = () => { | ||
const [ownerPets, setOwnerPets] = useState([]); | ||
|
||
const getAll = () => { | ||
getUserPets().then(ownerPets => setOwnerPets(ownerPets)); | ||
} | ||
|
||
useEffect(() => { | ||
getAll(); | ||
}, []); | ||
|
||
return ( | ||
<div className="pet-container"> | ||
{ownerPets.map((pet) => { | ||
return <div className="pet-list-container" key={pet.id}> | ||
<div><img style={{ width: 200 }} src={pet.imageLocation} /></div> | ||
<div>{pet.name}</div> | ||
<div>{pet.birthdate}</div> | ||
<div>{pet.breed}</div> | ||
<div><Link to={``}>Edit</Link><Link to={``}>Delete</Link></div> | ||
<div><Link to={``}>View All Records</Link></div> | ||
</div> | ||
})} | ||
</div> | ||
) | ||
} |
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,22 @@ | ||
import { getToken } from "./authManager"; | ||
|
||
const baseUrl = "/api/user"; | ||
|
||
export const getCurrentUserByFirebaseId = (id) => { | ||
return getToken().then((token) => { | ||
return fetch(`${baseUrl}/${id}`, { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}).then((res) => { | ||
if (res.ok) { | ||
return res.json(); | ||
} else { | ||
throw new Error( | ||
"An unknown error occured.", | ||
); | ||
} | ||
}); | ||
}); | ||
}; |
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