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

클라이언트 API 호출 함수 추가 #149

Merged
merged 1 commit into from
Dec 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions frontend/src/utils/blockApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,34 @@ export const deletePageCascade = (blockId: string) =>
method: 'DELETE',
defaultReturn: { parent: null },
})();

type CreateAndUpdateBody = {
create: {
parentId: string;
index?: number;
blockDTO?: { type?: string; value?: string };
};
update: Block | null;
};

export const createAndUpdate = (param: CreateAndUpdateBody) =>
fetchApi<
{ parent: Block; block: Block; updated: Block },
CreateAndUpdateBody
>({
url: `${BASE_URL}/create-and-update`,
method: 'PATCH',
defaultReturn: { parent: null, block: null, updated: null },
})(param);

type DeleteAndUpdateBody = {
deleteId: string;
update: Block | null;
};

export const deleteAndUpdate = (param: DeleteAndUpdateBody) =>
fetchApi<{ parent: Block; updated: Block }, DeleteAndUpdateBody>({
url: `${BASE_URL}/delete-and-update`,
method: 'PATCH',
defaultReturn: { parent: null, updated: null },
})(param);