({
queryKey: [QUERY_KEYS.getListDetail, params?.listId],
queryFn: () => getListDetail(Number(params?.listId)),
- enabled: !!params?.listId,
retry: 0,
});
@@ -209,7 +210,11 @@ function ListInformation() {
{list?.ownerNickname}
- {userId !== list?.ownerId && }
+
+ {userId && userId !== list?.ownerId && (
+
+ )}
+
{/* TODO: μ½λΌλ³΄λ μ΄ν° κΈ°λ₯ μ£Όμ */}
{/**/}
{/* */}
diff --git a/src/app/user/locale.ts b/src/app/user/locale.ts
index bcbc5aa0..2042602c 100644
--- a/src/app/user/locale.ts
+++ b/src/app/user/locale.ts
@@ -5,16 +5,15 @@ export const userLocale = {
follower: 'μμ§μ νλ‘μκ° μμ΄μ',
following: 'μμ§ νλ‘μ°ν μ¬λμ΄ μμ΄μ',
},
+ follow: 'νλ‘μ°',
follower: 'νλ‘μ',
following: 'νλ‘μ',
+ cancelFollow: 'νλ‘μ° μ·¨μ',
total: 'μ΄',
people: 'λͺ
',
myList: 'λ§μ΄ 리μ€νΈ',
collaboList: 'μ½λΌλ³΄ 리μ€νΈ',
noListMessage: 'ν΄λΉ μΉ΄ν
κ³ λ¦¬μ μμ§ λ¦¬μ€νΈκ° μμ΄μ',
- cancelFollow: 'νλ‘μ° μ·¨μ',
- follow: 'νλ‘μ°',
-
confirm: 'νμΈ',
goToMypage: 'λ§μ΄νμ΄μ§λ‘ μ΄λνκΈ°',
profileImageAlt: 'νλ‘ν μ΄λ―Έμ§',
diff --git a/src/components/FollowButton/FollowButton.css.ts b/src/components/FollowButton/FollowButton.css.ts
new file mode 100644
index 00000000..b268645b
--- /dev/null
+++ b/src/components/FollowButton/FollowButton.css.ts
@@ -0,0 +1,24 @@
+import { style } from '@vanilla-extract/css';
+import { vars } from '@/styles/theme.css';
+
+export const followButtonDefault = style({
+ width: 'auto',
+ height: 'auto',
+ padding: '4px 6px',
+
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+
+ backgroundColor: vars.color.blue,
+ borderRadius: '20px',
+ color: vars.color.white,
+ fontSize: '1.2rem',
+ fontWeight: '400',
+});
+
+export const followButtonFollowing = style({
+ backgroundColor: vars.color.white,
+ color: vars.color.bluegray8,
+ border: `0.5px solid ${vars.color.bluegray8}`,
+});
diff --git a/src/app/(home)/_components/FollowButton.tsx b/src/components/FollowButton/FollowButton.tsx
similarity index 66%
rename from src/app/(home)/_components/FollowButton.tsx
rename to src/components/FollowButton/FollowButton.tsx
index 4aa4e339..485068e0 100644
--- a/src/app/(home)/_components/FollowButton.tsx
+++ b/src/components/FollowButton/FollowButton.tsx
@@ -9,52 +9,44 @@ import getUserOne from '@/app/_api/user/getUserOne';
import { QUERY_KEYS } from '@/lib/constants/queryKeys';
import { UserType } from '@/lib/types/userProfileType';
+import { useUser } from '@/store/useUser';
import toasting from '@/lib/utils/toasting';
import toastMessage, { MAX_FOLLOWING } from '@/lib/constants/toastMessage';
-import * as styles from './RecommendedUsers.css';
-
import useBooleanOutput from '@/hooks/useBooleanOutput';
import Modal from '@/components/Modal/Modal';
import LoginModal from '@/components/login/LoginModal';
import { useLanguage } from '@/store/useLanguage';
import { commonLocale } from '@/components/locale';
+import * as styles from './FollowButton.css';
+
interface FollowButtonProps {
- isFollowing: boolean;
- onClick: () => void;
+ isFollowed: boolean;
+ onClick?: () => void;
userId: number;
- targetId: number;
}
-function FollowButton({ isFollowing, onClick, userId, targetId }: FollowButtonProps) {
- const { language } = useLanguage();
+function FollowButton({ isFollowed, onClick, userId }: FollowButtonProps) {
const queryClient = useQueryClient();
+ const { language } = useLanguage();
+ const { user: userMe } = useUser();
const { isOn, handleSetOff, handleSetOn } = useBooleanOutput();
const { data: userMeData } = useQuery({
- queryKey: [QUERY_KEYS.userOne, userId],
- queryFn: () => getUserOne(userId),
- enabled: !!userId,
- retry: 1,
+ queryKey: [QUERY_KEYS.userOne, userMe.id],
+ queryFn: () => getUserOne(userMe.id as number),
+ enabled: !!userMe.id,
});
const followUserMutation = useMutation({
- mutationKey: [isFollowing ? QUERY_KEYS.deleteFollow : QUERY_KEYS.follow, targetId],
- mutationFn: isFollowing ? () => deleteFollowUser(targetId) : () => createFollowUser(targetId),
+ mutationKey: [isFollowed ? QUERY_KEYS.deleteFollow : QUERY_KEYS.follow, userId],
+ mutationFn: isFollowed ? () => deleteFollowUser(userId) : () => createFollowUser(userId),
onMutate: async () => {
await queryClient.cancelQueries({ queryKey: [QUERY_KEYS.userOne, userId] });
const previousFollower: UserType | undefined = queryClient.getQueryData([QUERY_KEYS.userOne, userId]);
if (!previousFollower) return;
- const nextData = {
- ...previousFollower,
- isFollowed: !isFollowing,
- followerCount: isFollowing ? previousFollower.followerCount - 1 : previousFollower.followerCount + 1,
- };
-
- queryClient.setQueryData([QUERY_KEYS.userOne, userId], nextData);
-
return { previousFollower };
},
onError: (error: AxiosError, userId: number, context) => {
@@ -67,27 +59,31 @@ function FollowButton({ isFollowing, onClick, userId, targetId }: FollowButtonPr
queryClient.invalidateQueries({
queryKey: [QUERY_KEYS.userOne, userId],
});
+ queryClient.invalidateQueries({
+ queryKey: [QUERY_KEYS.getListDetail],
+ });
},
});
- const handleFollowUser = (isFollowing: boolean) => () => {
- if (!isFollowing) {
+ const handleFollowUser = (isFollowed: boolean) => () => {
+ if (!isFollowed) {
if (userMeData && userMeData?.followingCount >= MAX_FOLLOWING) {
toasting({ type: 'warning', txt: toastMessage[language].limitFollow });
return;
}
}
followUserMutation.mutate(userId);
- onClick();
+ if (onClick) onClick();
};
return (
<>
{isOn && (
diff --git a/src/lib/types/listType.ts b/src/lib/types/listType.ts
index eb120024..2696a088 100644
--- a/src/lib/types/listType.ts
+++ b/src/lib/types/listType.ts
@@ -112,6 +112,7 @@ export interface ListDetailType {
items: ItemType[];
isCollected: boolean;
isPublic: boolean;
+ isFollowing: boolean;
backgroundPalette: BACKGROUND_COLOR_PALETTE_TYPE;
backgroundColor: string;
collectCount: number;