-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body값에 있는 email 키를 넣어서 mutation key를 유효하게 만드는건 어떤가욥...?
src/subscription/utils/index.ts
Outdated
export const getCookie = (name: string) => { | ||
const value = `; ${document.cookie}`; | ||
const parts = value.split(`; ${name}=`); | ||
if (parts.length === 2) return parts.pop()?.split(";").shift(); |
There was a problem hiding this comment.
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: '', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode를 설정해주면 될것같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 이거 설명해주실 수 있나용❔
There was a problem hiding this comment.
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 체크하지 않아도 검증 가능합니다..!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오 !! 참고해서 수정했습니다! useForm 에서 이미 유효성 검사 처리가 가능하군용 💯
src/middleware.ts
Outdated
@@ -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") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에서 구조분해 할당하면 pathname으로도 가져올수있겟네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용해봤습니다..!
@@ -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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
나중에는 다른 workbook 페이지가 될수도 있을것같습니다...!
There was a problem hiding this comment.
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'> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type으로 선언하면 { } 괄호가 필요없을것같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit 사용해서 type 으로 수정했습니당 👍
🔥 Related Issues
resolve #75
close #75
💜 작업 내용
/workbook
으로 접속시/workbook/1
로 이동할 수 있도록 미들웨어 수정✅ PR Point