Skip to content

Commit

Permalink
✨ feat(#96): 편지 등록 input 변경에 따른 전역 store 상태 변경 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yyypearl committed Nov 20, 2024
1 parent ebe643c commit 7052a3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
9 changes: 8 additions & 1 deletion src/app/letter/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const LetterRegisterPage = () => {
const [isButtonDisabled, setIsButtonDisabled] = useState<boolean>(false);
const [isImageUploadLoading, setImageUploadLoading] =
useState<boolean>(false); // 서버 이미지 업로드 상태
const [loadingResolved, setLoadingResolved] = useState(false); // 로딩 플래그

const [letterState, setLetterState] = useRecoilState(registerLetterState);
const [isToastShown, setIsToastShown] = useState(false);
Expand All @@ -44,6 +43,10 @@ const LetterRegisterPage = () => {

const handleSenderChange = (newValue: string) => {
setSender(newValue);
setLetterState((prevState) => ({
...prevState,
senderName: newValue,
}));
};

const handleContentChange = (newValue: string) => {
Expand All @@ -53,6 +56,10 @@ const LetterRegisterPage = () => {
} else {
setContent(newValue);
}
setLetterState((prevState) => ({
...prevState,
content: newValue,
}));
};

const handleShowToast = () => {
Expand Down
15 changes: 0 additions & 15 deletions src/app/send/letter/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const SendLetterPage = () => {

const [isImageUploadLoading, setImageUploadLoading] =
useState<boolean>(false); // 서버 이미지 업로드 상태
const [loadingResolved, setLoadingResolved] = useState(false); // 로딩 플래그

const [draftModal, setDraftModal] = useRecoilState(draftModalState);
const [letterState, setLetterState] = useRecoilState(sendLetterState);
Expand Down Expand Up @@ -216,12 +215,6 @@ const SendLetterPage = () => {
}));
};

useEffect(() => {
if (!isImageUploadLoading) {
setLoadingResolved(true); // 로딩 완료 플래그
}
}, [isImageUploadLoading]);

/* 임시 저장 */
const handleSaveLetter = async () => {
console.log("클릭");
Expand Down Expand Up @@ -279,14 +272,6 @@ const SendLetterPage = () => {

const handleAddNext = async () => {
/* 다음 페이지 */
if (isLoading) {
// 로딩 완료될 때까지 대기
while (!loadingResolved) {
await new Promise((resolve) => setTimeout(resolve, 100));
}
}

/* 로딩(서버 URL 반환)이 끝난 뒤, 이후 코드 실행 */
setLetterState((prevState) => ({
...prevState,
draftId: draftId,
Expand Down

0 comments on commit 7052a3c

Please sign in to comment.