-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat / style : 게시판 생성 모달 api 연결, sidebar 스타일 수정
feat / style : 게시판 생성 모달 api 연결, sidebar 스타일 수정
- Loading branch information
1 parent
973148c
commit 6e46526
Showing
6 changed files
with
110 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { CreateBoardRequest, CreateBoardResponse } from '../../models/Modal'; | ||
import { http } from '../../apis/httpClient'; | ||
|
||
export const createBoardApi = async ({ | ||
title, | ||
}: CreateBoardRequest): Promise<CreateBoardResponse> => { | ||
const token = localStorage.getItem('accessToken'); // 토큰 가져오기 | ||
if (!token) { | ||
throw new Error('토큰이 없습니다. 로그인 상태를 확인해주세요.'); | ||
} | ||
|
||
const response = await http.post<CreateBoardResponse>( | ||
'/api/boards', | ||
{ title }, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, // 헤더에 토큰 추가 | ||
'Content-Type': 'application/json', | ||
}, | ||
} | ||
); | ||
|
||
return response; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { createBoardApi } from '../../apis/Board/createBoardApi'; | ||
import { CreateBoardRequest, CreateBoardResponse } from '../../models/Modal'; | ||
|
||
export const useCreateBoard = () => { | ||
return useMutation<CreateBoardResponse, Error, CreateBoardRequest>({ | ||
mutationFn: createBoardApi, | ||
onSuccess: (data) => { | ||
console.log('교실 생성 성공:', data); | ||
}, | ||
onError: (error) => { | ||
console.error('교실 생성 실패:', error); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters