Skip to content
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
4 changes: 2 additions & 2 deletions src/api/service/group-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const groupServiceRemote = () => ({
// 모임 이미지 사전 업로드 (POST /groups/images/upload) - multipart/form-data

createGroup: (payload: CreateGroupPayload) => {
return api.post<CreateGroupResponse>('/groups/create', payload);
return apiV2.post<CreateGroupResponse>('/groups/create', payload);
},

getGroupDetails: (payload: GroupIdPayload) => {
Expand All @@ -60,6 +60,6 @@ export const groupServiceRemote = () => ({
},

uploadGroupImages: (payload: FormData) => {
return api.post<PreUploadGroupImageResponse>('/groups/images/upload', payload);
return apiV2.post<PreUploadGroupImageResponse>('/groups/images/upload', payload);
},
});
16 changes: 4 additions & 12 deletions src/app/post-meetup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from '@/components/pages/post-meetup';
import { useCreateGroup } from '@/hooks/use-group/use-group-create';
import { CreateGroupFormValues, createGroupSchema } from '@/lib/schema/group';
import { PreUploadGroupImageResponse } from '@/types/service/group';

const PostMeetupPage = () => {
const { replace } = useRouter();
Expand All @@ -37,18 +36,11 @@ const PostMeetupPage = () => {
onSubmit: createGroupSchema,
},
onSubmit: async ({ value }) => {
const images = [] as PreUploadGroupImageResponse['images'];
value.images = value.images?.map((image, idx) => {
return { ...image, sortOrder: idx };
});

if (value.images) {
value.images.forEach((image, idx) => {
images.push({
...image,
sortOrder: idx,
});
});
}

const res = await createGroup({ ...value, images: images });
const res = await createGroup({ ...value });

replace(`/meetup/${res.id}`);
},
Expand Down
1 change: 1 addition & 0 deletions src/lib/schema/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const createGroupSchema = z.object({
images: z
.array(
z.object({
imageKey: z.string(),
sortOrder: z.number(),
imageUrl440x240: z.string(),
imageUrl100x100: z.string(),
Expand Down
47 changes: 36 additions & 11 deletions src/types/service/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ export interface PreUploadGroupImagePayload {

export interface PreUploadGroupImageResponse {
images: {
imageKey: string;
sortOrder: number;
imageUrl440x240: string;
imageUrl100x100: string;
}[];
}

export type CreateGroupImagePayload = PreUploadGroupImageResponse;

export interface CreateGroupPayload {
title: string;
location: string;
Expand All @@ -98,28 +97,54 @@ export interface CreateGroupPayload {
tags?: string[] | null;
description: string;
maxParticipants: number;
images?: CreateGroupImagePayload['images'] | null;
images?: {
imageKey: string;
sortOrder: number;
}[];
}

export interface CreateGroupResponse {
id: number;
title: string;
location: string;
locationDetail?: string | null;
status: 'RECRUITING' | 'FULL' | 'FINISHED';
address: {
location: string;
locationDetail: string;
};
startTime: string;
endTime?: string;
tags?: string[] | null;
endTime: string;
tags: string[];
description: string;
participantCount: number;
maxParticipants: number;
createdAt: string;
updatedAt: string;
createdBy: {
userId: number;
nickName: string;
profileImage?: string | null;
profileImage: string;
profileMessage: string;
};
createdAt: string;
updatedAt: string;
images?: CreateGroupImagePayload['images'] | null;
myMembership?: {
groupUserId: number;
role: 'HOST' | 'MEMBER';
status: 'ATTEND' | 'LEFT';
joinedAt: string;
leftAt: string;
} | null;
images: {
groupImageId: number;
imageKey: string;
sortOrder: number;
variants: {
variantId: number;
type: 'CARD_440_240' | 'THUMBNAIL_100_100';
width: number;
height: number;
format: 'WEBP';
imageUrl: string;
}[];
}[];
}

export interface GetGroupDetailsResponse {
Expand Down