diff --git a/package.json b/package.json index 397c087..f6e5378 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "prop-types": "^15.7.2", "qs": "^6.10.2", "react": "^17.0.2", + "react-datepicker": "^4.5.0", "react-dom": "^17.0.2", "react-redux": "^7.2.6", "react-router-dom": "^6.0.2", diff --git a/src/common/utils/getTodayDate.jsx b/src/common/utils/getDateStr.jsx similarity index 60% rename from src/common/utils/getTodayDate.jsx rename to src/common/utils/getDateStr.jsx index 75dc4d4..9be2f31 100644 --- a/src/common/utils/getTodayDate.jsx +++ b/src/common/utils/getDateStr.jsx @@ -1,15 +1,16 @@ -const getTodayDate = () => { - let today = new Date(); +const getDateStr = (date) => { + let today = new Date(date); + let dd = today.getDate(); let mm = today.getMonth() + 1; let yyyy = today.getFullYear(); if (dd < 10) { - dd += '0'; + dd = '0' + dd; } if (mm < 10) { - mm += '0'; + mm = '0' + mm; } today = `${yyyy}-${mm}-${dd}`; @@ -17,4 +18,4 @@ const getTodayDate = () => { return today; }; -export default getTodayDate; +export default getDateStr; diff --git a/src/common/utils/getDateValidate.jsx b/src/common/utils/getDateValidate.jsx new file mode 100644 index 0000000..0140a24 --- /dev/null +++ b/src/common/utils/getDateValidate.jsx @@ -0,0 +1,41 @@ +const getDateValidate = (date) => { + let checkDate = new Date(date); + let today = new Date(); + + let dd1 = checkDate.getDate(); + let mm1 = checkDate.getMonth() + 1; + let yyyy1 = checkDate.getFullYear(); + + let dd2 = today.getDate(); + let mm2 = today.getMonth() + 1; + let yyyy2 = today.getFullYear(); + console.log(dd1); + console.log(mm1); + if (dd1 < 10) { + dd1 = '0' + dd1; + } + + if (mm1 < 10) { + mm1 = '0' + mm1; + } + + if (dd2 < 10) { + dd2 = '0' + dd2; + } + + if (mm2 < 10) { + mm2 = '0' + mm1; + } + + checkDate = `${yyyy1}-${mm1}-${dd1}`; + today = `${yyyy2}-${mm2}-${dd2}`; + console.log(checkDate); + console.log(today); + // 지정 날짜가 현재 날짜 보다 크면 에러 발생 유도 + const result = checkDate > today; + console.log(result); + + return result; +}; + +export default getDateValidate; diff --git a/src/components/domain/DiaryCreateStepOne/index.jsx b/src/components/domain/DiaryCreateStepOne/index.jsx index 2e291e6..48e0c39 100644 --- a/src/components/domain/DiaryCreateStepOne/index.jsx +++ b/src/components/domain/DiaryCreateStepOne/index.jsx @@ -1,6 +1,11 @@ import styled from '@emotion/styled'; +import { css } from '@emotion/react'; import font from '@assets/fonts'; -import { Input } from '@components/base'; +import DatePicker from 'react-datepicker'; +import { ko } from 'date-fns/esm/locale'; +import color from '@assets/colors'; + +import 'react-datepicker/dist/react-datepicker.css'; const Container = styled.div` margin-top: 80px; @@ -13,23 +18,41 @@ const Title = styled.span` ${font.heading_24}; `; +const InputStyle = css` + display: block; + width: 100%; + box-sizing: border-box; + border: none; + border-bottom: 1px solid ${color.brown}; + background-color: transparent; + color: ${color.black}; + outline: none; + ${font.content_18}; + + &::placeholder { + color: ${color.grey}; + } +`; + const ErrorText = styled.span` margin-top: 5px; font-size: 14px; color: red; `; -const DiaryCreateStepOne = ({ onChange, date, dateError, getTodayDate }) => { +const DiaryCreateStepOne = ({ date, setDate, dateError }) => { return ( 날짜를 선택해주세요. - setDate(date)} + placeholderText="일기 기록 날짜를 입력해주세요 !" + selected={date} + maxDate={new Date()} /> {dateError && {dateError}} diff --git a/src/components/domain/DiaryImages/index.jsx b/src/components/domain/DiaryImages/index.jsx index 5c38202..c3e44a3 100644 --- a/src/components/domain/DiaryImages/index.jsx +++ b/src/components/domain/DiaryImages/index.jsx @@ -45,13 +45,7 @@ const DiaryImages = ({ images }) => { {images.map((image, index) => ( - image + image ))} diff --git a/src/components/domain/Header/index.jsx b/src/components/domain/Header/index.jsx index b2c13e3..10c2c25 100644 --- a/src/components/domain/Header/index.jsx +++ b/src/components/domain/Header/index.jsx @@ -14,7 +14,6 @@ const HeaderContainer = styled.header` z-index: 5; top: 0; left: 0; - right: 0; width: 100%; height: 70px; justify-content: center; @@ -25,11 +24,10 @@ const HeaderContainer = styled.header` `; const HeaderContent = styled.div` - display: -webkit-flex; display: flex; - justify-content: space-between; - -webkit-flex: 1; flex: 1; + width: 100%; + margin: 0; justify-content: ${({ align }) => align}; `; @@ -65,7 +63,7 @@ const Header = ({ {leftComponent} {centerComponent} - {rightComponent} + {rightComponent} ); }; @@ -91,7 +89,6 @@ export const MainHeader = ({ groupTitle, familyMotto, role }) => { } - centerComponent={''} rightComponent={ + {modalContent === '변경되었습니다.' ? ( + handleModalVisible(false, 'back')} + selectable="confirm" + > + {modalContent} + + ) : ( + handleModalVisible(false)} + selectable="confirm" + > + {modalContent} + + )} ); }; diff --git a/src/pages/AlbumSettingsPage/index.jsx b/src/pages/AlbumSettingsPage/index.jsx index 8d86add..03c0ccb 100644 --- a/src/pages/AlbumSettingsPage/index.jsx +++ b/src/pages/AlbumSettingsPage/index.jsx @@ -39,8 +39,8 @@ const AlbumSettingsPage = () => { const navigate = useNavigate(); const albumSettings = (list) => - list.map(({ name, to }) => ( - <> + list.map(({ name, to }, index) => ( +
{ handleToPage(to); @@ -49,7 +49,7 @@ const AlbumSettingsPage = () => { {name} - +
)); const goBack = () => { diff --git a/src/pages/DiaryCreatePage/index.jsx b/src/pages/DiaryCreatePage/index.jsx index d41c066..9f63493 100644 --- a/src/pages/DiaryCreatePage/index.jsx +++ b/src/pages/DiaryCreatePage/index.jsx @@ -14,7 +14,8 @@ import useForm from '@hooks/useForm'; import { postImageUpload } from '@api/postImageUpload'; import { postDiaryCreate } from '@api/postDiaryCreate'; import { getExistenceDiaryDate } from '@api/getExistenceDiaryDate'; -import getTodayDate from '../../common/utils/getTodayDate'; +import getDateValidate from '@utils/getDateValidate'; +import getDateStr from '@utils/getDateStr'; const Conatainer = styled.div` margin-top: 80px; @@ -48,13 +49,13 @@ const DiaryCreatePage = () => { const { values, handleChange } = useForm({ initialValues: { - date: '', title: '', content: '', photos: [], }, }); - const { date, title, content, photos } = values; + const { title, content, photos } = values; + const [date, setDate] = useState(null); const [inputErrors, setInputErrors] = useState({}); const { dateError, titleError, contentError } = inputErrors; @@ -81,7 +82,7 @@ const DiaryCreatePage = () => { })); return; - } else if (date > getTodayDate()) { + } else if (getDateValidate(date)) { setInputErrors((values) => ({ ...values, dateError: '미래의 날짜에 해당하는 일기는 작성할 수 없습니다 !', @@ -91,7 +92,7 @@ const DiaryCreatePage = () => { } else if (date) { const data = { albumId, - date, + date: getDateStr(date), }; try { @@ -231,9 +232,9 @@ const DiaryCreatePage = () => { if (step === 1) { return ( ); diff --git a/src/pages/MemberInvitePage/index.jsx b/src/pages/MemberInvitePage/index.jsx index 31209ae..78c5c4e 100644 --- a/src/pages/MemberInvitePage/index.jsx +++ b/src/pages/MemberInvitePage/index.jsx @@ -79,7 +79,7 @@ const MemberInvitePage = () => { }; const [selectedUsers, setSelectedUsers] = useState([]); const [searchVisible, setSearchVisible] = useState(false); - const [ModalVisible, setModalVisible] = useState(false); + const [modalVisible, setModalVisible] = useState(false); const [searchInfo, setSearchInfo] = useState(initialState); const { albumId } = useParams(); const navigate = useNavigate(); @@ -139,12 +139,12 @@ const MemberInvitePage = () => { navigate('../'); }; - const OpenModal = () => { + const openModal = () => { setModalVisible(true); }; - const CloseModal = () => { - if (ModalVisible) { + const closeModal = () => { + if (modalVisible) { setModalVisible(false); } }; @@ -156,14 +156,14 @@ const MemberInvitePage = () => { targetMemberId: memberId, }); alert('초대가 발송되었습니다.'); - CloseModal(false); + closeModal(false); goBack(); } catch ({ response }) { const { data } = response; data.message = 'DUPLICATION_INVITATION_IN_ALBUM' && alert('이미 초대 요청을 보낸 유저가 포함되어 있습니다.'); - CloseModal(false); + closeModal(false); } }); }; @@ -192,18 +192,18 @@ const MemberInvitePage = () => { )} - {selectedUsers.length === 0 ? ( - + 초대할 인원이 없습니다. ) : ( handleInvite()} > diff --git a/src/pages/ResponseDefaultPage/index.jsx b/src/pages/ResponseDefaultPage/index.jsx index 504cef4..b3b31c0 100644 --- a/src/pages/ResponseDefaultPage/index.jsx +++ b/src/pages/ResponseDefaultPage/index.jsx @@ -57,7 +57,7 @@ const ResponseDefaultPage = ({ resizing }) => {
- 🥲죄송합니다. 저희 서비스는 모바일 환경만 지원합니다. (550px) + 죄송합니다. 저희 서비스는 모바일 환경만 지원합니다. (550px) 현재 사이즈 값은? {resizing}px diff --git a/src/pages/SpecialMomentPage/index.jsx b/src/pages/SpecialMomentPage/index.jsx index 6f6182c..131a5a0 100644 --- a/src/pages/SpecialMomentPage/index.jsx +++ b/src/pages/SpecialMomentPage/index.jsx @@ -72,7 +72,7 @@ const SpinnerWrapper = styled.div` const MomentDefault = styled.div` display: flex; flex-direction: column; - height: 500px; + height: 380px; justify-content: center; align-items: center; ${font.content_18}; @@ -132,7 +132,7 @@ const SpecialMomentPage = () => { {recordedAt.substr(0, 10)} {index} { {momentList.length === 0 && ( 앨범의 특별한 순간이 없습니다! - 일기를 북마크해서 특별한 순간을 만들어보세요. + + 일기를 북마크해서 특별한 순간을 만들어보세요. + )}