Skip to content
Merged
9 changes: 5 additions & 4 deletions src/components/pages/pending/pending-members/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';

import { API } from '@/api';
import { EmptyState } from '@/components/layout/empty-state';
import { groupKeys } from '@/lib/query-key/query-key-group';
import { GetJoinRequestsResponse } from '@/types/service/group';

import { PendingMemberCard } from './pending-member-card';
Expand All @@ -21,7 +22,7 @@ export const GroupPendingMembers = ({ groupId }: Props) => {
const queryClient = useQueryClient();

const { data, isLoading, error } = useQuery<GetJoinRequestsResponse>({
queryKey: ['joinRequests', groupId, 'PENDING'],
queryKey: groupKeys.joinRequests(groupId, 'PENDING'),
queryFn: () => API.groupService.getJoinRequests({ groupId }, 'PENDING'),
});

Expand All @@ -41,11 +42,11 @@ export const GroupPendingMembers = ({ groupId }: Props) => {
// 가입 신청 목록 캐시 무효화 및 자동 refetch
// GroupPendingSummary의 count도 자동으로 업데이트됨
await queryClient.invalidateQueries({
queryKey: ['joinRequests', groupId, 'PENDING'],
queryKey: groupKeys.joinRequests(groupId, 'PENDING'),
refetchType: 'active', // 활성화된 모든 쿼리 자동 refetch
});
// 모임 상세 정보도 갱신
await queryClient.invalidateQueries({ queryKey: ['groupDetails', groupId] });
await queryClient.invalidateQueries({ queryKey: groupKeys.detail(groupId) });
},
});

Expand All @@ -56,7 +57,7 @@ export const GroupPendingMembers = ({ groupId }: Props) => {
// 가입 신청 목록 캐시 무효화 및 모든 활성 쿼리 refetch
// GroupPendingSummary의 count도 자동으로 업데이트됨
await queryClient.invalidateQueries({
queryKey: ['joinRequests', groupId, 'PENDING'],
queryKey: groupKeys.joinRequests(groupId, 'PENDING'),
refetchType: 'active', // 활성화된 모든 쿼리 자동 refetch
});
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/pages/pending/pending-summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DEFAULT_GROUP_IMAGE } from 'constants/default-images';

import { API } from '@/api';
import { ImageWithFallback } from '@/components/ui';
import { groupKeys } from '@/lib/query-key/query-key-group';
import { GetJoinRequestsResponse } from '@/types/service/group';

interface Props {
Expand All @@ -16,7 +17,7 @@ interface Props {

export const GroupPendingSummary = ({ groupId, initialData }: Props) => {
const { data } = useQuery<GetJoinRequestsResponse>({
queryKey: ['joinRequests', groupId, 'PENDING'],
queryKey: groupKeys.joinRequests(groupId, 'PENDING'),
queryFn: () => API.groupService.getJoinRequests({ groupId }, 'PENDING'),
initialData,
});
Expand Down
56 changes: 52 additions & 4 deletions src/lib/metadata/home.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
import { Metadata } from 'next';
import { headers } from 'next/headers';

import { API } from '@/api';
import { GROUP_LIST_PAGE_SIZE } from '@/lib/constants/group-list';

export const generateHomeMetadata = async (keyword?: string): Promise<Metadata> => {
const headersList = headers();
const host = (await headersList).get('host') || process.env.DOMAIN;
const headersList = await headers();
const host = headersList.get('host') || process.env.DOMAIN || 'wego.monster';
const protocol =
headersList.get('x-forwarded-proto') || (host.includes('localhost') ? 'http' : 'https');
const currentUrl = keyword
? `https://${host}/?keyword=${encodeURIComponent(keyword)}`
: `https://${host}/`;
? `${protocol}://${host}/?keyword=${encodeURIComponent(keyword)}`
: `${protocol}://${host}/`;
const logoImageUrl = `${protocol}://${host}/icons/resizable/icon-wego-logo.svg`;

try {
if (keyword) {
const metaTitle = `${keyword} 검색결과 | WeGo`;
const metaDescription = `"${keyword}"에 대한 모임 검색 결과를 확인해보세요.`;

let searchImageUrl = logoImageUrl;
try {
const searchResponse = await API.groupService.getGroups({
size: GROUP_LIST_PAGE_SIZE,
keyword,
});
const firstGroupImage = searchResponse.items[0]?.images?.[0];
if (firstGroupImage) {
searchImageUrl = firstGroupImage;
}
} catch (error) {
// 실패 시 기본 로고 이미지 사용
console.error('이미지를 가져오는데 실패했습니다:', error);
}

return {
title: metaTitle,
description: metaDescription,
Expand All @@ -24,11 +45,20 @@ export const generateHomeMetadata = async (keyword?: string): Promise<Metadata>
locale: 'ko_KR',
type: 'website',
url: currentUrl,
images: [
{
url: searchImageUrl,
width: 400,
height: 400,
alt: `${keyword} 검색 결과 모임 이미지`,
},
],
},
twitter: {
card: 'summary',
title: metaTitle,
description: metaDescription,
images: [searchImageUrl],
},
robots: {
index: true,
Expand All @@ -54,11 +84,20 @@ export const generateHomeMetadata = async (keyword?: string): Promise<Metadata>
locale: 'ko_KR',
type: 'website',
url: currentUrl,
images: [
{
url: logoImageUrl,
width: 400,
height: 400,
alt: 'WeGo 로고',
},
],
},
twitter: {
card: 'summary',
title: metaTitle,
description: metaDescription,
images: [logoImageUrl],
},
robots: {
index: true,
Expand All @@ -78,9 +117,18 @@ export const generateHomeMetadata = async (keyword?: string): Promise<Metadata>
description: 'WeGo에서 함께할 다양한 모임을 탐색하고 참여하세요.',
url: currentUrl,
type: 'website',
images: [
{
url: logoImageUrl,
width: 400,
height: 400,
alt: 'WeGo 로고',
},
],
},
twitter: {
card: 'summary',
images: [logoImageUrl],
},
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/query-key/query-key-group/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ export const groupKeys = {
myList: (filters: { type: 'current' | 'myPost' | 'past'; cursor?: number; size: number }) =>
[...groupKeys.myLists(), filters] as const,
detail: (groupId: string) => [...groupKeys.all, groupId] as const,
joinRequests: (groupId: string, status: string = 'PENDING') =>
['joinRequests', groupId, status] as const,
};