Skip to content

Commit

Permalink
Merge pull request #248 from kakao-tech-campus-2nd-step3/Week11
Browse files Browse the repository at this point in the history
Week11 4
  • Loading branch information
ppochaco authored Nov 14, 2024
2 parents e43870f + bdde6ce commit 74709ea
Show file tree
Hide file tree
Showing 17 changed files with 274 additions and 333 deletions.
6 changes: 3 additions & 3 deletions src/api/services/profile/profile-question.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ type ProfileQuestionResponse = {
content: QuestionItem[]
}

const getProfileQuestion = async (userId: string) => {
const getProfileQuestion = async (userId: number) => {
const response = await fetchInstance.get<ProfileQuestionResponse>(
`/api/profile/question/${userId}`
)

return response?.data.content
return response.data.content
}

export const useGetProfileQuestion = (userId: string) => {
export const useGetProfileQuestion = (userId: number) => {
return useQuery({
queryKey: ['profileQuestion', userId],
queryFn: () => getProfileQuestion(userId),
Expand Down
14 changes: 12 additions & 2 deletions src/components/ChatBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ import { BiX } from 'react-icons/bi'

import { Box, Button, Flex } from '@chakra-ui/react'

import { ChatBoxProps } from '@/types'
interface ChatBoxProps {
direction: 'left' | 'right'
content: string
createdAt: string
deleteBtn?: boolean
onDelete?: () => void
}

export const ChatBox = ({
chatItem: { direction, content, createdAt, deleteBtn = false, onDelete },
direction,
content,
createdAt,
deleteBtn = false,
onDelete,
}: ChatBoxProps) => {
const isRight = direction === 'right'

Expand Down
64 changes: 0 additions & 64 deletions src/pages/Admin/GetQuestionAdminPage/index.tsx

This file was deleted.

59 changes: 0 additions & 59 deletions src/pages/Admin/index.tsx

This file was deleted.

16 changes: 6 additions & 10 deletions src/pages/GroupPage/Management/CreateQuestion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react'
import { useState } from 'react'
import { useForm } from 'react-hook-form'
import { BiError, BiPlus } from 'react-icons/bi'

Expand Down Expand Up @@ -29,6 +29,7 @@ export const GroupQuestionCreateModal = ({
groupId,
}: GroupQuestionCreateModalProps) => {
const errorAlert = useDisclosure()

const [errorMessage, setErrorMessage] = useState('')

const form = useForm<CreateQuestionFields>({
Expand Down Expand Up @@ -57,18 +58,14 @@ export const GroupQuestionCreateModal = ({
},
})

useEffect(() => {
form.reset({
groupId,
content: '',
})
}, [groupId, form])

return (
<Box>
<FormModal
isOpen={isOpen}
onClose={onClose}
onClose={() => {
onClose()
form.reset({ groupId, content: '' })
}}
icon={<BiPlus />}
title="그룹 질문 추가 요청"
description="그룹에 새로운 질문을 요청해보세요"
Expand All @@ -86,7 +83,6 @@ export const GroupQuestionCreateModal = ({
<CreateQuestionForm form={form} />
</Flex>
</FormModal>

<AlertModal
isOpen={errorAlert.isOpen}
onClose={errorAlert.onClose}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export const CreateQuestionButton = ({ userId }: CreateQuestionButtonProps) => {
onSuccess: () => {
formModal.onClose()
setNewQuestionContent('')
queryClient.invalidateQueries({ queryKey: ['postNewQuestion'] })
queryClient.invalidateQueries({
queryKey: ['profileQuestion', userId.toString()],
queryKey: ['profileQuestion', userId],
})
},
onError: () => {
Expand All @@ -52,6 +51,7 @@ export const CreateQuestionButton = ({ userId }: CreateQuestionButtonProps) => {
if (!newQuestionContent.trim()) {
setErrorMessage('질문을 입력해주세요')
formModal.onClose()
setNewQuestionContent('')
errorAlert.onOpen()
return
}
Expand Down Expand Up @@ -82,7 +82,10 @@ export const CreateQuestionButton = ({ userId }: CreateQuestionButtonProps) => {
</Button>
<FormModal
isOpen={formModal.isOpen}
onClose={formModal.onClose}
onClose={() => {
formModal.onClose()
setNewQuestionContent('')
}}
icon={<BiPlus />}
title="프로필 질문 추가하기"
description="친구들에게 궁금한 질문을 추가해보세요"
Expand Down
Loading

0 comments on commit 74709ea

Please sign in to comment.