Skip to content

Commit

Permalink
feat : 팔로우 검새화면에서 타인프로필 화면으로 라우팅
Browse files Browse the repository at this point in the history
  • Loading branch information
wade3420 committed Jan 28, 2024
1 parent 7d41347 commit 4e653ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
14 changes: 10 additions & 4 deletions src/app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -46,10 +48,14 @@ function List({ nickname }: { nickname: string }) {
memberId: item.memberId,
onButtonClick,
};
return item.followStatus === 'FOLLOWING' ? (
<FollowingItem key={item.memberId} {...params} />
) : (
<FollowerItem key={item.memberId} followStatus={item.followStatus} {...params} />
return (
<Link key={item.memberId} href={ROUTER.PROFILE.DETAIL(item.memberId)}>
{item.followStatus === 'FOLLOWING' ? (
<FollowingItem {...params} />
) : (
<FollowerItem followStatus={item.followStatus} {...params} />
)}
</Link>
);
})}
</ul>
Expand Down
9 changes: 5 additions & 4 deletions src/components/ListItem/Follow/FollowerItem.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,12 +15,13 @@ interface Props extends Omit<ComponentProps<typeof ProfileListItem>, 'buttonElem
function FollowerItem(props: Props) {
const { triggerSnackBar } = useSnackBar();

const onFollowerClick = async () => {
const onFollowerClick: MouseEventHandler<HTMLButtonElement> = 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,
Expand Down
6 changes: 4 additions & 2 deletions src/components/ListItem/Follow/FollowingItem.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,7 +12,9 @@ interface Props extends Omit<ComponentProps<typeof ProfileListItem>, 'buttonElem
function FollowingItem(props: Props) {
const { triggerSnackBar } = useSnackBar();

const onFollowerClick = async () => {
const onFollowerClick: MouseEventHandler<HTMLButtonElement> = async (e) => {
e.preventDefault();

try {
await FOLLOW_API.deleteFollow(props.memberId);
props.onButtonClick?.();
Expand Down

0 comments on commit 4e653ed

Please sign in to comment.