-
Notifications
You must be signed in to change notification settings - Fork 2
LC-2789 admin 배너 관리 #2138
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
Open
yeeun426
wants to merge
15
commits into
main
Choose a base branch
from
LC-2789-admin-배너-관리
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "LC-2789-admin-\uBC30\uB108-\uAD00\uB9AC"
+1,766
−71
Open
LC-2789 admin 배너 관리 #2138
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a4dbd2b
feat : admin 통합 배너 관리 수정
yeeun426 89251b2
Merge branch 'main' into LC-2789-admin-배너-관리
yeeun426 d325a3f
feat : 노출 중 ui 변경
yeeun426 72551b2
feat : 통합 배너 생성 API 스펙 적용 및 폴더 구조 정리
yeeun426 edd2823
feat: 통합 배너 수정 추가
yeeun426 bef565c
feat : 배너 삭제 기능 추가
yeeun426 10c3b20
feat: 통합 배너 노출 여부 토글 api 변경
yeeun426 e514250
feat : 어드민 사이드바 사용하지 않는 메뉴 정리
yeeun426 84a7901
feat : USER 통합 배너 api 수정
yeeun426 91a4253
feat : 등록/수정 페이지 검증 추가
yeeun426 bcd0574
feat : 만료된 배너 업데이트 버튼 추가
yeeun426 a23a005
feat : 업데이트 아이콘 추가
yeeun426 dc3e1fe
feat: 배너 등록 API 호출 방식 변경
yeeun426 2134741
feat : 마이페이지 모바일의 경우, 홈 배너로 수정
yeeun426 72a7ae9
feat : 폴더 구조 기반 리팩토링
yeeun426 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,134 @@ | ||
| 'use client'; | ||
|
|
||
| import { | ||
| CommonBannerDetailResponse, | ||
| CommonBannerFormValue, | ||
| CommonBannerType, | ||
| useEditCommonBannerForAdmin, | ||
| useGetCommonBannerDetailForAdmin, | ||
| } from '@/api/banner'; | ||
| import EditorTemplate from '@/domain/admin/program/ui/editor/EditorTemplate'; | ||
| import LoadingContainer from '@/common/loading/LoadingContainer'; | ||
| import { useParams, useRouter } from 'next/navigation'; | ||
| import { useEffect, useState } from 'react'; | ||
| import CommonBannerInputContent from '../../new/components/CommonBannerInputContent'; | ||
|
|
||
| const toDatetimeLocal = (iso: string) => { | ||
| const date = new Date(iso); | ||
| const pad = (n: number) => String(n).padStart(2, '0'); | ||
| return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`; | ||
| }; | ||
|
|
||
| const mapDetailToFormValue = ( | ||
| detail: CommonBannerDetailResponse, | ||
| ): CommonBannerFormValue => { | ||
| const types: Record<CommonBannerType, boolean> = { | ||
| HOME_TOP: false, | ||
| HOME_BOTTOM: false, | ||
| PROGRAM: false, | ||
| MY_PAGE: false, | ||
| }; | ||
|
|
||
| let homePcFileId: number | null = null; | ||
| let homeMobileFileId: number | null = null; | ||
| let programPcFileId: number | null = null; | ||
| let programMobileFileId: number | null = null; | ||
| let homePcFileUrl: string | null = null; | ||
| let homeMobileFileUrl: string | null = null; | ||
| let programPcFileUrl: string | null = null; | ||
| let programMobileFileUrl: string | null = null; | ||
|
|
||
| for (const item of detail.commonBannerDetailList ?? []) { | ||
| types[item.type] = true; | ||
|
|
||
| if (item.type === 'HOME_TOP' || item.type === 'HOME_BOTTOM') { | ||
| if (item.agentType === 'PC') { homePcFileId = item.fileId; homePcFileUrl = item.fileUrl ?? null; } | ||
| if (item.agentType === 'MOBILE') { homeMobileFileId = item.fileId; homeMobileFileUrl = item.fileUrl ?? null; } | ||
| } else if (item.type === 'PROGRAM') { | ||
| if (item.agentType === 'PC') { programPcFileId = item.fileId; programPcFileUrl = item.fileUrl ?? null; } | ||
| if (item.agentType === 'MOBILE') { programMobileFileId = item.fileId; programMobileFileUrl = item.fileUrl ?? null; } | ||
| } else if (item.type === 'MY_PAGE') { | ||
| // MY_PAGE PC = 프로그램 모바일, MY_PAGE MOBILE = 홈 모바일 | ||
| if (item.agentType === 'PC') { programMobileFileId = item.fileId; programMobileFileUrl = item.fileUrl ?? null; } | ||
| if (item.agentType === 'MOBILE') { homeMobileFileId = item.fileId; homeMobileFileUrl = item.fileUrl ?? null; } | ||
| } | ||
| } | ||
|
|
||
| const { commonBanner } = detail; | ||
|
|
||
| return { | ||
| title: commonBanner.title || '', | ||
| landingUrl: commonBanner.landingUrl || '', | ||
| isVisible: commonBanner.isVisible, | ||
| startDate: commonBanner.startDate | ||
| ? toDatetimeLocal(commonBanner.startDate) | ||
| : '', | ||
| endDate: commonBanner.endDate | ||
| ? toDatetimeLocal(commonBanner.endDate) | ||
| : '', | ||
| types, | ||
| homePcFile: null, | ||
| homeMobileFile: null, | ||
| programPcFile: null, | ||
| programMobileFile: null, | ||
| homePcFileId, | ||
| homeMobileFileId, | ||
| programPcFileId, | ||
| programMobileFileId, | ||
| homePcFileUrl, | ||
| homeMobileFileUrl, | ||
| programPcFileUrl, | ||
| programMobileFileUrl, | ||
| }; | ||
| }; | ||
|
|
||
| const CommonBannerEdit = () => { | ||
| const router = useRouter(); | ||
| const params = useParams(); | ||
| const commonBannerId = Number(params.id); | ||
|
|
||
| const { data, isLoading } = useGetCommonBannerDetailForAdmin({ | ||
| commonBannerId, | ||
| }); | ||
|
|
||
| const [value, setValue] = useState<CommonBannerFormValue | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (data && !value) { | ||
| setValue(mapDetailToFormValue(data)); | ||
| } | ||
| }, [data, value]); | ||
|
|
||
| const { mutate: tryEditCommonBanner } = useEditCommonBannerForAdmin({ | ||
| successCallback: () => { | ||
| router.push('/admin/banner/common-banners'); | ||
| }, | ||
| errorCallback: (error) => { | ||
| console.error(error); | ||
| alert('통합 배너 수정에 실패했습니다.'); | ||
| }, | ||
| }); | ||
|
|
||
| const handleSubmit = async (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
| if (!value) return; | ||
| tryEditCommonBanner({ commonBannerId, form: value }); | ||
| }; | ||
|
|
||
| if (isLoading || !value) { | ||
| return <LoadingContainer />; | ||
| } | ||
|
|
||
| return ( | ||
| <EditorTemplate | ||
| title="배너 수정" | ||
| onSubmit={handleSubmit} | ||
| submitButton={{ text: '수정' }} | ||
| cancelButton={{ text: '취소', to: '-1' }} | ||
| > | ||
| <CommonBannerInputContent value={value} onChange={setValue} /> | ||
| </EditorTemplate> | ||
| ); | ||
| }; | ||
|
|
||
| export default CommonBannerEdit; | ||
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.