Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fc23e5c
feat: Tanstack query를 이용한 데이터 가져오는 커스텀 훅 useFetchQuery 구현
AAminha Feb 21, 2025
a60519b
feat: NoticeRollingPaper에 데이터 패칭 적용
AAminha Feb 21, 2025
dd6a5dd
feat: 홈 페이지에 공용 컴포넌트 적용
AAminha Feb 21, 2025
f745ef9
rename: MessageDetailModal -> CommentDetailModal 컴포넌트 명 수정
AAminha Feb 21, 2025
e5a470b
rename: Message -> Comment 컴포넌트 명 수정
AAminha Feb 21, 2025
9b27a12
feat: 롤링페이퍼 조회 기능 구현
AAminha Feb 21, 2025
f4b1b9f
refactor: 중복되는 배경 컴포넌트 적용 및 불필요한 에셋 제거
AAminha Feb 21, 2025
60e4a5b
Merge branch 'develop' of https://github.com/prgrms-web-devcourse-fin…
AAminha Feb 21, 2025
af8375e
refactor: 중복되는 메모 배경 컴포넌트 적용 및 불필요한 에셋 제거
AAminha Feb 21, 2025
5e69d75
remove: 중복 에셋 제거
AAminha Feb 21, 2025
f513809
refactor: 중복되는 모달 배경 컴포넌트 적용 및 불필요한 에셋 제거
AAminha Feb 21, 2025
c82077c
style: 커스텀 훅 제거 및 queryClient 기본값 설정
AAminha Feb 22, 2025
2964a4c
feat: 삭제 모달 추가 및 삭제 mock api 연결
AAminha Feb 23, 2025
880e54a
feat: 편지 추가 mock api 연결
AAminha Feb 24, 2025
1332774
fix: 신고 ui 제거
AAminha Feb 24, 2025
837201a
style: 사용하지 않는 코드 제거
AAminha Feb 24, 2025
b73b29e
Merge branch 'develop' of https://github.com/prgrms-web-devcourse-fin…
AAminha Feb 24, 2025
04c48c8
style: 엔드포인트 오타 수정
AAminha Feb 24, 2025
7c5b26b
style: 더미 제거
AAminha Feb 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/apis/rolling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import client from './client';

export const getCurrentRollingPaper = async (): Promise<RollingPaperInformation> => {
const {
data: { data },
} = await client.get('/api/event-posts');
return data;
};

export const getRollingPaperDetail = async (
rollingPaperId: string | number,
): Promise<RollingPaper> => {
const {
data: { data },
} = await client.get(`/api/event-posts/${rollingPaperId}`);
return data;
};

export const postRollingPaperComment = async (rollingPaperId: string | number, content: string) => {
const {
data: { data },
} = await client.post(`/api/event-posts/${rollingPaperId}/comments`, {
content,
});
return data;
};

export const deleteRollingPaperComment = async (commentId: string | number) => {
try {
const {
data: { data },
} = await client.delete(`/api/event-posts/comments/${commentId}`);
return data;
} catch (error) {
console.error(error);
throw error;
}
};
Binary file removed src/assets/images/letter-pink.png
Binary file not shown.
Binary file removed src/assets/images/memo-pink.png
Binary file not shown.
Binary file removed src/assets/images/memo-yellow.png
Binary file not shown.
Binary file removed src/assets/images/modal-pink.png
Binary file not shown.
Binary file removed src/assets/images/modal-yellow.png
Binary file not shown.
Binary file removed src/assets/images/random-cheer-bird.png
Binary file not shown.
8 changes: 3 additions & 5 deletions src/components/ConfirmModal.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BackgroundImageWrapper 대신 ModalBackgroundWrapper 를 사용하신 이유가 궁금해요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 내용에도 적혀있는데요! 기존에는 모달 뒷배경도 이미지로 띄우고 있었어요. 물론 이미지 하나 더 추가한다고 해서 엄청나게 성능이 개선된다는 둥 속도가 빨라진다는 둥 그런건 아닐테지만... 그래도 CSS로 할 수 있으니까 이미지보단 나을 것 같다고 생각해서!
이미지를 뒷배경으로 깔아주는 역할을 하는 BackgroundImageWrapper 대신 다양한 css 처리를 미리 해둔 ModalBackgroundWrapper로 교체하였습니다!

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import ModalBg from '@/assets/images/modal-yellow.png';

