-
Notifications
You must be signed in to change notification settings - Fork 0
관리자 문의 ( #issue 335 ) #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,61 @@ | ||
| import type { ApiCommonBasicType } from '../../../models/apiCommon'; | ||
| import type { | ||
| ApiAdminInquiry, | ||
| ApiAdminInquiryDetail, | ||
| InquiryAnswerBody, | ||
| } from '../../../models/inquiry'; | ||
| import { httpClient } from '../../http.api'; | ||
|
|
||
| export const getAllInquiries = async () => { | ||
| try { | ||
| const response = await httpClient.get<ApiAdminInquiry>(`/inquiry`); | ||
| return response.data.data; | ||
| } catch (e) { | ||
| console.error('전체 문의 조회 에러', e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const getInquiryDetail = async (id: string) => { | ||
| try { | ||
| const response = await httpClient.get<ApiAdminInquiryDetail>( | ||
| `/inquiry/${id}` | ||
| ); | ||
|
|
||
| return response.data.data; | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const postInquiryAnswer = async ({ id, answer }: InquiryAnswerBody) => { | ||
| try { | ||
| await httpClient.post<ApiCommonBasicType>(`/inquiry/${id}/answer`, { | ||
| answer, | ||
| }); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const patchInquiryAnswer = async ({ id, answer }: InquiryAnswerBody) => { | ||
| try { | ||
| await httpClient.patch<ApiCommonBasicType>(`/inquiry/${id}/answer`, { | ||
| answer, | ||
| }); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const deleteInquiry = async (id: string) => { | ||
| try { | ||
| await httpClient.delete<ApiCommonBasicType>(`/inquiry/${id}`); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; |
This file contains hidden or 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,41 @@ | ||
| import { Link } from 'react-router-dom'; | ||
| import styled, { css } from 'styled-components'; | ||
|
|
||
| export const AdminInquiryContainer = styled(Link)``; | ||
|
|
||
| export const AdminInquiryWrapper = styled.div` | ||
| padding: 0.8rem; | ||
| display: grid; | ||
| grid-template-columns: 13% 51% 15% 11% 10%; | ||
| justify-content: center; | ||
| align-items: center; | ||
| font-size: 1.1rem; | ||
| `; | ||
|
|
||
| export const AdminInquiryTitle = styled.div``; | ||
|
|
||
| export const AdminInquiryCategory = styled.span` | ||
| font-size: 1.1rem; | ||
| font-weight: 500; | ||
| `; | ||
|
|
||
| export const AdminInquiryUser = styled.div``; | ||
|
|
||
| export const AdminInquiryDate = styled.span` | ||
| font-size: 0.9rem; | ||
| color: ${({ theme }) => theme.color.deepGrey}; | ||
| `; | ||
|
|
||
| export const AdminInquiryState = styled.div<{ $hasAnswer: boolean }>` | ||
| text-align: center; | ||
| color: ${({ $hasAnswer, theme }) => | ||
| $hasAnswer ? theme.color.white : theme.color.green}; | ||
| padding: 0.3rem; | ||
|
|
||
| ${({ $hasAnswer }) => | ||
| $hasAnswer && | ||
| css` | ||
| border-radius: ${({ theme }) => theme.borderRadius.large}; | ||
| background: ${({ theme }) => theme.color.navy}; | ||
| `} | ||
| `; |
This file contains hidden or 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,25 @@ | ||
| import { ADMIN_ROUTE } from '../../../constants/routes'; | ||
| import type { AdminInquiry as TAdminInquiry } from '../../../models/inquiry'; | ||
| import ContentBorder from '../../common/contentBorder/ContentBorder'; | ||
| import * as S from './AdminInquiry.styled'; | ||
|
|
||
| interface AdminInquiryProps { | ||
| list: TAdminInquiry; | ||
| } | ||
|
|
||
| export default function AdminInquiry({ list }: AdminInquiryProps) { | ||
| return ( | ||
| <S.AdminInquiryContainer to={`${ADMIN_ROUTE.detail}/${list.id}`}> | ||
| <S.AdminInquiryWrapper> | ||
| <S.AdminInquiryCategory>[{list.category}]</S.AdminInquiryCategory> | ||
| <S.AdminInquiryTitle>{list.title}</S.AdminInquiryTitle> | ||
| <S.AdminInquiryUser>{list.user.nickname}</S.AdminInquiryUser> | ||
| <S.AdminInquiryDate>{list.createdAt}</S.AdminInquiryDate> | ||
| <S.AdminInquiryState $hasAnswer={list.state}> | ||
| {list.state ? '답변완료' : '확인중'} | ||
| </S.AdminInquiryState> | ||
| </S.AdminInquiryWrapper> | ||
| <ContentBorder /> | ||
| </S.AdminInquiryContainer> | ||
| ); | ||
| } | ||
34 changes: 34 additions & 0 deletions
34
src/components/admin/adminInquiry/AdminInquiryAnswer.styled.ts
This file contains hidden or 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,34 @@ | ||
| import styled from 'styled-components'; | ||
| import { | ||
| AdminInquiryContentContainer, | ||
| AdminInquiryContentWrapper, | ||
| InquiryContent, | ||
| InquiryHeaderWrapper, | ||
| InquiryInfo, | ||
| } from './AdminInquiryDetailContent.styled'; | ||
| import { SendButton } from '../../user/customerService/inquiry/Inquiry.styled'; | ||
|
|
||
| export const InquiryAnswerContentContainer = styled( | ||
| AdminInquiryContentContainer | ||
| )``; | ||
|
|
||
| export const InquiryAnswerContentWrapper = styled(AdminInquiryContentWrapper)``; | ||
|
|
||
| export const AnswerHeaderWrapper = styled(InquiryHeaderWrapper)` | ||
| display: flex; | ||
| gap: 3rem; | ||
| `; | ||
|
|
||
| export const InquiryAnswerInfo = styled(InquiryInfo)` | ||
| display: flex; | ||
| align-items: center; | ||
| `; | ||
|
|
||
| export const InquiryAnswerButton = styled(SendButton)` | ||
| font-size: 0.9rem; | ||
| padding: 0.3rem 0.5rem; | ||
| `; | ||
|
|
||
| export const AnswerButtonSpan = styled.span``; | ||
|
|
||
| export const InquiryAnswerContent = styled(InquiryContent)``; |
This file contains hidden or 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,46 @@ | ||
| import { useEffect, useState } from 'react'; | ||
| import * as S from './AdminInquiryAnswer.styled'; | ||
| import { Link, useOutletContext } from 'react-router-dom'; | ||
| import { ADMIN_ROUTE } from '../../../constants/routes'; | ||
|
|
||
| interface AdminInquiryDetailContentOutletContext { | ||
| createdAt: string; | ||
| answerData: string; | ||
| } | ||
|
|
||
| type LinkType = '작성하기' | '수정하기'; | ||
|
|
||
| export default function AdminInquiryAnswer() { | ||
| const { createdAt, answerData }: AdminInquiryDetailContentOutletContext = | ||
| useOutletContext(); | ||
|
|
||
| const [answer, setAnswer] = useState<string>(''); | ||
| const selectButton: LinkType = answer === null ? '작성하기' : '수정하기'; | ||
|
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 버튼 선택 로직의 타입 불일치를 수정하세요.
- const [answer, setAnswer] = useState<string>('');
- const selectButton: LinkType = answer === null ? '작성하기' : '수정하기';
+ const [answer, setAnswer] = useState<string | null>(null);
+ const selectButton: LinkType = !answer || answer.trim() === '' ? '작성하기' : '수정하기';🤖 Prompt for AI Agents |
||
|
|
||
| useEffect(() => { | ||
| setAnswer(answerData); | ||
| }, [answerData]); | ||
|
|
||
| return ( | ||
| <S.InquiryAnswerContentContainer> | ||
| <S.InquiryAnswerContentWrapper> | ||
| <S.AnswerHeaderWrapper> | ||
| <S.InquiryAnswerInfo> | ||
| {createdAt ? createdAt : ''} | ||
| </S.InquiryAnswerInfo> | ||
| <S.InquiryAnswerButton | ||
| as={Link} | ||
| to={ | ||
| selectButton === '작성하기' | ||
| ? ADMIN_ROUTE.write | ||
| : ADMIN_ROUTE.modification | ||
| } | ||
| > | ||
| <S.AnswerButtonSpan>{selectButton}</S.AnswerButtonSpan> | ||
| </S.InquiryAnswerButton> | ||
| </S.AnswerHeaderWrapper> | ||
| <S.InquiryAnswerContent>{answer}</S.InquiryAnswerContent> | ||
| </S.InquiryAnswerContentWrapper> | ||
| </S.InquiryAnswerContentContainer> | ||
| ); | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
src/components/admin/adminInquiry/AdminInquiryAnswerWrite.styled.ts
This file contains hidden or 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,43 @@ | ||
| import styled from 'styled-components'; | ||
| import { | ||
| AdminInquiryContentContainer, | ||
| AdminInquiryContentWrapper, | ||
| InquiryContent, | ||
| } from './AdminInquiryDetailContent.styled'; | ||
| import { | ||
| AnswerHeaderWrapper, | ||
| InquiryAnswerButton, | ||
| InquiryAnswerInfo, | ||
| } from './AdminInquiryAnswer.styled'; | ||
|
|
||
| export const InquiryAnswerContentContainer = styled( | ||
| AdminInquiryContentContainer | ||
| )``; | ||
|
|
||
| export const InquiryAnswerWriteWrapper = styled(AdminInquiryContentWrapper)``; | ||
|
|
||
| export const InquiryAnswerWriteHeaderWrapper = styled(AnswerHeaderWrapper)` | ||
| display: flex; | ||
| gap: 3rem; | ||
| `; | ||
|
|
||
| export const InquiryAnswerWriteInfo = styled(InquiryAnswerInfo)` | ||
| display: flex; | ||
| align-items: center; | ||
| `; | ||
|
|
||
| export const InquiryAnswerWriteButton = styled(InquiryAnswerButton)` | ||
| align-items: start; | ||
| height: fit-content; | ||
| font-size: 0.9rem; | ||
| padding: 0.3rem 0.5rem; | ||
| `; | ||
|
|
||
| export const InquiryAnswerWriteButtonSpan = styled.span``; | ||
|
|
||
| export const InquiryAnswerWrite = styled(InquiryContent)` | ||
| resize: none; | ||
| border: 1px solid ${({ theme }) => theme.color.placeholder}; | ||
| border-radius: ${({ theme }) => theme.borderRadius.primary}; | ||
| padding: 1rem; | ||
| `; |
100 changes: 100 additions & 0 deletions
100
src/components/admin/adminInquiry/AdminInquiryAnswerWrite.tsx
This file contains hidden or 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,100 @@ | ||
| import { useOutletContext } from 'react-router-dom'; | ||
| import * as S from './AdminInquiryAnswerWrite.styled'; | ||
| import React, { useEffect, useRef, useState } from 'react'; | ||
| import { InquiryAnswerBody } from '../../../models/inquiry'; | ||
| import { UseMutationResult } from '@tanstack/react-query'; | ||
| import { AxiosError } from 'axios'; | ||
| import Modal from '../../common/modal/Modal'; | ||
| import { useModal } from '../../../hooks/useModal'; | ||
| import { INQUIRY_MESSAGE } from '../../../constants/user/customerService'; | ||
| import Spinner from '../../user/mypage/Spinner'; | ||
|
|
||
| interface AdminInquiryAnswerWriteProps { | ||
| answerData: string; | ||
| isWrite: boolean; | ||
| id: string; | ||
| postInquiryAnswerMutate: UseMutationResult< | ||
| void, | ||
| AxiosError, | ||
| InquiryAnswerBody | ||
| >; | ||
| patchInquiryAnswerMutate: UseMutationResult< | ||
| void, | ||
| AxiosError, | ||
| InquiryAnswerBody | ||
| >; | ||
| } | ||
|
|
||
| export default function AdminInquiryAnswerWrite() { | ||
| const { | ||
| answerData, | ||
| isWrite, | ||
| id, | ||
| postInquiryAnswerMutate, | ||
| patchInquiryAnswerMutate, | ||
| } = useOutletContext<AdminInquiryAnswerWriteProps>(); | ||
| const [answer, setAnswer] = useState<string>(''); | ||
| const inputRef = useRef<HTMLTextAreaElement>(null); | ||
| const { isOpen, message, handleModalOpen, handleModalClose } = useModal(); | ||
| const isLoading = | ||
| postInquiryAnswerMutate.isPending || patchInquiryAnswerMutate.isPending; | ||
|
|
||
| useEffect(() => { | ||
| if (answerData) { | ||
| setAnswer(answerData); | ||
| } | ||
| }, [answerData]); | ||
|
|
||
| if (isLoading) { | ||
| <Spinner />; | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const handleSubmitAnswer = (e: React.FormEvent<HTMLFormElement>) => { | ||
| e.preventDefault(); | ||
|
|
||
| if (answer.trim() === '') { | ||
| return handleModalOpen(INQUIRY_MESSAGE.writeContent); | ||
| } | ||
|
|
||
| if (isWrite) { | ||
| postInquiryAnswerMutate.mutate({ id, answer: answer }); | ||
| } else { | ||
| patchInquiryAnswerMutate.mutate({ id, answer: answer }); | ||
| } | ||
| }; | ||
|
|
||
| const handleChangeAnswer = (e: React.ChangeEvent<HTMLTextAreaElement>) => { | ||
| if (inputRef && inputRef.current) { | ||
| inputRef.current.style.height = 'auto'; | ||
| inputRef.current.style.height = `${inputRef.current.scrollHeight}px`; | ||
| } | ||
|
|
||
| const answerValue = e.target.value; | ||
|
|
||
| setAnswer(answerValue); | ||
| }; | ||
|
|
||
| return ( | ||
| <S.InquiryAnswerContentContainer> | ||
| <S.InquiryAnswerWriteWrapper as='form' onSubmit={handleSubmitAnswer}> | ||
| <S.InquiryAnswerWriteHeaderWrapper> | ||
| <S.InquiryAnswerWriteButton type='submit'> | ||
| <S.InquiryAnswerWriteButtonSpan> | ||
| 답변하기 | ||
| </S.InquiryAnswerWriteButtonSpan> | ||
| </S.InquiryAnswerWriteButton> | ||
| <S.InquiryAnswerWriteInfo></S.InquiryAnswerWriteInfo> | ||
| </S.InquiryAnswerWriteHeaderWrapper> | ||
| <S.InquiryAnswerWrite | ||
| as='textarea' | ||
| value={answer} | ||
| ref={inputRef} | ||
| onChange={handleChangeAnswer} | ||
| ></S.InquiryAnswerWrite> | ||
| </S.InquiryAnswerWriteWrapper> | ||
| <Modal isOpen={isOpen} onClose={handleModalClose}> | ||
| {message} | ||
| </Modal> | ||
| </S.InquiryAnswerContentContainer> | ||
| ); | ||
| } | ||
12 changes: 12 additions & 0 deletions
12
src/components/admin/adminInquiry/AdminInquiryDetail.styled.ts
This file contains hidden or 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,12 @@ | ||
| import styled from 'styled-components'; | ||
| import { SpinnerWrapperStyled } from '../../user/mypage/Spinner.styled'; | ||
|
|
||
| export const SpinnerWrapper = styled(SpinnerWrapperStyled)``; | ||
|
|
||
| export const AdminInquiryDetailContainer = styled.main` | ||
| width: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| gap: 1.5rem; | ||
| `; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.