Skip to content

Commit

Permalink
Merge branch 'develop' into yami/UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Yami Naik committed Nov 27, 2023
2 parents 63e83f6 + 8a19d9d commit 1c0cda5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions frontend/src/Locations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { API_ROUTES } from "./constants";
// import fakeData from "./fakeData.json";
import Modal from "./Modal";
import { FurbabyLocation } from "./types";
import toast from "react-hot-toast";

const Locations = () => {
const [open, setOpen] = useState(false);
Expand All @@ -24,19 +25,26 @@ const Locations = () => {
.post(
API_ROUTES.USER.LOCATION,
JSON.stringify({
state,
// state,
address,
city,
zipcode,
country,
default_location: false,
})
)
.then((response) => {
// TODO: handle response
if (response.status === 201)
{
onCloseModal();
toast.success("Location added successfully.");
}
console.log(response);
})
.catch((err) => {
// TODO: handle error
toast.error("Failed to add location.");
console.error(err);
});
};
Expand All @@ -53,8 +61,9 @@ const Locations = () => {
return axios
.get(API_ROUTES.USER.LOCATION)
.then((response) => {
console.log(response);
return response;
console.log(response, response.data);
setLocations(response?.data ?? []);
// return response;
})
.catch((err) => {
console.error("failed to fetch locations", err);
Expand All @@ -63,9 +72,7 @@ const Locations = () => {

React.useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getLocations().then((response) => {
setLocations(response?.data?.locations ?? []);
});
getLocations()//.then((response) => {
}, []);

const setAsDefault = (location: FurbabyLocation) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const API_ROUTES = {
USER: {
USER_ROOT: "api/user",
PROFILE_PICTURE: "api/user/profile_picture",
LOCATION: "api/location",
LOCATION: "api/user/locations",
},
PETS: "pets/",
JOBS: "jobs/",
Expand Down

0 comments on commit 1c0cda5

Please sign in to comment.