diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx index d623e897..e3bf3203 100644 --- a/src/app/search/page.tsx +++ b/src/app/search/page.tsx @@ -1,11 +1,13 @@ 'use client'; import { Suspense, useState } from 'react'; +import Link from 'next/link'; import { useSuspenseGetSearchNickname } from '@/apis/member'; import FollowerItem from '@/components/ListItem/Follow/FollowerItem'; import FollowingItem from '@/components/ListItem/Follow/FollowingItem'; import { ProfileItemSkeleton } from '@/components/ListItem/ProfileListItem'; import SearchBar from '@/components/SearchBar/SearchBar'; +import { ROUTER } from '@/constants/router'; import { css } from '@/styled-system/css'; function SearchPage() { @@ -46,10 +48,14 @@ function List({ nickname }: { nickname: string }) { memberId: item.memberId, onButtonClick, }; - return item.followStatus === 'FOLLOWING' ? ( - - ) : ( - + return ( + + {item.followStatus === 'FOLLOWING' ? ( + + ) : ( + + )} + ); })} diff --git a/src/components/ListItem/Follow/FollowerItem.tsx b/src/components/ListItem/Follow/FollowerItem.tsx index a5a4ea90..c7e29099 100644 --- a/src/components/ListItem/Follow/FollowerItem.tsx +++ b/src/components/ListItem/Follow/FollowerItem.tsx @@ -1,4 +1,4 @@ -import { type ComponentProps } from 'react'; +import { type ComponentProps, type MouseEventHandler } from 'react'; import { FOLLOW_API } from '@/apis/follow'; import { isSeverError } from '@/apis/instance.api'; import { type FollowStatusType } from '@/apis/schema/member'; @@ -15,12 +15,13 @@ interface Props extends Omit, 'buttonElem function FollowerItem(props: Props) { const { triggerSnackBar } = useSnackBar(); - const onFollowerClick = async () => { + const onFollowerClick: MouseEventHandler = async (e) => { + e.preventDefault(); + try { await FOLLOW_API.addFollow(props.memberId); props.onButtonClick?.(); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { + } catch (error) { if (isSeverError(error)) { triggerSnackBar({ message: error.response.data.data.message, diff --git a/src/components/ListItem/Follow/FollowingItem.tsx b/src/components/ListItem/Follow/FollowingItem.tsx index 69c12954..d98b4eb6 100644 --- a/src/components/ListItem/Follow/FollowingItem.tsx +++ b/src/components/ListItem/Follow/FollowingItem.tsx @@ -1,4 +1,4 @@ -import { type ComponentProps } from 'react'; +import { type ComponentProps, type MouseEventHandler } from 'react'; import { FOLLOW_API } from '@/apis/follow'; import Button from '@/components/Button/Button'; import { ProfileListItem } from '@/components/ListItem'; @@ -12,7 +12,9 @@ interface Props extends Omit, 'buttonElem function FollowingItem(props: Props) { const { triggerSnackBar } = useSnackBar(); - const onFollowerClick = async () => { + const onFollowerClick: MouseEventHandler = async (e) => { + e.preventDefault(); + try { await FOLLOW_API.deleteFollow(props.memberId); props.onButtonClick?.();