Skip to content

Commit 7f9ec57

Browse files
authored
Merge pull request #159 from YAPP-Github/fix/cheer-upload-state
2 parents b57f37c + c4e66f5 commit 7f9ec57

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

  • src/app

src/app/(store)/stores/register/_components/RegisterFunnel/_components/ImagesStep/ImagesStep.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export const ImagesStep = ({
3838
}: ImageStepProps) => {
3939
const { data: member } = useQuery(memberQueryOptions);
4040

41-
const { mutateAsync: postCheer, isPending } = usePostCheerMutation();
41+
const [isPending, setIsPending] = useState(false);
42+
43+
const { mutateAsync: postCheer } = usePostCheerMutation();
4244

4345
const [images, setImages] = useState<File[]>([]);
4446

@@ -59,6 +61,8 @@ export const ImagesStep = ({
5961
fileSize: number;
6062
}> = [];
6163

64+
setIsPending(true);
65+
6266
if (submitType === "with-images" && images.length > 0) {
6367
const { urls: presignedUrls } = await getPresignedUrl(
6468
images.map((image, index) => ({
@@ -95,6 +99,8 @@ export const ImagesStep = ({
9599
if (error instanceof ApiException) {
96100
toast.error(error.message);
97101
}
102+
} finally {
103+
setIsPending(false);
98104
}
99105
};
100106

src/app/story/register/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { zodResolver } from "@hookform/resolvers/zod";
44
import { useRouter } from "next/navigation";
5+
import { useState } from "react";
56
import { FormProvider, useForm } from "react-hook-form";
67

78
import { getPresignedUrl, uploadImageToS3 } from "@/app/_api/image/image.api";
@@ -23,7 +24,9 @@ import * as styles from "./page.css";
2324
export default function StoryRegisterPage() {
2425
const { file, clearUpload } = useImageUploadContext();
2526
const router = useRouter();
26-
const { mutate: postStory, isPending } = usePostStoryMutation();
27+
28+
const [isPending, setIsPending] = useState(false);
29+
const { mutate: postStory } = usePostStoryMutation();
2730

2831
const handleClick = () => {
2932
router.back();
@@ -45,6 +48,8 @@ export default function StoryRegisterPage() {
4548
let imageData: ImageRequest[] = [];
4649

4750
if (data.image) {
51+
setIsPending(true);
52+
4853
const { urls: presignedUrls } = await getPresignedUrl([
4954
{
5055
order: 0,
@@ -85,6 +90,8 @@ export default function StoryRegisterPage() {
8590
);
8691
} catch (error) {
8792
console.error("이미지 업로드 실패:", error);
93+
} finally {
94+
setIsPending(false);
8895
}
8996
};
9097

0 commit comments

Comments
 (0)