Skip to content

Commit

Permalink
fixed pet profile image bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rajghodasara1 committed Dec 12, 2023
1 parent 0724659 commit a25659f
Show file tree
Hide file tree
Showing 2 changed files with 6 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
9 changes: 5 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: React.FC = ({userid} : {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=${userid}`, {
responseType: "blob",
})
.then((response) => {
Expand Down Expand Up @@ -358,7 +358,7 @@ const PetProfiles: React.FC = () => {
);
};

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

const [petFormData, setPetFormData] = useState({
Expand Down Expand Up @@ -449,6 +449,7 @@ const PetProfilePage = () => {
}
};

// @ts-ignore
return (
<div className="max-w-screen-md mx-auto p-6">
<Tab.Group>
Expand All @@ -475,7 +476,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={userid} /> }</Tab.Panel>
<Tab.Panel>
{activeTab === "add" && (
<div className="mb-4 flex flex-col justify-between">
Expand Down

0 comments on commit a25659f

Please sign in to comment.