Skip to content

Commit

Permalink
Refactor: modal 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
quokka-eating-carrots committed Oct 22, 2023
1 parent 4fe6cf8 commit 5fbf91e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/api/postApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const requestEdit = async (formData: FormData, postId: number) => {

// 관리자 문의글 답변 등록
export const postAdmintQuestion = async (questionId: number, data: QuestionTypes) => {
console.log(data)
const response = await privateApi.post(`/admin/answer/register?questionId=${questionId}`, data)
return {
status: response.status,
Expand Down
9 changes: 8 additions & 1 deletion src/pages/AskDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import { useSelector } from 'react-redux'
import { RootState } from '@src/store/config'
import Inner from '@src/components/Style/Inner'
import PATH from '@src/constants/pathConst'
import useModal from '@src/hooks/useModal'

const AskDetail = () => {
const [question, setQuestion] = useState<QuestionGetTypes>()
const [answer, setAnswer] = useState<QuestionAnswerTypes>()
const { pathname } = useLocation()
const questionId = Number(pathname.slice(5))
const { openModal } = useModal()

const isPC = useMediaQuery({
query: '(min-width: 450px)',
Expand All @@ -28,7 +30,12 @@ const AskDetail = () => {
const answerResponse = await getQuestionAnswer(questionId)
setAnswer(answerResponse)
} catch (error) {
console.log(error)
openModal({
isModalOpen: true,
isConfirm: false,
content: ['정보를 불러올 수 없습니다.', '메인으로 돌아갑니다.'],
navigateOption: PATH.HOME,
})
}
}
fetchData()
Expand Down
8 changes: 7 additions & 1 deletion src/pages/BoardDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ const BoardDetails = () => {
const authenticated = useSelector((state: RootState) => state.accessToken.authenticated)
const userInfo = useSelector((state: RootState) => state.userInfo)
const { openModal } = useModal()

const blindFn = async () => {
try {
await blindBoard(Number(boardId))
} catch (error) {
console.log(error)
openModal({
isModalOpen: true,
isConfirm: false,
content: ['오류가 발생하였습니다.', '메인으로 돌아갑니다.'],
navigateOption: PATH.HOME,
})
}
}

Expand Down
17 changes: 15 additions & 2 deletions src/pages/MyPageDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import styled from 'styled-components'
import MBoardList from '@src/components/MyPage/MBoardList'
import ReactPaginate from 'react-paginate'
import { COLORS } from '@src/globalStyles'
import useModal from '@src/hooks/useModal'
import PATH from '@src/constants/pathConst'

const MyPageDetail = () => {
const { state }: { state: number } = useLocation()
Expand All @@ -21,6 +23,7 @@ const MyPageDetail = () => {
const [wishTotalPage, setWishTotalPage] = useState<number>(1)
const [wishlists, setWishlists] = useState<IWishlistType[]>([])
const menuLists = ['양도', '좋아요', '댓글']
const { openModal } = useModal()

const activeList = (activeMenu: number, screen: string) => {
if (activeMenu === 0 && screen === 'mobile') {
Expand Down Expand Up @@ -128,7 +131,12 @@ const MyPageDetail = () => {
setPosts(postsResponse?.data)
setPostTotalPage(postsResponse?.totalPages)
} catch (error) {
console.log(error)
openModal({
isModalOpen: true,
isConfirm: false,
content: ['정보를 불러올 수 없습니다.', '메인으로 돌아갑니다.'],
navigateOption: PATH.HOME,
})
}
}
const wishlistData = async (page = 1) => {
Expand All @@ -137,7 +145,12 @@ const MyPageDetail = () => {
setWishlists(wishlistResponse?.data)
setWishTotalPage(wishlistResponse?.totalPages)
} catch (error) {
console.log(error)
openModal({
isModalOpen: true,
isConfirm: false,
content: ['정보를 불러올 수 없습니다.', '메인으로 돌아갑니다.'],
navigateOption: PATH.HOME,
})
}
}

Expand Down

0 comments on commit 5fbf91e

Please sign in to comment.