Skip to content

Commit

Permalink
Merge pull request #103 from Onion-City/dev
Browse files Browse the repository at this point in the history
Feat: 모임 생성 디폴트 값 추가 & 성공 시 리다이렉트
  • Loading branch information
hhbb0081 authored Jul 4, 2024
2 parents 90a8cf9 + 76b8459 commit 99b64e2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/features/user/club/SetupUserClub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function SetupUserClub() {
mode: "onChange",
defaultValues: {
clubIntro: "",
// clubLinks: "", 링크 추가 시 주석 해제
link: "",
clubName: "",
contactMeans: "",
isPrivate: false,
Expand Down
6 changes: 3 additions & 3 deletions src/features/user/club/constants/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export const REGISTER_INPUT_ARR2 = [
},
{
title: "모임 관련 링크",
type: "textarea",
name: "clubLinks",
type: "input",
name: "link",
essential: false,
subtitle: "notion, 디스코드, 오픈 채팅방 등",
maxCnt: 300
// maxCnt: 300
},
]

Expand Down
5 changes: 5 additions & 0 deletions src/hook/club/useClubsMutation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { http } from "@/apis/http";
import { ClubFormData } from "@/types/club";
import { useMutation } from "@tanstack/react-query";
import { useRouter } from "next/navigation";

// 모임 생성 (/clubs)
async function createClub(data: ClubFormData): Promise<void> {
Expand All @@ -15,6 +16,7 @@ async function createClub(data: ClubFormData): Promise<void> {
isPrivate: data.isPrivate,
contactMeans: data.contactMeans,
namePolicy: data.namePolicy,
link: data.link,
}),
],
{ type: "application/json" }
Expand Down Expand Up @@ -43,10 +45,13 @@ interface UseCreateClubs {
}

export function useClubsMutation(): UseCreateClubs {
const router = useRouter();
const { mutate } = useMutation<void, Error, ClubFormData>({
mutationFn: createClub,
onSuccess: () => {
console.log("모임 등록 성공");
router.push('/');

},
onError: (error) => {
console.log("모임 등록 실패", error);
Expand Down
2 changes: 1 addition & 1 deletion src/types/club/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface ClubFormData {
isPrivate: boolean;
namePolicy: "REAL_NAME" | "NICK_NAME";
contactMeans: string;
link: string[];
link: string;
profileImage?: imageState;
}

Expand Down

0 comments on commit 99b64e2

Please sign in to comment.