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.
deleted seniors, request, and chapter
- Loading branch information
1 parent
4a3fe98
commit 31ab487
Showing
6 changed files
with
93 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { DeleteChapterResponse } from "./route.schema"; | ||
|
||
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); | ||
}; |
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,23 @@ | ||
import { z } from "zod"; | ||
|
||
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"), | ||
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
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