-
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.
Merge pull request #6 from rebekahgrandey/vet-home-page
fixed register in UserController, fixed repos, changed homepage direc…
- Loading branch information
Showing
9 changed files
with
183 additions
and
22 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
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,10 @@ | ||
import { VetHomePage } from "./VetHomePage"; | ||
|
||
export const HomePage = () => { | ||
|
||
return ( | ||
<> | ||
<VetHomePage /> | ||
</> | ||
) | ||
} |
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,3 +1,32 @@ | ||
import React from "react"; | ||
import { Routes, Route, Navigate } from "react-router-dom"; | ||
import { getAllPets } from "../../modules/petManager"; | ||
import React, { useEffect, useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { Card } from "reactstrap"; | ||
|
||
export const VetHomePage = () => { | ||
const [pets, setPets] = useState([]); | ||
|
||
const getAll = () => { | ||
getAllPets().then(pets => setPets(pets)); | ||
} | ||
|
||
useEffect(() => { | ||
getAll(); | ||
}, []); | ||
|
||
return ( | ||
<div className="pet-container"> | ||
<div className="pet_list_header"><div className="pet-left">Owner</div><div className="pet-center">Number</div><div className="pet-right">Pet</div></div> | ||
<div className="row justify-content-center"> | ||
{pets.map((pet) => { | ||
return <Card key={pet.id}><div className="pet-list-container"> | ||
<div className="pet_elements pet-left">{pet.owner.phone}</div> | ||
<div className="post_elements post-center">{pet.owner.name}</div> | ||
<div className="post_elements post-right"><Link to={``}>{pet.name}</Link></div> | ||
<div></div> | ||
</div></Card> | ||
})} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { getToken } from "./authManager"; | ||
|
||
const baseUrl = '/api/pet'; | ||
|
||
export const getAllPets = () => { | ||
return getToken().then((token) => { | ||
return fetch(baseUrl, { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}).then((res) => { | ||
if (res.ok) { | ||
return res.json(); | ||
} else { | ||
throw new Error( | ||
"An unknown error occurred.", | ||
); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
export const addPet = (pet) => { | ||
return getToken().then((token) => { | ||
return fetch(baseUrl, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Authorization": `Bearer ${token}` | ||
}, | ||
body: JSON.stringify(pet) | ||
}); | ||
}); | ||
|
||
|
||
}; | ||
|
||
export const getPetById = (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.", | ||
); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
export const editPet = (pet, id) => { | ||
return getToken().then((token) => { | ||
return fetch(`${baseUrl}/${id}`, { | ||
method: "PUT", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Authorization": `Bearer ${token}` | ||
}, | ||
body: JSON.stringify(pet) | ||
}); | ||
}); | ||
|
||
}; |