Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kchanatipz committed Feb 19, 2024
1 parent 815371a commit 68fe230
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/api/pets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ const postPet = async (data: postPetRequest): Promise<Pet> => {
return response.data;
};

const updateVisibility = async (id: string, visibility: boolean): Promise<Pet> => {
const updateVisibility = async (
id: string,
visibility: boolean
): Promise<Pet> => {
const { accessToken } = useAuthStore.getState();

const response = await axios.put<Pet>(
`${import.meta.env.VITE_API_URL}/pets/${id}`,
{
is_visible: visibility
is_visible: visibility,
},
{
headers: {
Expand All @@ -53,7 +56,7 @@ const updateVisibility = async (id: string, visibility: boolean): Promise<Pet> =
);

return response.data;
}
};

export { getPets, postPet, updateVisibility };
export type { PetsResponse, postPetRequest };
8 changes: 5 additions & 3 deletions src/components/Card/PetCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
};


const likeHandle = (event: React.MouseEvent<HTMLButtonElement>) => {
handleClick(event);
};
Expand All @@ -50,7 +49,7 @@ const PetCard = ({
const [visibility, setVisibility] = useState(isVisibled);
const toggleVisibility = () => {
setVisibility((prev) => !prev);
}
};

const pathname = useLocation().pathname;
const role = useMemo(() => {
Expand Down Expand Up @@ -128,7 +127,10 @@ const PetCard = ({
onClick={adoptHandle}
/>
) : (
<TogglePetButton visibility={visibility} onClick={toggleVisibility} />
<TogglePetButton
visibility={visibility}
onClick={toggleVisibility}
/>
)}
</div>
</div>
Expand Down
13 changes: 7 additions & 6 deletions src/hooks/mutation/useUpdateVisibility.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {updateVisibility} from "@/api/pets";
import { updateVisibility } from "@/api/pets";
import { useMutation } from "@tanstack/react-query";

const useUpdateVisibility = () => {
return useMutation({
mutationFn: ({ id, visibility }: { id: string, visibility: boolean }) => updateVisibility(id, visibility)
});
}
return useMutation({
mutationFn: ({ id, visibility }: { id: string; visibility: boolean }) =>
updateVisibility(id, visibility),
});
};

export { useUpdateVisibility };
export { useUpdateVisibility };

0 comments on commit 68fe230

Please sign in to comment.