diff --git a/src/modules/SelsoList/SelsoList.jsx b/src/modules/SelsoList/SelsoList.jsx index 33020fc..f47da7d 100644 --- a/src/modules/SelsoList/SelsoList.jsx +++ b/src/modules/SelsoList/SelsoList.jsx @@ -5,13 +5,14 @@ import Modal from 'src/components/Modal'; import SelsoItemCard from './SelsoItemCard'; import styles from './SelsoList.module.scss'; -import { selsoCost } from 'src/constants/costs'; const SelsoList = inject('selsoListStore', 'userStore', 'myPointStore')( - observer(({ selsoListStore, userStore, myPointStore, history }) => { + observer(({ selsoListStore, userStore, history }) => { const [isOpenSpendPointModal, setIsOpenSpendPointModal] = useState(false); const [isOpenPointLackModal, setIsOpenPointLackModal] = useState(false); - + const [isOpenHaveNotSelsoProfileModal, setIsOpenHaveNotSelsoProfileModal] = useState(false); + const [isOpenNotActiveSelsoProfileModal, setIsOpenNotActiveSelsoProfileModal] = useState(false); + useEffect(() => { if (userStore.profile?.gender && userStore.profile?.university) { if (userStore.profile.gender === 'MALE') { @@ -23,22 +24,40 @@ const SelsoList = inject('selsoListStore', 'userStore', 'myPointStore')( }, [userStore.profile?.gender, userStore.profile?.university]); const moveToDetailPageHandler = (selsoItem) => (_e) => { - selsoListStore.setChoosedSelso(selsoItem); + selsoListStore.getMySelsoProfile() + .then((res) => { + if (res.status === 404) { + setIsOpenHaveNotSelsoProfileModal(true); + } else if (res.status === 200) { + selsoListStore.setChoosedSelso(selsoItem); - if (selsoItem.isViewed) { - history.push('selso/detail'); - } else { - setIsOpenSpendPointModal(true); - } + if (selsoItem.isViewed) { + selsoListStore.fetchSelsoDetail() + .then((res) => { + if (res.status === 200) { + history.push('selso/detail'); + } else if (res.status === 403) { + setIsOpenNotActiveSelsoProfileModal(true); + } + }); + } else { + setIsOpenSpendPointModal(true); + } + } + }); }; const spendPointAndMoveToDetailPage = () => { - if (myPointStore.restPoint >= selsoCost.ViewProfileDetail) { - history.push('selso/detail'); - } else { - setIsOpenSpendPointModal(false); - setIsOpenPointLackModal(true); - } + selsoListStore.fetchSelsoDetail() + .then((res) => { + if (res.status === 200) { + selsoListStore.root.myPointStore.fetchMyPointHistory(); + history.push('selso/detail'); + } else if (res.status === 403) { + setIsOpenSpendPointModal(false); + setIsOpenPointLackModal(true); + } + }); }; return ( @@ -49,18 +68,62 @@ const SelsoList = inject('selsoListStore', 'userStore', 'myPointStore')( )) - } - setIsOpenPointLackModal(false)} + } + setIsOpenPointLackModal(false)} + > + 포인트가 부족합니다. 학교 인증이 완료되면 30포인트가 지급됩니다. + 학생증 이미지를 업로드하지 않으신 분은 회원가입 마무리를 해주세요. 이미지를 확인하고 포인트를 지급하는 데 시간이 걸릴 수 있습니다. + + setIsOpenHaveNotSelsoProfileModal(false)} + buttonList={[ + history.push('/user/register')} > - 포인트가 부족합니다. 학교 인증이 완료되면 30포인트가 지급됩니다. - 학생증 이미지를 업로드하지 않으신 분은 회원가입 마무리를 해주세요. 이미지를 확인하고 포인트를 지급하는 데 시간이 걸릴 수 있습니다. - - setIsOpenSpendPointModal(false)} - buttonList={[ + 등록하기 + , + setIsOpenHaveNotSelsoProfileModal(false)} + > + 취소 + , + ]} + > + 셀소 프로필 등록 후 이용해주세요. + + setIsOpenNotActiveSelsoProfileModal(false)} + buttonList={[ + history.push('my/profile')} + > + 공개하기 + , + setIsOpenNotActiveSelsoProfileModal(false)} + > + 취소 + , + ]} + > + 셀소 프로필을 공개 후 이용해주세요. + + setIsOpenSpendPointModal(false)} + buttonList={[ { - if (selsoListStore.choosedSelso) { - // choosed selso 값이 없을 경우 fetchSelsoDetail function이 undefined를 반환하여 callback을 사용할 수 없다. - selsoListStore.fetchSelsoDetail() - .then((res) => { - if (res?.status === 200) { - selsoListStore.root.myPointStore.fetchMyPointHistory(); - } - }); - } - }, [selsoListStore.choosedSelso]); - const getOpenKakaoLink = async () => { const chatLink = await selsoListStore.fetchOpenKakaoLink(selsoListStore.fetchedSelsoDetail.id) .then((res) => { diff --git a/src/stores/SelsoListStore.js b/src/stores/SelsoListStore.js index d4aef6d..217e458 100644 --- a/src/stores/SelsoListStore.js +++ b/src/stores/SelsoListStore.js @@ -36,8 +36,21 @@ export default class SelsoListStore { .then((res) => { this.mySelsoProfile = res.data; return res; - }) - .catch((err) => err); + }).catch((err) => { + if (err.response) { + return { + status: err.response.status, + message: err.response.statusText, + data: err.response.data, + }; + } + + return { + status: null, + message: 'unknown error', + data: {}, + }; + }); @action setMySelsoProfile = (type, value) => { this.mySelsoProfile[type] = value @@ -105,7 +118,21 @@ export default class SelsoListStore { status: res.status, message: res.statusText, }; - }); + }).catch((err) => { + if (err.response) { + return { + status: err.response.status, + message: err.response.statusText, + data: err.response.data, + }; + } + + return { + status: null, + message: 'unknown error', + data: {}, + }; + }) } };
포인트가 부족합니다. 학교 인증이 완료되면 30포인트가 지급됩니다.
학생증 이미지를 업로드하지 않으신 분은 회원가입 마무리를 해주세요. 이미지를 확인하고 포인트를 지급하는 데 시간이 걸릴 수 있습니다.
셀소 프로필 등록 후 이용해주세요.
셀소 프로필을 공개 후 이용해주세요.