forked from JumboCode/TheLegacyProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Nick Doan <[email protected]>
- Loading branch information
1 parent
31ab487
commit 59d9361
Showing
5 changed files
with
20 additions
and
53 deletions.
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 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,9 @@ | ||
import { DeleteChapterResponse } from "./route.schema"; | ||
import { deleteChapterResponse } from "./route.schema"; | ||
|
||
export const DeleteChapter = async (chapterId: string) => { | ||
export const deleteChapter = async (chapterId: string) => { | ||
const response = await fetch(`/api/chapter/${chapterId}`, { | ||
method: "DELETE", | ||
}); | ||
const json = await response.json(); | ||
console.log(json); | ||
return DeleteChapterResponse.parse(json); | ||
return deleteChapterResponse.parse(json); | ||
}; |
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,23 +1,14 @@ | ||
import { z } from "zod"; | ||
|
||
export const DeleteChapterResponse = z.discriminatedUnion("code", [ | ||
export const deleteChapterResponse = z.discriminatedUnion("code", [ | ||
z.object({ | ||
code: z.literal("SUCCESS"), | ||
message: z.literal("The chapter was successfully deleted"), | ||
}), | ||
|
||
z.object({ | ||
code: z.literal("INVALID_CHAPTER_ID"), | ||
code: z.literal("CHAPTER_NOT_FOUND"), | ||
message: z.literal("The chapter id could not be found"), | ||
}), | ||
|
||
z.object({ | ||
code: z.literal("INVALID_REQUEST"), | ||
data: z.literal("The request was invalid"), | ||
}), | ||
|
||
z.object({ | ||
code: z.literal("UNKNOWN"), | ||
data: z.any(), | ||
}), | ||
]); |
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