-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/beta qa #167
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
Fix/beta qa #167
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
| 'use client'; | ||
| import { EP } from '@/global/api/ep'; | ||
| import BottomSheetModal from '@/global/components/modal/BottomSheetModal'; | ||
| import ConfirmModal from '@/global/components/modal/ConfirmModal'; | ||
| import Toast from '@/global/components/toast/Toast'; | ||
| import { downloadFile } from '@/global/utils/downloadFile'; | ||
| import { getDeviceType } from '@/global/utils/getDeviceType'; | ||
| import { shareImage } from '@/global/utils/image/shareImage'; | ||
| import { useQueryClient } from '@tanstack/react-query'; | ||
| import { Download, Heart, Info } from 'lucide-react'; | ||
| import { Download, Heart, Info, Trash2 } from 'lucide-react'; | ||
| import { useState } from 'react'; | ||
| import { useDeleteAlbumPhotoMutation } from '../hooks/useDeleteAlbumPhotoMutation'; | ||
| import { usePhotoDetailQuery } from '../hooks/usePhotoDetailQuery'; | ||
| import { usePhotoDownloadMutation } from '../hooks/usePhotoDownloadMutation'; | ||
| import { usePhotoLikedMutation } from '../hooks/usePhotoLikedMutation'; | ||
| import { usePhotoUnlikedMutation } from '../hooks/usePhotoUnlikedMutation'; | ||
|
|
@@ -35,11 +38,36 @@ export default function FooterPhotoDetail({ | |
| const queryClient = useQueryClient(); | ||
| const [isDownloading, setIsDownloading] = useState(false); | ||
| const [isPhotoInfoOpen, setIsPhotoInfoOpen] = useState(false); | ||
|
|
||
| const { data: photoDetail } = usePhotoDetailQuery({ | ||
| albumId, | ||
| photoId, | ||
| }); | ||
|
|
||
| console.log( | ||
| '🗑️ FooterPhotoDetail - canDelete:', | ||
| photoDetail?.canDelete, | ||
| 'photoId:', | ||
| photoId, | ||
| ); | ||
|
Comment on lines
+47
to
+52
Contributor
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.
Contributor
Author
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 { mutateAsync: mutateAsyncLike, isPending: isLiking } = | ||
| usePhotoLikedMutation(); | ||
| const { mutateAsync: mutateAsyncUnlike, isPending: isUnliking } = | ||
| usePhotoUnlikedMutation(); | ||
| const { mutateAsync: mutateAsyncDownload } = usePhotoDownloadMutation(); | ||
| const { mutateAsync: mutateAsyncDelete } = useDeleteAlbumPhotoMutation(); | ||
|
|
||
| const handleDelete = async (): Promise<void> => { | ||
| try { | ||
| await mutateAsyncDelete({ albumId, photoId }); | ||
| queryClient.invalidateQueries({ queryKey: [EP.album.photos(albumId)] }); | ||
| setIsPhotoInfoOpen(false); | ||
|
Contributor
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.
Contributor
Author
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. 반영 |
||
| } catch (e) { | ||
| console.error(e); | ||
| Toast.alert('사진 삭제에 실패했습니다.'); | ||
| } | ||
| }; | ||
dasosann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const handleDeepToggle = async (): Promise<void> => { | ||
| try { | ||
|
|
@@ -105,23 +133,6 @@ export default function FooterPhotoDetail({ | |
|
|
||
| return ( | ||
| <section className='mx-10 flex shrink-0 justify-around py-5'> | ||
| <BottomSheetModal | ||
| title={'사진 정보'} | ||
| open={isPhotoInfoOpen} | ||
| onOpenChange={setIsPhotoInfoOpen} | ||
| trigger={ | ||
| <button className='flex w-12 justify-center'> | ||
| <Info width={24} height={24} color='white' /> | ||
| </button> | ||
| } | ||
| > | ||
| <SectionPhotoData | ||
| albumId={albumId} | ||
| photoId={photoId} | ||
| onAfterDelete={() => setIsPhotoInfoOpen(false)} | ||
| /> | ||
| </BottomSheetModal> | ||
|
|
||
| <button | ||
| type='button' | ||
| onClick={handleDownload} | ||
|
|
@@ -135,6 +146,22 @@ export default function FooterPhotoDetail({ | |
| color={`${isRecentlyDownloaded ? 'var(--color-neutral-400)' : 'white'}`} | ||
| /> | ||
| </button> | ||
| <BottomSheetModal | ||
| title={'사진 정보'} | ||
| open={isPhotoInfoOpen} | ||
| onOpenChange={setIsPhotoInfoOpen} | ||
| trigger={ | ||
| <button className='flex w-12 justify-center'> | ||
| <Info width={24} height={24} color='white' /> | ||
| </button> | ||
| } | ||
| > | ||
| <SectionPhotoData | ||
| name={photoDetail?.name} | ||
| captureTime={photoDetail?.captureTime} | ||
| createdAt={photoDetail?.createdAt} | ||
| /> | ||
| </BottomSheetModal> | ||
|
|
||
| <div className='typo-body-lg-semibold flex w-12 justify-center gap-1'> | ||
| <button type='button' onClick={handleDeepToggle}> | ||
|
|
@@ -165,6 +192,22 @@ export default function FooterPhotoDetail({ | |
| <ListPhotoLikers albumId={albumId} photoId={photoId} /> | ||
| </BottomSheetModal> | ||
| </div> | ||
|
|
||
| {photoDetail?.canDelete && ( | ||
| <ConfirmModal | ||
| title='사진을 삭제할까요?' | ||
| description='지운 사진은 다시 복구할 수 없어요.' | ||
| cancelText='취소' | ||
| confirmText='삭제하기' | ||
| confirmClassName='text-text-basic-inverse bg-button-accent-fill active:bg-button-accent-pressed active:text-basic-inverse' | ||
| onConfirm={handleDelete} | ||
| trigger={ | ||
| <button className='flex w-12 justify-center'> | ||
| <Trash2 width={24} height={24} color='white' /> | ||
| </button> | ||
| } | ||
| /> | ||
| )} | ||
| </section> | ||
| ); | ||
| } | ||
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.
date-fns라이브러리가 프로젝트에 이미 사용되고 있으니, 날짜 형식을 직접 만드는 대신format함수를 사용하면 코드를 더 간결하고 일관성 있게 유지할 수 있습니다.DateXInput컴포넌트에서도date-fns를 사용하고 있습니다.제안된 코드를 적용하려면 파일 상단에
import { format } from 'date-fns';를 추가해야 합니다.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.
반영