-
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
554bc66
refactor: divide subscription and workbook
soomin9106 f50ec61
refactor: migrate subscribe bottom bar main to subscription
soomin9106 54ec84d
feat: redirect /workbook to /workbook/1
soomin9106 4293852
chore: add github domain in next js image
soomin9106 b6f9609
feat: subscribe API 연결
soomin9106 a2c81b9
feat: unsubscribe API
soomin9106 68edba2
chore: change file name
soomin9106 dd5e9b1
refactor: interface to type using Omit
soomin9106 6aac329
refactor: return if conditional statement is not met
soomin9106 c74e82c
refactor: use destructuring assignment
soomin9106 9553999
refactor: add onSubmit mode and remove safeParse
soomin9106 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const API_ROUTE = { | ||
SUBSCRIBE: (workbookId: string) => `/api/v1/workbooks/${workbookId}/subs`, | ||
}; | ||
export const QUERY_KEY = { | ||
SUBSCRIBE_WORKBOOK: "sub-workbook", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { UseMutationOptions } from "@tanstack/react-query"; | ||
|
||
import { ApiResponse, axiosRequest } from "@api/api-config"; | ||
|
||
import { | ||
MessageOnlyResponse, | ||
SubscribeBody, | ||
SubscribeParams, | ||
} from "@subscription/types/subscription"; | ||
|
||
import { API_ROUTE, QUERY_KEY } from "./api"; | ||
|
||
export const subscribeWorkbook = ( | ||
params: SubscribeParams, | ||
body: SubscribeBody, | ||
): Promise<ApiResponse<MessageOnlyResponse>> => { | ||
return axiosRequest("post", API_ROUTE.SUBSCRIBE(params.workbookId), body); | ||
}; | ||
|
||
export const subscribeWorkbookOptions = ( | ||
params: SubscribeParams | ||
): UseMutationOptions< | ||
ApiResponse<MessageOnlyResponse>, | ||
Error, | ||
SubscribeBody | ||
> => { | ||
return { | ||
mutationKey: [QUERY_KEY.SUBSCRIBE_WORKBOOK, params.workbookId], | ||
mutationFn: (body) => subscribeWorkbook(params, body) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
import { z } from "zod" | ||
|
||
import { UNSUBSCRIBE_FORM } from "@workbook/constants/unsubscribe" | ||
import { EMAIL_CONTROL } from "@subscription/constants/main" | ||
import { UNSUBSCRIBE_FORM } from "@subscription/constants/unsubscribe" | ||
|
||
export const unSubscribeSchema = z.object({ | ||
opinion: z | ||
.string() | ||
.max(255, { message: UNSUBSCRIBE_FORM.WORD_LIMIT }) | ||
|
||
}) | ||
|
||
export const emailSubscribeSchema = z.object({ | ||
email: z | ||
.string() | ||
.min(1, { message: EMAIL_CONTROL.INVALID_EMAIL }) | ||
.email(EMAIL_CONTROL.INVALID_EMAIL) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
import { z } from "zod"; | ||
|
||
import { unSubscribeSchema } from "@subscription/schemas"; | ||
import { ApiResponse } from "@api/api-config"; | ||
|
||
export type UnsubscribeFormData = z.infer<typeof unSubscribeSchema>; | ||
import { emailSubscribeSchema, unSubscribeSchema } from "@subscription/schemas"; | ||
|
||
export type variantType = "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | ||
export type EmailSubscribeFormData = z.infer<typeof emailSubscribeSchema>; | ||
|
||
export type UnsubscribeFormData = z.infer<typeof unSubscribeSchema>; | ||
|
||
export type SubscribeParams = { | ||
workbookId: string; | ||
} | ||
|
||
export type SubscribeBody = { | ||
email: string | ||
} | ||
|
||
export interface MessageOnlyResponse extends Pick<ApiResponse<any>, 'message'> {} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 으로 수정했습니당 👍