Skip to content

Commit 1023961

Browse files
authored
Merge pull request #201 from DevKor-github/fix/post-toast
[Fix] post ์—๋Ÿฌ ํ•ธ๋“ค๋ง
2 parents ec74048 + f12b97b commit 1023961

4 files changed

Lines changed: 32 additions & 11 deletions

File tree

โ€Žsrc/features/post/components/StepFunnel/Step5/index.tsxโ€Ž

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import * as c from '../style.css';
77
import SelectedPhoto from '../../uploadedPhoto';
88
import UploadFile from '../../UploadFile';
99
import { useStep5Store } from '@/features/post/stores/Step5Store';
10-
import { ALLOWED_EXTENSIONS, MAX_DESC, MAX_SIZE_BYTES, MAX_SIZE_MB, MAX_TITLE } from '@/libs/constants';
10+
import {
11+
ALLOWED_EXTENSIONS,
12+
MAX_DESC,
13+
MAX_FILE_LENGTH,
14+
MAX_SIZE_BYTES,
15+
MAX_SIZE_MB,
16+
MAX_TITLE,
17+
} from '@/libs/constants';
1118
import AlertText from '../../AlertText';
1219
import { getFileKeys } from '@/common/utils/getFileKeys';
1320
import getImageUrl from '@/common/utils/getImageUrl';
@@ -42,11 +49,11 @@ const Step5 = () => {
4249
const validFiles = fileArray.filter(file => {
4350
const ext = file.name.split('.').pop()?.toLowerCase();
4451
if (!ext || !ALLOWED_EXTENSIONS.includes(ext)) {
45-
openToast({ message: `"${file.name}"์€(๋Š”) ์ง€์›ํ•˜์ง€ ์•Š๋Š” ํ™•์žฅ์ž์ž…๋‹ˆ๋‹ค.` });
52+
openToast({ message: `์ง€์›ํ•˜์ง€ ์•Š๋Š” ํ™•์žฅ์ž์ž…๋‹ˆ๋‹ค.` });
4653
return false;
4754
}
4855
if (file.size > MAX_SIZE_BYTES) {
49-
openToast({ message: `"${file.name}"์€(๋Š”) ${MAX_SIZE_MB}MB๋ฅผ ์ดˆ๊ณผํ•ฉ๋‹ˆ๋‹ค.` });
56+
openToast({ message: `${MAX_SIZE_MB}MB๋ฅผ ์ดˆ๊ณผํ•ฉ๋‹ˆ๋‹ค.` });
5057
return false;
5158
}
5259
return true;
@@ -122,8 +129,8 @@ const Step5 = () => {
122129
</div>
123130

124131
<div className={s.AlertText}>
125-
<AlertText isIcon={true}>์ตœ๋Œ€ 6์žฅ๊นŒ์ง€ ๋“ฑ๋ก์ด ๊ฐ€๋Šฅํ•ด์š”.</AlertText>
126-
<AlertText isIcon={true}>์žฅ๋‹น ์ตœ๋Œ€ 5MB๊นŒ์ง€ ๋“ฑ๋ก์ด ๊ฐ€๋Šฅํ•ด์š”.</AlertText>
132+
<AlertText isIcon={true}>์ตœ๋Œ€ {MAX_FILE_LENGTH}์žฅ๊นŒ์ง€ ๋“ฑ๋ก์ด ๊ฐ€๋Šฅํ•ด์š”.</AlertText>
133+
<AlertText isIcon={true}>์žฅ๋‹น ์ตœ๋Œ€ {MAX_SIZE_MB}MB๊นŒ์ง€ ๋“ฑ๋ก์ด ๊ฐ€๋Šฅํ•ด์š”.</AlertText>
127134
</div>
128135
</div>
129136
</div>

โ€Žsrc/features/post/components/WriteLayout/index.tsxโ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ export const MAX_STEP = 6;
2929
const WriteLayout = ({ postState, itemId, isEdit }: Props) => {
3030
const [step, setStep] = useState(1);
3131

32-
const { mutate: postItem } = usePostItem();
33-
const { mutate: putItem } = usePutItem();
32+
const { mutate: postItem, isPending: isPosting } = usePostItem();
33+
const { mutate: putItem, isPending: isPutting } = usePutItem();
34+
35+
const isSubmitting = isPosting || isPutting;
3436

3537
const navigate = useNavigate();
3638
const data = useCollectPostData();
@@ -104,6 +106,7 @@ const WriteLayout = ({ postState, itemId, isEdit }: Props) => {
104106
isFirst={isFirst}
105107
isLast={isLast}
106108
postState={postState}
109+
isSubmitting={isSubmitting}
107110
/>
108111
</div>
109112
</div>

โ€Žsrc/features/post/components/WriteLayout/navigator.tsxโ€Ž

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,19 @@ interface NavigatorProps {
1818
isFirst: boolean;
1919
isLast: boolean;
2020
postState?: ItemDetailInterface;
21+
isSubmitting?: boolean;
2122
}
2223

23-
const Navigator = ({ totalSteps, currentStep, goNext, goPrev, isFirst, isLast, postState }: NavigatorProps) => {
24+
const Navigator = ({
25+
totalSteps,
26+
currentStep,
27+
goNext,
28+
goPrev,
29+
isFirst,
30+
isLast,
31+
postState,
32+
isSubmitting,
33+
}: NavigatorProps) => {
2434
const isStep1Valid = useStep1Store(state => state.isBtnValid());
2535
const isStep2Valid = useStep2Store(state => state.isBtnValid());
2636
const isStep3Valid = useStep3Store(state => state.isBtnValid());
@@ -36,10 +46,11 @@ const Navigator = ({ totalSteps, currentStep, goNext, goPrev, isFirst, isLast, p
3646
if (isLast && postState) {
3747
isBtnValid = !isStoreEqualToState(postState);
3848
}
39-
const isBtnAble = isBtnValid ? 'main' : 'disabled';
49+
const isBtnAble = isBtnValid && !isSubmitting ? 'main' : 'disabled';
4050

4151
const onClick = () => {
42-
if (isBtnValid) goNext();
52+
if (!isBtnValid || isSubmitting) return;
53+
goNext();
4354
};
4455

4556
return (

โ€Žsrc/libs/constants/index.tsโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const MAX_TITLE = 64;
44
export const MAX_DESC = 1000;
55
export const MAX_REVIEW = 500;
66
export const ALLOWED_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp'];
7-
export const MAX_SIZE_MB = 5;
7+
export const MAX_SIZE_MB = 3;
88
export const MAX_SIZE_BYTES = MAX_SIZE_MB * 1024 * 1024;
99
export const MAX_FILE_LENGTH = 6;
1010

0 commit comments

Comments
ย (0)