()
| 71 | }; |
| 72 | |
| 73 | const handleContentSubmit = async () => { |
| 74 | setLoading(true); |
| 75 | if (type === "appx") { |
| 76 | //@ts-ignore |
| 77 | metadata.appxVideoJSON = formatInputJSON(metadata.appxVideoJSON); |
| 78 | //@ts-ignore |
| 79 | if (!validateJSON(metadata.appxVideoJSON)) { |
| 80 | toast.error("Invalid JSON"); |
| 81 | setLoading(false); |
| 82 | return; |
| 83 | } |
| 84 | } |
| 85 | const response = await fetch('/api/admin/content', { |
| 86 | body: JSON.stringify({ |
| 87 | type, |
| 88 | thumbnail: imageUri, |
| 89 | title, |
| 90 | courseId, |
| 91 | parentContentId, |
| 92 | //* Metadata will be list of resolutions for normal videos and appxVideoId for appx videos |
| 93 | metadata, |
| 94 | adminPassword, |
| 95 | courseTitle, |
| 96 | rest, |
| 97 | discordChecked, |
| 98 | }), |
| 99 | method: 'POST', |
| 100 | headers: { |
| 101 | 'Content-Type': 'application/json', |
| 102 | }, |
| 103 | }); |
| 104 | const responseData = await response.json(); |
| 105 | setLoading(false); |
| 106 | if (response.status === 200) { |
| 107 | // handle success if needed |
| 108 | toast.success(responseData.message); |
| 109 | setTrigger((prev) => prev + 1); // why? trigger a re-render, this is a hack |
| 110 | setMetadata({}); |
| 111 | } else { |
| 112 | // handle error if needed |
| 113 | toast.error(responseData.message || 'Something went wrong'); |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | return ( |
| 118 | <div className="grid grid-cols-1 gap-4 rounded-xl border-2 p-6 lg:grid-cols-7"> |
nothing calls this directly
no test coverage detected