-
Notifications
You must be signed in to change notification settings - Fork 0
관리자 페이지 FAQ 구현 (#issue 333) #334
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 all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
721bc34
chore: before merge, cherry pick commit
YouD0313 5f0740c
feat: FAQ 사이드바 추가, routes 설정, 기본페이지 세팅
YouD0313 e49010e
chore: merge develop
YouD0313 f2b3895
feat: FAQ 관리자 페이지에서 공통 사용
YouD0313 1d6380a
design: margin-bottom 5rem
YouD0313 dfad697
disign: 사이드바 스크롤 고정
YouD0313 5fd6482
design: adminTitle fixed, FAQ searchBar fixed
YouD0313 da63bd6
feat: faq 작성, 수정, 삭제 기능 구현
YouD0313 b52d182
refactor: 리뷰 반영
YouD0313 8bf32b1
refactor: useSearchbar 적용
YouD0313 a7a7d99
refactor: 공백 차지 constant에서 정의 후 사용
YouD0313 a5a7055
design: searchBar 너비 수정
YouD0313 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { ApiCommonBasicType } from '../../../models/apiCommon'; | ||
| import type { ApiFAQDetail, WriteBody } from '../../../models/customerService'; | ||
| import { httpClient } from '../../http.api'; | ||
|
|
||
| export const getFAQDetail = async (id: string) => { | ||
| try { | ||
| const response = await httpClient.get<ApiFAQDetail>(`/faq/${id}`); | ||
|
|
||
| return response.data.data; | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const postFAQ = async (formData: WriteBody) => { | ||
| try { | ||
| await httpClient.post<ApiCommonBasicType>(`faq`, formData); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const putFAQ = async ({ | ||
| id, | ||
| formData, | ||
| }: { | ||
| id: string; | ||
| formData: WriteBody; | ||
| }) => { | ||
| try { | ||
| await httpClient.put<ApiCommonBasicType>(`faq/${id}`, formData); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const deleteFAQ = async (id: string) => { | ||
| try { | ||
| await httpClient.delete<ApiCommonBasicType>(`faq/${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
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'; | ||
| import { SearchBarFixedWrapperStyled } from '../../common/admin/searchBar/SearchBar.styled'; | ||
| import { GAP_HEIGHT } from '../../../constants/admin/adminGap'; | ||
|
|
||
| export const SpinnerWrapper = styled(SpinnerWrapperStyled)``; | ||
|
|
||
| export const SearchBarFixedWrapper = styled(SearchBarFixedWrapperStyled)``; | ||
|
|
||
| export const FAQItemWrapper = styled.div` | ||
| margin-top: calc(${GAP_HEIGHT.headerTitleTop} + ${GAP_HEIGHT.sectionTop}); | ||
| `; |
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,33 @@ | ||
| import * as S from './AdminFAQList.styled'; | ||
| import SearchBar from '../../../components/common/admin/searchBar/SearchBar'; | ||
| import FAQItem from '../../user/customerService/faq/FAQItem'; | ||
| import { useGetFAQ } from '../../../hooks/user/useGetFAQ'; | ||
| import Spinner from '../../user/mypage/Spinner'; | ||
| import useSearchBar from '../../../hooks/admin/useSearchBar'; | ||
|
|
||
| export default function AdminFAQList() { | ||
| const { searchUnit, value, handleGetKeyword } = useSearchBar(); | ||
| const keyword = searchUnit.keyword; | ||
| const { faqData, isLoading } = useGetFAQ({ keyword }); | ||
|
|
||
| if (isLoading) { | ||
| return ( | ||
| <S.SpinnerWrapper> | ||
| <Spinner /> | ||
| </S.SpinnerWrapper> | ||
| ); | ||
| } | ||
|
|
||
| if (!faqData) return; | ||
|
|
||
| return ( | ||
| <> | ||
| <S.SearchBarFixedWrapper> | ||
| <SearchBar onGetKeyword={handleGetKeyword} value={value} /> | ||
| </S.SearchBarFixedWrapper> | ||
| <S.FAQItemWrapper> | ||
| <FAQItem faqData={faqData} $isAdmin={true} /> | ||
| </S.FAQItemWrapper> | ||
| </> | ||
| ); | ||
| } |
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,124 @@ | ||
| import { INQUIRY_MESSAGE } from '../../../constants/user/customerService'; | ||
| import * as S from './../../admin/adminNotice/AdminNoticeWrite.styled'; | ||
| import React, { useEffect, useState } from 'react'; | ||
| import { useLocation } from 'react-router-dom'; | ||
| import { useModal } from '../../../hooks/useModal'; | ||
| import Modal from '../../../components/common/modal/Modal'; | ||
| import type { WriteBody } from '../../../models/customerService'; | ||
| import Spinner from '../../../components/user/mypage/Spinner'; | ||
| import { useAdminFAQ } from '../../../hooks/admin/useAdminFAQ'; | ||
|
|
||
| export default function AdminFAQWrite() { | ||
| const location = useLocation(); | ||
| const { | ||
| isOpen: isModalOpen, | ||
| message, | ||
| handleModalOpen, | ||
| handleModalClose, | ||
| } = useModal(); | ||
| const pathname = location.state?.from || ''; | ||
| const id = location.state?.id || ''; | ||
|
|
||
| const formDefault = () => { | ||
| setForm({ | ||
| title: '', | ||
| content: '', | ||
| }); | ||
| }; | ||
|
|
||
| const { getFAQDetailData, postFAQMutate, putFAQMutate } = useAdminFAQ({ | ||
| handleModalOpen, | ||
| formDefault, | ||
| pathname, | ||
| id, | ||
| }); | ||
| const [form, setForm] = useState<WriteBody>({ | ||
| title: '', | ||
| content: '', | ||
| }); | ||
| const { data: FAQDetailData, isLoading } = getFAQDetailData; | ||
|
|
||
| useEffect(() => { | ||
| if (!FAQDetailData) return; | ||
| setForm({ title: FAQDetailData.title, content: FAQDetailData.content }); | ||
| }, [FAQDetailData]); | ||
|
|
||
| const handleSubmitInquiry = (e: React.FormEvent<HTMLFormElement>) => { | ||
| e.preventDefault(); | ||
|
|
||
| const isValid = { | ||
| title: form.title.trim() !== '', | ||
| content: form.content.trim() !== '', | ||
| }; | ||
|
|
||
| if (!isValid.title) { | ||
| return handleModalOpen(INQUIRY_MESSAGE.writeTitle); | ||
| } | ||
| if (!isValid.content) { | ||
| return handleModalOpen(INQUIRY_MESSAGE.writeContent); | ||
| } | ||
|
|
||
| const formData = new FormData(e.currentTarget as HTMLFormElement); | ||
|
|
||
| const formDataObj: WriteBody = { | ||
| title: formData.get('title') as string, | ||
| content: formData.get('content') as string, | ||
| }; | ||
|
|
||
| if (!id) { | ||
| return postFAQMutate.mutate(formDataObj); | ||
| } else { | ||
| return putFAQMutate.mutate({ id, formDataObj }); | ||
| } | ||
| }; | ||
|
|
||
| if (isLoading) { | ||
| return ( | ||
| <S.SpinnerWrapper> | ||
| <Spinner /> | ||
| </S.SpinnerWrapper> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <S.AdminNoticeContainer> | ||
| <S.AdminNoticeForm | ||
| onSubmit={handleSubmitInquiry} | ||
| method='post' | ||
| encType='multipart/form-data' | ||
| > | ||
| <S.AdminNoticeWrapper> | ||
| <S.AdminNoticeNav> | ||
| <S.AdminNoticeInputTitle | ||
| name='title' | ||
| type='text' | ||
| placeholder='제목을 입력하세요.' | ||
| value={form.title} | ||
| onChange={(e) => | ||
| setForm((prev) => ({ ...prev, title: e.target.value })) | ||
| } | ||
| /> | ||
| </S.AdminNoticeNav> | ||
| <S.AdminNoticeContentWrapper> | ||
| <S.AdminNoticeContent | ||
| as='textarea' | ||
| name='content' | ||
| value={form.content} | ||
| onChange={(e) => | ||
| setForm((prev) => ({ ...prev, content: e.target.value })) | ||
| } | ||
| ></S.AdminNoticeContent> | ||
| </S.AdminNoticeContentWrapper> | ||
| <S.AdminNoticeSendButtonWrapper> | ||
| <S.AdminNoticeSendButton type='submit'> | ||
| 제출 | ||
| </S.AdminNoticeSendButton> | ||
| </S.AdminNoticeSendButtonWrapper> | ||
| </S.AdminNoticeWrapper> | ||
| </S.AdminNoticeForm> | ||
| <Modal isOpen={isModalOpen} onClose={handleModalClose}> | ||
| {message} | ||
| </Modal> | ||
| </S.AdminNoticeContainer> | ||
| ); | ||
| } |
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 |
|---|---|---|
| @@ -1,11 +1,21 @@ | ||
| import { GAP_HEIGHT } from './../../../constants/admin/adminGap'; | ||
| import styled from 'styled-components'; | ||
| import { SpinnerWrapperStyled } from '../../user/mypage/Spinner.styled'; | ||
| import { SearchBarFixedWrapperStyled } from '../../common/admin/searchBar/SearchBar.styled'; | ||
|
|
||
| export const SpinnerWrapper = styled(SpinnerWrapperStyled)` | ||
| width: 100%; | ||
| `; | ||
|
|
||
| export const NoticeItemWrapper = styled.section` | ||
| export const SearchBarFixedWrapper = styled(SearchBarFixedWrapperStyled)``; | ||
|
|
||
| export const NoticeItemContainer = styled.section` | ||
| margin-top: calc( | ||
| ${GAP_HEIGHT.headerTitleTop} + ${GAP_HEIGHT.sectionTop} + 1rem | ||
| ); | ||
| `; | ||
|
|
||
| export const NoticeItemWrapper = styled.div` | ||
| display: flex; | ||
| justify-content: center; | ||
| `; |
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사이드바와 헤더 너비 불일치 문제가 있습니다.
사이드바 너비는 15rem인데 AdminTitle.styled.ts에서는 20rem을 가정하고 있습니다 (
calc(100vw - 20rem)). 이로 인해 레이아웃 불일치가 발생할 수 있습니다.다음 중 하나로 수정해주세요:
또는
🤖 Prompt for AI Agents