import BackgroundImageWrapper from './BackgroundImageWrapper';
import ModalBackgroundWrapper from './ModalBackgroundWrapper';
import ModalOverlay from './ModalOverlay';

interface ConfirmModalProps {
Expand Down Expand Up @@ -28,13 +26,13 @@ const ConfirmModal = ({
return (
<ModalOverlay>
<div className="w-73">
<BackgroundImageWrapper as="section" className="mb-12 rounded-lg p-5" imageUrl={ModalBg}>
<ModalBackgroundWrapper className="relative mb-12 rounded-lg p-5">
<div className="flex flex-col gap-1">
<p className="body-m text-gray-80">{title}</p>
<p className="caption-r text-black">{description}</p>
</div>
{children}
</BackgroundImageWrapper>
</ModalBackgroundWrapper>
<section className="flex items-center gap-6">
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { twMerge } from 'tailwind-merge';

interface ListItemWrapperProps {
interface LetterWrapperProps {
isSender?: boolean;
className?: string;
children: React.ReactNode;
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
}

const ListItemWrapper = ({
isSender = false,
className,
children,
onClick,
}: ListItemWrapperProps) => {
const LetterWrapper = ({ isSender = false, className, children, onClick }: LetterWrapperProps) => {
return (
<article
className={twMerge(
'relative flex overflow-hidden rounded-sm p-4',
isSender ? 'list-sender-bg' : 'list-receiver-bg',
isSender ? 'letter-sender-bg' : 'letter-receiver-bg',
className,
)}
onClick={onClick}
Expand All @@ -28,4 +23,4 @@ const ListItemWrapper = ({
);
};

export default ListItemWrapper;
export default LetterWrapper;
31 changes: 31 additions & 0 deletions src/components/MemoWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { twMerge } from 'tailwind-merge';

interface MemoWrapperProps {
isSender?: boolean;
className?: string;
children: React.ReactNode;
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
}

const MemoWrapper = ({ isSender = false, className, children, onClick }: MemoWrapperProps) => {
return (
<article
className={twMerge(
'relative flex overflow-hidden p-4',
isSender ? 'memo-sender-bg' : 'letter-receiver-bg',
className,
)}
onClick={onClick}
>
<div className="z-10 w-full">{children}</div>
<div
className={twMerge(
'absolute inset-0 z-0 blur-xl',
isSender ? 'bg-white/50' : 'bg-white/70',
)}
/>
</article>
);
};

export default MemoWrapper;
10 changes: 4 additions & 6 deletions src/components/MessageModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { ChangeEvent } from 'react';

import ModalBg from '@/assets/images/modal-pink.png';

import BackgroundImageWrapper from './BackgroundImageWrapper';
import ModalOverlay from './ModalOverlay';
import TextareaField from './TextareaField';

Expand Down Expand Up @@ -32,15 +29,16 @@ const MessageModal = ({
return (
<ModalOverlay>
<p className="body-sb mb-4 text-center text-white">{description}</p>
<BackgroundImageWrapper as="section" className="mb-12 w-78 rounded-lg p-4" imageUrl={ModalBg}>
<section className="relative mb-12 w-78 overflow-hidden rounded-lg bg-[#FFD3CE] p-4">
<TextareaField
rows={5}
value={inputValue}
placeholder={placeholder}
onChange={onInputChange}
/>
{children}
</BackgroundImageWrapper>
<div className="relative z-1">{children}</div>
<div className="absolute inset-0 z-0 bg-white/60 blur-xl" />
</section>
<section className="flex items-center gap-6">
<button
type="button"
Expand Down
17 changes: 17 additions & 0 deletions src/components/ModalBackgroundWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { twMerge } from 'tailwind-merge';

interface ModalBackgroundWrapperProps {
className?: string;
children: React.ReactNode;
}

const ModalBackgroundWrapper = ({ className, children }: ModalBackgroundWrapperProps) => {
return (
<article className={twMerge('bg-primary-3 relative overflow-hidden', className)}>
<div className="relative z-1">{children}</div>
<div className="absolute inset-0 z-0 bg-white/70 blur-xl" />
</article>
);
};

export default ModalBackgroundWrapper;
26 changes: 0 additions & 26 deletions src/components/NoticeRolling.tsx

This file was deleted.

34 changes: 34 additions & 0 deletions src/components/NoticeRollingPaper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useQuery } from '@tanstack/react-query';
import { Link } from 'react-router';
import { twMerge } from 'tailwind-merge';

import { getCurrentRollingPaper } from '@/apis/rolling';
import { NoticeIcon } from '@/assets/icons';

const NoticeRollingPaper = () => {
const { data } = useQuery({
queryKey: ['notice-rolling-paper'],
queryFn: () => getCurrentRollingPaper(),
});

const noticeText = data?.title;

return (
<Link to={`/board/rolling/${data?.eventPostId}`}>
<article
className={twMerge(
'text-gray-60 flex w-full items-center gap-2.5 rounded-lg px-4 py-2',
'bg-linear-[275deg,rgba(255,255,255,0.4)_13.74%,rgba(238,238,238,0.4)_67.61%]',
'shadow-[0_1px_6px_rgba(218,189,74,0.8)]',
)}
>
<NoticeIcon className="h-6 w-6 shrink-0 text-gray-50" />
<div className="w-full overflow-hidden">
<p className="body-sb animate-marquee whitespace-nowrap">{noticeText}</p>
</div>
</article>
</Link>
);
};

export default NoticeRollingPaper;
37 changes: 17 additions & 20 deletions src/components/ResultLetter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import letterPink from '@/assets/images/letter-pink.png';

import { CATEGORYS } from '../pages/Write/constants';

import LetterWrapper from './LetterWrapper';

export default function ResultLetter({
categoryName = 'CONSOLATION',
title,
Expand All @@ -14,32 +14,29 @@ export default function ResultLetter({
const today = `${date.getFullYear()}년 ${date.getMonth() + 1}월 ${date.getDate()}일`;

return (
<div
className="flex w-full max-w-[300px] flex-col gap-[35px] p-4"
style={{ backgroundImage: `url(${letterPink})` }}
>
<div className="flex justify-between gap-3">
<div className="flex flex-col gap-2.5">
<span className="caption-b text-gray-60">따숨이님께</span>
<span className="caption-r text-gray-80 line-clamp-3 break-all">{title}</span>
<LetterWrapper>
<div className="flex w-full flex-col gap-[35px]">
<div className="flex justify-between gap-3">
<div className="flex flex-col gap-2.5">
<span className="caption-b text-gray-60">따숨이님께</span>
<span className="caption-r text-gray-80 line-clamp-3 break-all">{title}</span>
</div>
<img src={CATEGORYS[categoryName]} alt="우표" />
</div>
<img src={CATEGORYS[categoryName]} alt="우표" />
</div>
<div className="flex flex-col gap-[5px]">
<span className="caption-sb text-gray-60">{today}</span>
<div className="flex gap-1">
{address.split('').map((spell, idx) => {
return (
<div className="flex flex-col gap-[5px]">
<span className="caption-sb text-gray-60">{today}</span>
<div className="flex gap-1">
{address.split('').map((spell, idx) => (
<span
className="caption-r flex h-6 w-6 items-center justify-center rounded-sm bg-white/40"
key={idx}
>
{spell}
</span>
);
})}
))}
</div>
</div>
</div>
</div>
</LetterWrapper>
);
}
2 changes: 1 addition & 1 deletion src/components/TextareaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentPropsWithoutRef } from 'react';

const TextareaField = ({ ...props }: ComponentPropsWithoutRef<'textarea'>) => {
return (
<div className="w-full rounded-sm bg-white px-3 py-1.5">
<div className="relative z-1 w-full rounded-sm bg-white px-3 py-1.5">
<textarea
className="body-m placeholder:text-gray-30 text-gray-80 w-full resize-none bg-transparent"
{...props}
Expand Down
6 changes: 6 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import App from './App';
import './styles/index.css';

const queryClient = new QueryClient();
queryClient.setDefaultOptions({
queries: {
staleTime: 1000 * 60 * 5, // 5분
gcTime: 1000 * 60 * 60, // 1시간
},
});
Comment on lines +10 to +15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쿼리클리이언트 생성✅


createRoot(document.getElementById('root')!).render(
<StrictMode>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Home/components/RandomCheer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useState } from 'react';

import randomCheerBird from '@/assets/images/field-theme-asset-bird.png';

import { RANDOM_CHEER_LIST } from '../constants';
import randomCheerBird from '@/assets/images/random-cheer-bird.png';

const RandomCheer = () => {
const getRandomCheer = (): string => {
Expand Down
11 changes: 5 additions & 6 deletions src/pages/Home/components/ShowDraftModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import DeleteOutlineRoundedIcon from '@mui/icons-material/DeleteOutlineRounded';
import React from 'react';
import ModalBg from '@/assets/images/modal-yellow.png';
import ModalOverlay from '@/components/ModalOverlay';

import DeleteOutlineRoundedIcon from '@mui/icons-material/DeleteOutlineRounded';
import ModalBackgroundWrapper from '@/components/ModalBackgroundWrapper';
import ModalOverlay from '@/components/ModalOverlay';

interface ShowDraftModalProps {
children?: React.ReactNode;
Expand All @@ -24,8 +24,7 @@ const ShowDraftModal = ({ onClose }: ShowDraftModalProps) => {
임시저장된 편지가 있어요!
</p>
<div className="flex w-73 justify-center">
<section className="relative overflow-hidden rounded-lg p-5">
<img src={ModalBg} className="absolute inset-0 z-[-10] h-full w-full" />
<ModalBackgroundWrapper className="relative overflow-hidden rounded-lg p-5">
<div className="flex flex-col gap-1">
<p className="body-sb text-gray-80">임시저장 편지</p>
<p className="caption-r text-black">로그아웃 시 임시 저장된 편지는 사라집니다</p>
Expand All @@ -43,7 +42,7 @@ const ShowDraftModal = ({ onClose }: ShowDraftModalProps) => {
</div>
))}
</div>
</section>
</ModalBackgroundWrapper>
</div>
</div>
</ModalOverlay>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Home/components/ShowIncomingLettersModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import ModalBg from '@/assets/images/modal-yellow.png';

import ModalBackgroundWrapper from '@/components/ModalBackgroundWrapper';
import ModalOverlay from '@/components/ModalOverlay';

interface ShowIncomingLettersModalProps {
Expand All @@ -22,8 +23,7 @@ const ShowIncomingLettersModal = ({ onClose }: ShowIncomingLettersModalProps) =>
따숨 배달부가 따숨이의 답장을 배달 중이에요!
</p>
<div className="flex w-73 justify-center">
<section className="relative overflow-hidden rounded-lg p-5">
<img src={ModalBg} className="absolute inset-0 z-[-10] h-full w-full" />
<ModalBackgroundWrapper className="relative overflow-hidden rounded-lg p-5">
<div className="flex flex-col gap-1">
<p className="body-sb text-gray-80">오고 있는 편지</p>
<p className="caption-r text-black">시간은 실제 시간을 기반으로 책정됩니다.</p>
Expand All @@ -39,7 +39,7 @@ const ShowIncomingLettersModal = ({ onClose }: ShowIncomingLettersModalProps) =>
</div>
))}
</div>
</section>
</ModalBackgroundWrapper>
</div>
</div>
</ModalOverlay>
Expand Down
Loading