Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 친구목록 조회 수정 #29

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/organisms/FriendListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ const FriendListItem: React.FC<{
return (
<div className="flex p-[16px] mb-[12px] justify-between items-center bg-white rounded-[12px]">
<div className="flex items-center">
{/* TODO profile img ENUM res 데이터로 교체 */}
<Image
src={returnProfileImg('GREEN')}
src={returnProfileImg(data.profileImage)}
width={40}
height={40}
className="w-[40px] h-[40px] aspect-square"
Expand Down
29 changes: 17 additions & 12 deletions src/components/templates/FriendListTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const FriendListTemplate: React.FC<{ possibleDelete: boolean }> = ({
const [selectedFriendIds, setSelectedFriendIds] = useState<number[]>([]);
const {
data: friendsData,
fetchNextPage: friendsNextPage,
fetchNextPage: fetchFriendsNextPage,
isFetchingNextPage: isFetchingfriendsNextPage,
refetch: friendsRefetch,
} = useGetFriendships({
Expand All @@ -53,7 +53,7 @@ const FriendListTemplate: React.FC<{ possibleDelete: boolean }> = ({

const onIntersect: IntersectionObserverCallback = ([entry]) => {
if (entry.isIntersecting) {
void friendsNextPage();
void fetchFriendsNextPage();
}
};

Expand Down Expand Up @@ -116,18 +116,23 @@ const FriendListTemplate: React.FC<{ possibleDelete: boolean }> = ({
/>
)),
)}
{isFetchingfriendsNextPage ? (
<SuspenseFallback />
) : (
<div ref={bottom} />
)}
</div>

{isFetchingfriendsNextPage ? <SuspenseFallback /> : <div ref={bottom} />}

<div className="fixed w-screen max-w-[480px] bottom-0 px-[20px] py-[26px]">
<Button
text={'삭제하기'}
className={`w-full ${selectedFriendIds.length === 0 ? 'bg-gray3 text-gray1' : 'bg-primary2 text-white'}`}
onClick={deleteOnOpen}
disabled={selectedFriendIds.length === 0}
/>
</div>
{possibleDelete ? (
<div className="fixed w-screen max-w-[480px] bottom-0 px-[20px] py-[26px]">
<Button
text={'삭제하기'}
className={`w-full ${selectedFriendIds.length === 0 ? 'bg-gray3 text-gray1' : 'bg-primary2 text-white'}`}
onClick={deleteOnOpen}
disabled={selectedFriendIds.length === 0}
/>
</div>
) : null}

<Modal
onClose={deleteOnClose}
Expand Down
3 changes: 3 additions & 0 deletions src/types/friendship/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { ProfileEnum } from '../common';

export interface FriendshipData {
userId: number;
nickname: string;
ingredientCount: number;
profileImage: ProfileEnum;
}

export type FriendshipSortType = 'nickname' | 'createdAt';
Loading