Skip to content

Commit

Permalink
feat: 커피챗 예외처리 (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
seojisoosoo authored Nov 4, 2024
1 parent 05189ce commit a3e5be6
Showing 1 changed file with 16 additions and 33 deletions.
49 changes: 16 additions & 33 deletions src/pages/coffeechat/edit/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const CoffeechatEdit = () => {
type: 'single',
typeOptions: {
approveButtonText: '확인',
buttonFunction: async () => await router.push(playgroundLink.coffeechat()),
buttonFunction: async () => router.push(playgroundLink.coffeechat()),
},
};
open(option);
Expand All @@ -69,37 +69,21 @@ const CoffeechatEdit = () => {
);
};

// FIXME: url에서 직접 id 변경하여 접속하는 경우, 다른 사람의 커피챗 수정 불가능하도록 막기
// useEffect(() => {
// if (memberId !== String(me?.id)) {
// open({
// title: '다른 사람의 커피챗은 수정할 수 없어요',
// description: ``,
// type: 'single',
// typeOptions: {
// approveButtonText: '확인',
// buttonFunction: async () => await router.push(playgroundLink.coffeechat()),
// },
// });
// }
// }, [me?.id, memberId, open, router]);

// FIXME: 존재하지 않는 커피챗 id 접속
// useEffect(() => {
// if (isError) {
// const axiosError = error as AxiosError;

// open({
// title: `${axiosError?.response?.data}`,
// description: ``,
// type: 'single',
// typeOptions: {
// approveButtonText: '확인',
// buttonFunction: async () => await router.push(playgroundLink.coffeechat()),
// },
// });
// }
// }, [error, isError, open, router]);
if (status === 'loading' || status === 'error') return null;

// MEMO: url에서 직접 id 변경하여 접속하는 경우, 다른 사람의 커피챗 수정 불가능하도록 막기
if (status === 'success' && memberId && me?.id && memberId !== String(me?.id)) {
router.push(playgroundLink.coffeechat());

return null;
}

// MEMO: 존재하지 않는 커피챗 id 접속
if (status === 'success' && isError) {
router.push(playgroundLink.coffeechat());

return null;
}

const defaultForm = {
memberInfo: {
Expand All @@ -122,7 +106,6 @@ const CoffeechatEdit = () => {

return (
<AuthRequired>
{(status === 'loading' || status === 'error') && null}
{status === 'success' && openerProfile && memberId === String(me?.id) && !isError ? (
<CoffeechatUploadPage uploadType='수정' form={defaultForm} onSubmit={onSubmit} />
) : null}
Expand Down

0 comments on commit a3e5be6

Please sign in to comment.