-
Notifications
You must be signed in to change notification settings - Fork 0
관리자 페이지 공지사항 (#issue 323) #329
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 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
70d5e7c
feat: 관리자페이지 공지사항 유저페이지와 공통으로 사용하기 위해 분리
YouD0313 7808d6a
chore: confict resolve
YouD0313 847b43c
feat: 작성하기 추가 중 searchbar 코드 공유
YouD0313 a66faca
feat: 관리자 공지사항 작성 구현
YouD0313 29c405d
feat: 수정, 삭제 구현
YouD0313 ec8fefb
chore: resolve conflict
YouD0313 fbd88f4
feat: 작성, 수정, 삭제 구현
YouD0313 a808d89
refactor: 리뷰반영
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,37 @@ | ||
| import type { ApiCommonBasicType } from '../../../models/apiCommon'; | ||
| import { httpClient } from '../../http.api'; | ||
|
|
||
| export const postNotice = async (formData: FormData) => { | ||
| try { | ||
| await httpClient.post<ApiCommonBasicType>(`/notice`, formData, { | ||
| headers: { | ||
| 'Content-Type': 'multipart/form-data', | ||
| }, | ||
| }); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const putNotice = async (id: number, formData: FormData) => { | ||
| try { | ||
| await httpClient.put<ApiCommonBasicType>(`/notice/${id}`, formData, { | ||
| headers: { | ||
| 'Content-Type': 'multipart/form-data', | ||
| }, | ||
| }); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const deleteNotice = async (id: number) => { | ||
| try { | ||
| await httpClient.delete<ApiCommonBasicType>(`/notice/${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,61 @@ | ||
| import { Link } from 'react-router-dom'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| export const AdminSearchBarContainer = styled.form` | ||
| width: 100%; | ||
| display: flex; | ||
| justify-content: space-evenly; | ||
| margin-bottom: 2rem; | ||
| `; | ||
|
|
||
| export const AdminSearchBarWrapper = styled.div` | ||
| display: flex; | ||
| width: 60%; | ||
| `; | ||
|
|
||
| export const AdminSearchBarInputWrapper = styled.div` | ||
| display: flex; | ||
| width: 100%; | ||
| justify-content: space-between; | ||
| padding: 0.5rem 0.5rem 0.5rem 1rem; | ||
| border: 1px solid ${({ theme }) => theme.color.deepGrey}; | ||
| border-radius: ${({ theme }) => theme.borderRadius.large} 0 0 | ||
| ${({ theme }) => theme.borderRadius.large}; | ||
| `; | ||
|
|
||
| export const AdminSearchBarInput = styled.input` | ||
| width: 100%; | ||
| font-size: 1.3rem; | ||
| `; | ||
|
|
||
| export const AdminSearchBarBackIcon = styled.button` | ||
| svg { | ||
| width: 1.5rem; | ||
| } | ||
| `; | ||
|
|
||
| export const AdminSearchBarButton = styled.button` | ||
| width: 15%; | ||
| border: 1px solid ${({ theme }) => theme.color.navy}; | ||
| background: ${({ theme }) => theme.color.navy}; | ||
| border-radius: 0 ${({ theme }) => theme.borderRadius.large} | ||
| ${({ theme }) => theme.borderRadius.large} 0; | ||
| font-size: 1.3rem; | ||
| color: ${({ theme }) => theme.color.white}; | ||
| padding: 0.5rem 1rem 0.5rem 0.5rem; | ||
| `; | ||
|
|
||
| export const WriteLink = styled(Link)` | ||
| border: 1px solid ${({ theme }) => theme.color.navy}; | ||
| background: ${({ theme }) => theme.color.navy}; | ||
| border-radius: ${({ theme }) => theme.borderRadius.large}; | ||
| font-size: 1rem; | ||
| color: ${({ theme }) => theme.color.white}; | ||
| padding: 0.5rem 1rem; | ||
| transition: all 300ms ease-in-out; | ||
|
|
||
| &:hover { | ||
| background: ${({ theme }) => theme.color.white}; | ||
| color: ${({ 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,82 @@ | ||
| import { XMarkIcon } from '@heroicons/react/24/outline'; | ||
| import { MODAL_MESSAGE_CUSTOMER_SERVICE } from '../../../constants/user/customerService'; | ||
| import * as S from './SearchBar.styled'; | ||
| import { useState } from 'react'; | ||
| import { useLocation, useSearchParams } from 'react-router-dom'; | ||
| import { useModal } from '../../../hooks/useModal'; | ||
| import Modal from '../../common/modal/Modal'; | ||
| import { ADMIN_ROUTE } from '../../../constants/routes'; | ||
|
|
||
| interface SearchBarProps { | ||
| onGetKeyword: (value: string) => void; | ||
| value: string; | ||
| } | ||
|
|
||
| export default function SearchBar({ onGetKeyword, value }: SearchBarProps) { | ||
| const [keyword, setKeyword] = useState<string>(''); | ||
| const { isOpen, message, handleModalOpen, handleModalClose } = useModal(); | ||
| const [searchParams, setSearchParams] = useSearchParams(); | ||
|
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. 🛠️ Refactor suggestion 상태 관리 구조를 개선해야 합니다. 컴포넌트가 로컬 다음 중 하나의 방식으로 수정하는 것을 권장합니다: 방법 1: 완전한 제어 컴포넌트 - const [keyword, setKeyword] = useState<string>('');
+ // keyword 상태 제거하고 value prop만 사용방법 2: 로컬 상태만 사용 interface SearchBarProps {
- onGetKeyword: (value: string) => void;
- value: string;
+ onGetKeyword: (value: string) => void;
+ initialValue?: string;
}
🤖 Prompt for AI Agents |
||
| const location = useLocation(); | ||
|
|
||
| const handleKeyword = (inputValue: string) => { | ||
| const newSearchParams = new URLSearchParams(searchParams); | ||
| if (inputValue === '') { | ||
| newSearchParams.delete('keyword'); | ||
| } else { | ||
| newSearchParams.set('keyword', inputValue); | ||
| } | ||
| setSearchParams(newSearchParams); | ||
| }; | ||
|
|
||
| const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
| e.preventDefault(); | ||
|
|
||
| if (keyword.trim() === '') { | ||
| return handleModalOpen(MODAL_MESSAGE_CUSTOMER_SERVICE.noKeyword); | ||
| } else { | ||
| onGetKeyword(keyword); | ||
| handleKeyword(keyword); | ||
| return; | ||
| } | ||
| }; | ||
|
|
||
| const handleChangeKeyword = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const value = e.target.value; | ||
| setKeyword(value); | ||
| }; | ||
|
|
||
| const handleClickSearchDefault = () => { | ||
| setKeyword(''); | ||
| onGetKeyword(''); | ||
| handleKeyword(''); | ||
| }; | ||
|
|
||
| return ( | ||
| <S.AdminSearchBarContainer onSubmit={handleSubmit}> | ||
| <S.AdminSearchBarWrapper> | ||
| <S.AdminSearchBarInputWrapper> | ||
| <S.AdminSearchBarInput | ||
| placeholder={MODAL_MESSAGE_CUSTOMER_SERVICE.noKeyword} | ||
| value={keyword ? keyword : value} | ||
| onChange={handleChangeKeyword} | ||
| /> | ||
| {value && ( | ||
| <S.AdminSearchBarBackIcon | ||
| type='button' | ||
| onClick={handleClickSearchDefault} | ||
| > | ||
| <XMarkIcon /> | ||
| </S.AdminSearchBarBackIcon> | ||
| )} | ||
| </S.AdminSearchBarInputWrapper> | ||
| <S.AdminSearchBarButton>검색</S.AdminSearchBarButton> | ||
| </S.AdminSearchBarWrapper> | ||
| <S.WriteLink to={ADMIN_ROUTE.write} state={{ form: location.pathname }}> | ||
| 작성하기 | ||
| </S.WriteLink> | ||
| <Modal isOpen={isOpen} onClose={handleModalClose}> | ||
| {message} | ||
| </Modal> | ||
| </S.AdminSearchBarContainer> | ||
| ); | ||
| } | ||
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
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,7 @@ | ||
| export const ADMIN_MODAL_MESSAGE = { | ||
| writeSuccess: '성공적으로 작성되었습니다.', | ||
| writeFail: '작성이 실패하였습니다.', | ||
| writeDeleteSuccess: '삭제되었습니다.', | ||
| writeDeleteFail: '삭제가 실패하였습니다.', | ||
| writeError: '알수없는 에러가 발생했습니다.', | ||
| }; |
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.
🛠️ Refactor suggestion
함수 반환 타입 명시와 일관된 에러 처리 개선 필요
인증 토큰 체크 로직 추가는 보안상 좋은 개선이지만, 몇 가지 개선사항이 있습니다:
undefined반환보다는 명시적인 에러나 null 반환을 고려해보세요다음과 같이 개선하는 것을 권장합니다:
🤖 Prompt for AI Agents