diff --git a/api/user.ts b/api/user.ts index bd005a4d..2ed20bd3 100644 --- a/api/user.ts +++ b/api/user.ts @@ -3,7 +3,7 @@ import { client } from './common/axios'; import { API_VERSION_01, PATH_USER } from './path'; import { UseFormReturn } from 'react-hook-form'; -import { UserAccountDataResponseType } from '@/types/api/response'; +import { DefaultResponseType, UserAccountDataResponseType } from '@/types/api/response'; import { WishesDataInputType } from '@/types/wishesType'; const ACCESS_TOKEN = getAccessToken(); @@ -11,7 +11,7 @@ const ACCESS_TOKEN = getAccessToken(); export const putUserAccount = async ( methods: UseFormReturn, ) => { - const data = await client.put( + const data = await client.put( `${API_VERSION_01}${PATH_USER.ACCOUNT}`, { accountInfo: { diff --git a/components/Cakes/CakesForm.tsx b/components/Cakes/CakesForm.tsx index 01dc15fc..40aa8a9e 100644 --- a/components/Cakes/CakesForm.tsx +++ b/components/Cakes/CakesForm.tsx @@ -13,6 +13,7 @@ import { CakeListType } from '@/types/cakes/cakeListType'; import { useGetPublicWishes } from '@/hooks/queries/public'; import { UseMutateFunction } from 'react-query'; import theme from '@/styles/theme'; +import { useEffect, useState } from 'react'; interface CakesFormProps { methods: UseFormReturn; @@ -39,11 +40,25 @@ export default function CakesForm(props: CakesFormProps) { const { methods, selectedCake, selectedIndex, selectCake, wishesId, postPublicCakesData } = props; const { publicWishesData } = useGetPublicWishes(wishesId); + const [btnState, setBtnState] = useState(false); const handleClickFn = () => { + if (!btnState) return; postPublicCakesData(); }; + useEffect(() => { + if ( + methods.watch('letter') !== '' && + methods.watch('letter').length <= 300 && + methods.watch('giverName') + ) { + setBtnState(true); + } else { + setBtnState(false); + } + }, [methods.watch()]); + return ( <> @@ -80,7 +95,11 @@ export default function CakesForm(props: CakesFormProps) { - @@ -107,7 +126,10 @@ const Styled = { HintBox: styled(StyledBox)` width: 100%; - height: 12.6rem; + min-height: 12.6rem; + max-height: 16rem; + + overflow: scroll; ${theme.fonts.body14}; diff --git a/components/Cakes/CakesPay.tsx b/components/Cakes/CakesPay.tsx index 6bf4a1c7..52a69266 100644 --- a/components/Cakes/CakesPay.tsx +++ b/components/Cakes/CakesPay.tsx @@ -35,7 +35,8 @@ export default function CakesPay(props: CakesPayProps) { alert('계좌번호에 오류가 있습니다!'); return; } - const accountInfoText = `${publicWishesData.bank} ${publicWishesData.accountNumber}` || ''; + const accountInfoText = + `${publicWishesData.bank} ${publicWishesData.accountNumber} ${selectedCake.price}원` || ''; const isClipboardSupported = () => navigator?.clipboard != null; try { diff --git a/components/Common/Box/ImageBox.tsx b/components/Common/Box/ImageBox.tsx index 65a20dd6..52cc9f56 100644 --- a/components/Common/Box/ImageBox.tsx +++ b/components/Common/Box/ImageBox.tsx @@ -15,7 +15,7 @@ export default function ImageBox(props: PropsWithChildren) { return {children}; } -const StyledImageBox = styled(StyledBox)` +export const StyledImageBox = styled(StyledBox)` width: 100%; height: 15rem; diff --git a/components/Common/Input/Input.tsx b/components/Common/Input/Input.tsx index e7b25f3b..3a55f83e 100644 --- a/components/Common/Input/Input.tsx +++ b/components/Common/Input/Input.tsx @@ -15,12 +15,14 @@ interface InputProps { inputType?: HTMLInputTypeAttribute; placeholder?: string; readOnly?: boolean; + disabled?: boolean; register: UseFormRegisterReturn; errors?: FieldError; } export default function Input(props: PropsWithChildren) { - const { width, inputType, boxType, placeholder, readOnly, register, errors, children } = props; + const { width, inputType, boxType, placeholder, readOnly, disabled, register, errors, children } = + props; return ( <> @@ -30,6 +32,7 @@ export default function Input(props: PropsWithChildren) { pattern={inputType === 'number' ? '\\d*' : undefined} placeholder={placeholder} readOnly={readOnly} + disabled={disabled} {...register} /> {children} @@ -39,10 +42,10 @@ export default function Input(props: PropsWithChildren) { ); } -export const StyledInput = styled.input` +export const StyledInput = styled.input<{ disabled?: boolean }>` width: 100%; height: 100%; ${theme.fonts.body12}; - color: ${theme.colors.dark_blue}; + color: ${(props) => (props.disabled ? theme.colors.gray1 : theme.colors.dark_blue)}; `; diff --git a/components/Common/Input/InputLength.tsx b/components/Common/Input/InputLength.tsx index 978d8b16..3ad5c771 100644 --- a/components/Common/Input/InputLength.tsx +++ b/components/Common/Input/InputLength.tsx @@ -10,15 +10,16 @@ export default function InputLength(props: InputLengthProps) { const { inputLength, limitLength } = props; return ( - + {inputLength}/{limitLength} ); } const Styled = { - Container: styled.div` - color: ${theme.colors.gray2}; + Container: styled.div<{ inputLength: number; limitLength: number }>` + color: ${(props) => + props.inputLength > props.limitLength ? theme.colors.warning_red : theme.colors.gray2}; ${theme.fonts.body12}; padding-left: 1rem; diff --git a/components/Common/Input/TextareaBox.tsx b/components/Common/Input/TextareaBox.tsx index 7f3d16e6..e1e50d8d 100644 --- a/components/Common/Input/TextareaBox.tsx +++ b/components/Common/Input/TextareaBox.tsx @@ -12,15 +12,21 @@ interface TextareaBoxProps { inputLength?: number; limitLength?: number; readOnly?: boolean; + disabled?: boolean; register: UseFormRegisterReturn; } export default function TextareaBox(props: TextareaBoxProps) { - const { placeholder, inputLength, limitLength, readOnly, register } = props; + const { placeholder, inputLength, limitLength, readOnly, disabled, register } = props; return ( - + {limitLength && } @@ -35,11 +41,12 @@ const Styled = { justify-content: space-between; `, - Textarea: styled.textarea` + Textarea: styled.textarea<{ disabled?: boolean }>` width: 100%; height: 10.5rem; ${theme.fonts.body12}; + color: ${(props) => (props.disabled ? theme.colors.gray1 : theme.colors.dark_blue)}; resize: none; `, diff --git a/components/Common/Modal/BankInput.tsx b/components/Common/Modal/BankInput.tsx index 8c0aba84..d23cb153 100644 --- a/components/Common/Modal/BankInput.tsx +++ b/components/Common/Modal/BankInput.tsx @@ -5,7 +5,7 @@ import styled from 'styled-components'; import { UseFormReturn } from 'react-hook-form'; -import { WishesDataInputType } from '@/types/wishesType'; +import { MainProgressDataType, WishesDataInputType } from '@/types/wishesType'; import { ArrowDownIc } from '@/public/assets/icons'; import Image from 'next/image'; @@ -18,6 +18,7 @@ import { validation } from '@/validation/input'; interface BankInputProps { methods: UseFormReturn; + progressData?: MainProgressDataType; } export default function BankInput(props: BankInputProps) { @@ -39,7 +40,6 @@ export default function BankInput(props: BankInputProps) { boxType="inputBox--large" placeholder="은행 선택" register={methods.register('bank')} - readOnly > 더 보기 diff --git a/components/Main/MainCenterContent.tsx b/components/Main/MainCenterContent.tsx index 178e3b7e..30a5b750 100644 --- a/components/Main/MainCenterContent.tsx +++ b/components/Main/MainCenterContent.tsx @@ -11,12 +11,11 @@ import { import theme from '@/styles/theme'; import { useGetMainProgressData } from '@/hooks/queries/wishes'; import { convertMoneyText } from '@/utils/common/convertMoneyText'; +import router from 'next/router'; export default function MainCenterContent() { const { progressData } = useGetMainProgressData(); - console.log(progressData); - const ChatImg = () => { if (!progressData) { return MainChatImg; @@ -31,6 +30,10 @@ export default function MainCenterContent() { } }; + const handleMoveLetterPage = () => { + progressData && router.push(`mypage/letters/${progressData?.wishId}`); + }; + return ( @@ -55,12 +58,12 @@ export default function MainCenterContent() { 총 ???개 ) : ( - <> +
{'예상 케이크 금액 >\n'} {`총 ${convertMoneyText( progressData?.price.toString() || '0', )}원`} - +
)}
diff --git a/components/Main/MainTopContent.tsx b/components/Main/MainTopContent.tsx index 16115e51..243c203a 100644 --- a/components/Main/MainTopContent.tsx +++ b/components/Main/MainTopContent.tsx @@ -24,8 +24,8 @@ export default function MainTopContent() { return 'D-Day'; } else { return progressData.dayCount < 0 - ? `D${progressData?.dayCount}` - : `D+${progressData?.dayCount}`; + ? `D+${Math.abs(progressData?.dayCount)}` + : `D-${progressData?.dayCount}`; } }; diff --git a/components/Mypage/EditWishes/index.tsx b/components/Mypage/EditWishes/index.tsx index 81f442f5..fdc1e934 100644 --- a/components/Mypage/EditWishes/index.tsx +++ b/components/Mypage/EditWishes/index.tsx @@ -2,12 +2,11 @@ import Button from '@/components/Common/Button'; import Calendar from '@/components/Common/Calendar/Calendar'; import InputContainer from '@/components/Common/Input/InputContainer'; import TextareaBox from '@/components/Common/Input/TextareaBox'; -import UploadTypeToggleBtn from '@/components/Common/UploadTypeToggleBtn'; + import ItemLink from '@/components/Wishes/WishesForm/ItemLink'; import theme from '@/styles/theme'; import styled from 'styled-components'; import { useEffect, useState } from 'react'; -import { convertMoneyText } from '@/utils/common/convertMoneyText'; import UploadPresent from '@/components/Wishes/WishesForm/UploadPresent'; import Input from '@/components/Common/Input/Input'; import useUploadItemInfo from '@/hooks/wishes/useUploadItemInfo'; @@ -23,10 +22,14 @@ import SiteList from '@/components/Wishes/WishesForm/SiteList'; import { usePutUserAccount } from '@/hooks/queries/user'; import { LIMIT_TEXT } from '@/constant/limitText'; import { getDate } from '@/utils/common/getDate'; +import { validation } from '@/validation/input'; +import InputLength from '@/components/Common/Input/InputLength'; export default function EditWishesContainer() { const { imageFile, preSignedImageUrl, uploadImageFile } = useUploadItemInfo(); - const [isLinkLoadType, setIsLinkLoadType] = useState(true); //false : 링크 불러오기 true : 직접 + const [isLinkLoadType, setIsLinkLoadType] = useState(false); //false : 링크 불러오기 true : 직접 + + const [editState, setEditState] = useState(false); const methods = useForm({ defaultValues: { @@ -48,7 +51,6 @@ export default function EditWishesContainer() { const { wishesProgressData } = useGetWishesProgress(); const { progressData } = useGetMainProgressData(); - const { handlePutUserAccount } = usePutUserAccount(methods); const { handlePutProgressWishes } = usePutProgressWishes(methods); @@ -72,20 +74,46 @@ export default function EditWishesContainer() { } }, [wishesProgressData]); - const handleLoadTypeToggle = (state: boolean) => { - setIsLinkLoadType(state); + useEffect(() => { + if ( + methods.getValues('initial').length !== 0 && + methods.getValues('initial').length <= 15 && + methods.getValues('imageUrl') && + methods.getValues('price') !== '' && + Number(methods.getValues('price')) <= 12000000 && + methods.getValues('title').length <= 20 && + methods.getValues('hint').length !== 0 && + methods.getValues('hint').length <= 300 && + methods.getValues('name') && + methods.getValues('bank') && + methods.getValues('account') && + methods.getValues('phone') && + validation.isCorrectPhoneNumber(methods.getValues('phone')) + ) { + setEditState(true); + } else { + setEditState(false); + } + }, [methods.watch()]); + + const handleClickFn = () => { + if (!editState) return; + handlePutUserAccount(); + handlePutProgressWishes(); }; + console.log(progressData); + return ( <> 소원링크 정보 수정하기 - + /> */} {isLinkLoadType ? ( @@ -99,16 +127,31 @@ export default function EditWishesContainer() { preSignedImageUrl={preSignedImageUrl} uploadImageFile={uploadImageFile} methods={methods} + progressStatus={progressData?.status} /> )} - + + + - + + + @@ -126,7 +169,7 @@ export default function EditWishesContainer() { {/* BankInfo */} - + @@ -143,17 +186,15 @@ export default function EditWishesContainer() { inputLength={methods.watch('hint').length} limitLength={LIMIT_TEXT.DESCRIPTION} register={methods.register('hint')} + disabled={progressData?.status === 'WHILE'} /> diff --git a/components/Mypage/Letters/CakeListButton.tsx b/components/Mypage/Letters/CakeListButton.tsx index 05f7d60a..c388d4e4 100644 --- a/components/Mypage/Letters/CakeListButton.tsx +++ b/components/Mypage/Letters/CakeListButton.tsx @@ -5,20 +5,18 @@ import Image, { StaticImageData } from 'next/image'; interface CakeListButtonProps { image?: string | StaticImageData; backgroundColor: string; - fontColor: string; - fonts: string; handleClick?: () => void; cakeName?: string; cakeNum?: number; } export default function CakeListButton(props: CakeListButtonProps) { - const { image, backgroundColor, fonts, fontColor, handleClick, cakeName, cakeNum } = props; + const { image, backgroundColor, handleClick, cakeName, cakeNum } = props; return ( {image && 케이크 이미지} - {/* */} - + + {cakeName} X {cakeNum}개 @@ -43,14 +41,10 @@ const Styled = { margin: 0 0 1rem; `, - // TextContainer: styled.div<{ fonts: string; fontColor: string }>` - // padding: 0.2rem 0.5rem 0 1rem; - // ${(props) => props.fonts} - - // `, - - TextContainer: styled.div<{ fontColor: string }>` + TextContainer: styled.div` padding: 0.2rem 0.5rem 0 1rem; + margin-left: 2rem; + ${theme.fonts.button18}; `, NumText: styled.span` diff --git a/components/Mypage/Letters/LettersMain.tsx b/components/Mypage/Letters/LettersMain.tsx index b0912ca5..164ae6cb 100644 --- a/components/Mypage/Letters/LettersMain.tsx +++ b/components/Mypage/Letters/LettersMain.tsx @@ -76,8 +76,6 @@ export default function LettersMainContainer() { : undefined } backgroundColor={theme.colors.pastel_blue} - fontColor={theme.colors.gray4} - fonts={theme.fonts.button18} image={cake.smallImage} cakeName={cake.name} cakeNum={getCakeNum(cake.cakeNumber, cakesCount)} diff --git a/components/Mypage/Letters/[id].tsx b/components/Mypage/Letters/[id].tsx index 8a065bb6..a6fdb2a3 100644 --- a/components/Mypage/Letters/[id].tsx +++ b/components/Mypage/Letters/[id].tsx @@ -52,8 +52,6 @@ export default function LettersContainer() { <> { + if (progressData?.status === 'END' || progressData === undefined) return; setCancleModalState(!cancleModalState); }; @@ -53,12 +54,12 @@ export default function MyPageContainer() { useResetRecoilState(LoginUserInfo); }; - const handleWithdrawal = () => { - if (window.confirm('탈퇴를 진행하시겠습니까?')) { - deleteUserInfo(); - router.push('/'); - } - }; + // const handleWithdrawal = () => { + // if (window.confirm('탈퇴를 진행하시겠습니까?')) { + // deleteUserInfo(); + // router.push('/'); + // } + // }; return ( <> @@ -106,6 +107,7 @@ export default function MyPageContainer() { > 진행중인 펀딩 중단하기 + {} 지난 소원 링크 모음 @@ -119,7 +121,7 @@ export default function MyPageContainer() { 로그아웃 - 회원탈퇴 + {/* 회원탈퇴 */}
diff --git a/components/Wishes/Common/WishesStepBtn.tsx b/components/Wishes/Common/WishesStepBtn.tsx index 636a2b31..f03cd8c4 100644 --- a/components/Wishes/Common/WishesStepBtn.tsx +++ b/components/Wishes/Common/WishesStepBtn.tsx @@ -23,7 +23,8 @@ export default function WishesStepBtn(props: WishesStepBtnProps) { const handleNextClickFn = () => { if (handleClickFn) handleClickFn(); - wishesStep.handleNextStep(); + + wishesStep.nextState && wishesStep.handleNextStep(); }; return ( diff --git a/components/Wishes/WishesForm/Preview.tsx b/components/Wishes/WishesForm/Preview.tsx index c037214b..3a90a53c 100644 --- a/components/Wishes/WishesForm/Preview.tsx +++ b/components/Wishes/WishesForm/Preview.tsx @@ -1,5 +1,4 @@ import InputContainer from '@/components/Common/Input/InputContainer'; -import TextareaBox from '@/components/Common/Input/TextareaBox'; import styled from 'styled-components'; import theme from '@/styles/theme'; import { convertMoneyText } from '@/utils/common/convertMoneyText'; @@ -13,6 +12,8 @@ import WishesStepBtn from '../Common/WishesStepBtn'; import { ColorSystemType } from '@/types/common/box/boxStyleType'; import { useEffect } from 'react'; import { usePostWishes } from '@/hooks/queries/wishes'; +import ImageBox, { StyledImageBox } from '@/components/Common/Box/ImageBox'; +import { StyledBox } from '@/components/Common/Box'; interface PreviewProps { methods: UseFormReturn; @@ -56,7 +57,9 @@ export default function Preview(props: PreviewProps) { - + + {methods.getValues('hint')} + @@ -101,4 +104,16 @@ const Styled = { ButtonWrapper: styled.div` padding-bottom: 4.6rem; `, + + PreviewBox: styled(StyledBox)` + width: 100%; + height: 15rem; + + padding: 1rem 1rem 1rem 1.2rem; + + ${theme.fonts.body14} + border: 0.1rem solid ${theme.colors.main_blue}; + + overflow: scroll; + `, }; diff --git a/components/Wishes/WishesForm/UploadPresent.tsx b/components/Wishes/WishesForm/UploadPresent.tsx index 2fd53a44..6397f537 100644 --- a/components/Wishes/WishesForm/UploadPresent.tsx +++ b/components/Wishes/WishesForm/UploadPresent.tsx @@ -18,10 +18,11 @@ interface UploadPresentProps { preSignedImageUrl: string; uploadImageFile: (e: ChangeEvent) => void; methods: UseFormReturn; + progressStatus?: 'WHILE' | 'BEFORE' | 'END'; } export default function UploadPresent(props: UploadPresentProps) { - const { imageFile, preSignedImageUrl, uploadImageFile, methods } = props; + const { imageFile, preSignedImageUrl, uploadImageFile, methods, progressStatus } = props; useEffect(() => { if (preSignedImageUrl) methods.setValue('imageUrl', preSignedImageUrl); @@ -58,6 +59,7 @@ export default function UploadPresent(props: UploadPresentProps) { boxType="inputBox--large" placeholder="ex. 12,000,000" register={methods.register('price', { required: true })} + disabled={progressStatus === 'WHILE'} > { if ( methods.getValues('title') && + methods.getValues('title').length <= 20 && methods.getValues('hint').length !== 0 && methods.getValues('hint').length <= 300 ) { @@ -43,7 +44,7 @@ export default function WishesStep2(props: WishesStep2Props) { }, [methods.watch()]); return ( -
+ <>
@@ -72,7 +73,7 @@ export default function WishesStep2(props: WishesStep2Props) { - + ); } diff --git a/components/Wishes/WishesForm/WishesStep1.tsx b/components/Wishes/WishesForm/WishesStep1.tsx index 70625d16..44f83a28 100644 --- a/components/Wishes/WishesForm/WishesStep1.tsx +++ b/components/Wishes/WishesForm/WishesStep1.tsx @@ -59,6 +59,7 @@ export default function WishesStep1(props: PropsWithChildren) methods.getValues('initial').length <= 15 && imageFile && methods.getValues('price') !== '' && + Number(methods.getValues('price')) > 0 && Number(methods.getValues('price')) <= 12000000 ) { wishesStep.changeNextState(true); diff --git a/pages/mypage/letters/[id].tsx b/pages/mypage/letters/[id].tsx index 797a3420..25ed2d31 100644 --- a/pages/mypage/letters/[id].tsx +++ b/pages/mypage/letters/[id].tsx @@ -3,7 +3,7 @@ import LettersMainContainer from '@/components/Mypage/Letters/LettersMain'; export default function LettersMainPage() { return ( - + );