Skip to content

Commit

Permalink
frontend: fix issue picture fetching (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolharsam authored Dec 12, 2023
1 parent e829a84 commit 508b299
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/src/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const Home = (props: React.PropsWithChildren<HomeProps>) => {
} else if (pathname === ROUTES.PROTECTED_ROUTES.LOCATIONS) {
return <Locations />;
} else if (pathname === ROUTES.PROTECTED_ROUTES.PET_PROFILES) {
return <PetProfiles />;
return <PetProfiles userId={props.authContext.authenticationState.sessionInformation.id} />;
} else if (pathname === ROUTES.PROTECTED_ROUTES.JOBS) {
return <JobPage />;
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/PetProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PetCardChip = (props: { title: string; value: string }) => {
);
};

const PetProfiles: React.FC = () => {
const PetProfiles = (props: { userId: string }) => {
const [pets, setPets] = useState<Pet[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
Expand Down Expand Up @@ -68,7 +68,7 @@ const PetProfiles: React.FC = () => {
if (response.data.length) {
response.data.forEach((pet: Pet) => {
axios
.get(`${API_ROUTES.USER.PET_PICTURE}?id=${pet.id}`, {
.get(`${API_ROUTES.USER.PET_PICTURE}?id=${pet.id}&owner_id=${props.userId}`, {
responseType: "blob",
})
.then((response) => {
Expand Down Expand Up @@ -358,7 +358,7 @@ const PetProfiles: React.FC = () => {
);
};

const PetProfilePage = () => {
const PetProfilePage = (props: { userId: string }) => {
const [activeTab, setActiveTab] = useState("view");

const [petFormData, setPetFormData] = useState({
Expand Down Expand Up @@ -475,7 +475,7 @@ const PetProfilePage = () => {
</Tab>
</Tab.List>
<Tab.Panels className="p-4 bg-white border border-t-0 rounded-b-md">
<Tab.Panel>{activeTab === "view" && <PetProfiles />}</Tab.Panel>
<Tab.Panel>{activeTab === "view" && <PetProfiles userId={props.userId} />}</Tab.Panel>
<Tab.Panel>
{activeTab === "add" && (
<div className="mb-4 flex flex-col justify-between">
Expand Down

0 comments on commit 508b299

Please sign in to comment.