-
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.
feat: add previews to add page, chore: clean up admin pages, chore: f…
…ix centering
- Loading branch information
1 parent
1b5fc5e
commit 37579af
Showing
6 changed files
with
147 additions
and
96 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { deleteJSONData, postJSONData } from "./api"; | ||
import { Video } from "./types"; | ||
|
||
async function addVideo(video: Video) { | ||
const VITE_PUBLIC_API_URL = import.meta.env.VITE_PUBLIC_API_URL; | ||
const VITE_PUBLIC_CLERK_SIGN_IN_URL = import.meta.env.VITE_PUBLIC_CLERK_SIGN_IN_URL; | ||
const name = video.name; | ||
const description = video.description; | ||
const category = video.category; | ||
const thumbnailURL = video.thumbnailURL; | ||
const videoURL = video.videoURL; | ||
const urlName = video.urlName; | ||
const ageRating = video.rating; | ||
const data = await postJSONData(`${VITE_PUBLIC_API_URL}/videoAPI/add`, { | ||
userId: localStorage.getItem("userId") || "", | ||
sessionId: localStorage.getItem("sessionId") || "", | ||
name, | ||
description, | ||
category, | ||
thumbnailURL, | ||
videoURL, | ||
urlName, | ||
ageRating, | ||
}); | ||
if (data.status !== "success") { | ||
window.location.href = VITE_PUBLIC_CLERK_SIGN_IN_URL; | ||
return; | ||
} | ||
window.location.href = "/admin"; | ||
} | ||
|
||
async function deleteVideo(urlName: string, setStatus: any) { | ||
const VITE_PUBLIC_API_URL = import.meta.env.VITE_PUBLIC_API_URL; | ||
const userId = localStorage.getItem("userId"); | ||
const sessionId = localStorage.getItem("sessionId"); | ||
setStatus("Removing..."); | ||
try { | ||
const responce = await deleteJSONData(`${VITE_PUBLIC_API_URL}/videoAPI/delete`, { | ||
urlName: urlName, | ||
userId: userId, | ||
sessionId: sessionId, | ||
}); | ||
if (responce.status === "success") { | ||
window.location.href = "/admin"; | ||
} else { | ||
setStatus("Failed to remove!"); | ||
} | ||
} catch (e: any) { | ||
setStatus("Failed to remove!"); | ||
} | ||
} | ||
|
||
export { addVideo, deleteVideo }; |