Skip to content

Commit

Permalink
fix issue with default location update render
Browse files Browse the repository at this point in the history
  • Loading branch information
kolharsam committed Dec 11, 2023
1 parent c112247 commit edeb8ac
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/src/Locations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ const Locations = () => {
const updateDefault = (location: FurbabyLocation, newDefault: boolean) => {
axios
.put(API_ROUTES.USER.LOCATION, { ...location, default_location: newDefault })
.then((resp) => {
console.log(resp);
.then(() => {
toast.success(`updated default location to ${location.address}`);
getLocations();
})
.catch((err) => {
console.error(err);
Expand All @@ -99,16 +100,15 @@ const Locations = () => {
if (locations.length) {
return (
<div className="grid gap-x-8 gap-y-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3">
{locations.map((loc, index) => (
{locations.map((loc) => (
<div className="card w-96 bg-base-100 shadow-md" key={loc.id}>
{loc.default_location && (
<div className="absolute top-7 right-7">
<div className="badge badge-outline">Default</div>
</div>
)}
<div className="card-body">
<h2 className="card-title">Location {index + 1}</h2>
<p className="prose">{loc.address}</p>
<h2 className="card-title">{loc.address}</h2>
<p className="prose">
{loc.city}, {loc.country} - {loc.zipcode}
</p>
Expand Down

0 comments on commit edeb8ac

Please sign in to comment.