Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Feature/subscription 75 ] 구독 & 구독 취소 API 연결 #78

Merged
merged 11 commits into from
Jun 27, 2024

Conversation

soomin9106
Copy link
Collaborator

🔥 Related Issues

resolve #75
close #75

💜 작업 내용

  • 구독과 구독 취소 관련 컴포넌트, 훅, 상수 등을 subscription 으로 이동
  • 구독 API 연결
  • 구독 취소 API 연결
  • /workbook 으로 접속시 /workbook/1 로 이동할 수 있도록 미들웨어 수정

✅ PR Point

  • 컴포넌트나 기능등의 의미 통일성이 더 있을 것 같아서 subscription 폴더를 하나 파서 구독 및 구독취소 코드들을 마이그레이션 했습니다.
  • 구독 POST 훅을 짜서 API 테스트 완료했습니다!
  • 구독 취소 POST 훅을 짜서 API 테스트 완료했습니다!

@soomin9106 soomin9106 self-assigned this Jun 27, 2024
Copy link
Collaborator

@Happhee Happhee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

역싀 빠르게 작업해주시는 숨니 멋집니다!!

@@ -20,16 +24,32 @@ export const useUnsubscribeForm = () => {
},
});

const { mutate: unsubscribeWorkbook } = useMutation(unsubscribeWorkbookOptions());

const onSubmit = (values: UnsubscribeFormData) => {
try {
const result = unSubscribeSchema.safeParse(values);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

근데 이거 제출할때 zod가 유효성 검사 해주지 않나요?! 왜 한번더 진행하는걸까욥..?

UnsubscribeBody
> => {
return {
mutationKey: [QUERY_KEY.UNSUBSCRIBE_WORKBOOK],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

body값에 있는 email 키를 넣어서 mutation key를 유효하게 만드는건 어떤가욥...?

export const getCookie = (name: string) => {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop()?.split(";").shift();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

조건문에 해당되지 않을때 반환하는게 있다면 더 명시적일것같습니다..!

useEffect(function getId() {
return setWorkbookId(getWorkbookId(pathname));
}, [pathname])

const form = useForm<EmailSubscribeFormData>({
resolver: zodResolver(emailSubscribeSchema),
defaultValues: {
email: '',
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mode를 설정해주면 될것같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 이거 설명해주실 수 있나용❔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useForm zod mode 참고해보시면, 굳이 submit 함수 실행할때 safeparse 체크하지 않아도 검증 가능합니다..!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9553999

오오 !! 참고해서 수정했습니다! useForm 에서 이미 유효성 검사 처리가 가능하군용 💯

@@ -21,6 +21,12 @@ export default function middleware(req: NextRequest) {
const nextUrl = req.nextUrl.clone();
const email = nextUrl.searchParams.get("user");

/** /workbook 으로 진입 시 리다이랙션 */
if (nextUrl.pathname === "/workbook") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서 구조분해 할당하면 pathname으로도 가져올수있겟네요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c74e82c

사용해봤습니다..!

@@ -21,6 +21,12 @@ export default function middleware(req: NextRequest) {
const nextUrl = req.nextUrl.clone();
const email = nextUrl.searchParams.get("user");

/** /workbook 으로 진입 시 리다이랙션 */
if (nextUrl.pathname === "/workbook") {
nextUrl.pathname = "/workbook/1";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에는 다른 workbook 페이지가 될수도 있을것같습니다...!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞아요!! 이 부분은 한 번 말해봐야겠네용!!

}

export interface MessageOnlyResponse extends Pick<ApiResponse<any>, 'message'> {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type으로 선언하면 { } 괄호가 필요없을것같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit 사용해서 type 으로 수정했습니당 👍

@soomin9106 soomin9106 merged commit c82515a into develop Jun 27, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants