11'use client' ;
22
3- import React , { useEffect , useState } from 'react' ;
3+ import React , { Suspense , useEffect , useState } from 'react' ;
44import styled , { css } from 'styled-components' ;
55import { theme } from '@/styles/theme' ;
66import Input from '@/components/common/Input' ;
77import Button from '@/components/common/Button' ;
8- import { useRouter } from 'next/navigation' ;
8+ import { useRouter , useSearchParams } from 'next/navigation' ;
99import Image from 'next/image' ;
1010
1111import {
@@ -22,11 +22,12 @@ import { useToast } from '@/hooks/useToast';
2222import { postImage } from '@/api/image/image' ;
2323import ConfirmModal from '@/components/common/ConfirmModal' ;
2424import { draftModalState } from '@/recoil/draftStore' ;
25- import imageCompression from 'browser-image-compression' ;
2625import DraftButton from '@/components/draft/DraftButton' ;
26+ import Loader , { LoaderContainer } from '@/components/common/Loader' ;
2727
2828const SendContentPage = ( ) => {
2929 const router = useRouter ( ) ;
30+ const searchParams = useSearchParams ( ) ;
3031 const { showToast } = useToast ( ) ;
3132 const [ draftId , setDraftId ] = useState < string | null > ( null ) ;
3233 const [ receiver , setReceiver ] = useState < string > ( '' ) ;
@@ -39,6 +40,8 @@ const SendContentPage = () => {
3940 const [ isImageUploadLoading , setImageUploadLoading ] =
4041 useState < boolean > ( false ) ; // 서버 이미지 업로드 상태
4142
43+ const isGuest = searchParams . get ( 'guest' ) === 'true' ;
44+
4245 const [ draftModal , setDraftModal ] = useRecoilState ( draftModalState ) ;
4346 const [ letterState , setLetterState ] = useRecoilState ( sendLetterState ) ;
4447 const [ tempCount , setTempCount ] = useState < number > ( 3 ) ;
@@ -81,7 +84,7 @@ const SendContentPage = () => {
8184 }
8285 } ;
8386
84- fetchGetDraftCount ( ) ;
87+ if ( ! isGuest ) fetchGetDraftCount ( ) ;
8588
8689 if ( draftKey ) {
8790 fetchGetDraft ( ) ;
@@ -263,7 +266,8 @@ const SendContentPage = () => {
263266 images : images ,
264267 previewImages : previewImages
265268 } ) ) ;
266- router . push ( '/send/template' ) ;
269+
270+ router . push ( `/send/template${ isGuest ? '?guest=true' : '' } ` ) ;
267271 } ;
268272
269273 /* 임시 저장 삭제 핸들러 */
@@ -317,13 +321,15 @@ const SendContentPage = () => {
317321
318322 return (
319323 < >
320- < DraftButton
321- handleSaveLetter = { handleSaveLetter }
322- handleDraftBottom = { handleDraftBottom }
323- isDraftDisabled = { isDraftDisabled }
324- isImageUploadLoading = { isImageUploadLoading }
325- tempCount = { tempCount }
326- />
324+ { ! isGuest && (
325+ < DraftButton
326+ handleSaveLetter = { handleSaveLetter }
327+ handleDraftBottom = { handleDraftBottom }
328+ isDraftDisabled = { isDraftDisabled }
329+ isImageUploadLoading = { isImageUploadLoading }
330+ tempCount = { tempCount }
331+ />
332+ ) }
327333 < Container >
328334 < div >
329335 < Label >
@@ -420,7 +426,19 @@ const SendContentPage = () => {
420426 ) ;
421427} ;
422428
423- export default SendContentPage ;
429+ export default function SendContentPaging ( ) {
430+ return (
431+ < Suspense
432+ fallback = {
433+ < LoaderContainer >
434+ < Loader />
435+ </ LoaderContainer >
436+ }
437+ >
438+ < SendContentPage />
439+ </ Suspense >
440+ ) ;
441+ }
424442
425443const Container = styled . div `
426444 width: 100%;
0 commit comments