1
0
Fork 0
amy.rip/review/App.tsx

69 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-12-24 19:55:44 +01:00
import "../src/App.css";
import "./reviewed.css";
import { sendReview } from "../src/components/api";
2024-12-24 14:02:54 +01:00
export default function App() {
2024-12-24 19:55:44 +01:00
const token = window.location.hash
.substring(
window.location.hash.indexOf("access_token") + "access_token".length + 1,
)
.substring(0, 30);
console.log(token);
if (token === "") {
window.location.href =
2024-12-24 20:01:16 +01:00
"https://discord.com/oauth2/authorize?client_id=1208380910525743134&response_type=token&redirect_uri=https%3A%2F%2Famy.rip%2Freview%2F&scope=identify";
2024-12-24 19:55:44 +01:00
}
let ref!: HTMLTextAreaElement;
return (
<div class="reviewOuterparent">
<div class="reviewParent">
<img src="../fjonkie.png" alt="" />
<span>(it doesnt)</span>
<textarea
ref={ref}
onKeyPress={async (e) => {
if (e.key === "Enter") {
e.preventDefault();
if (await sendReview(ref.value, token)) {
alert("review sent!");
} else {
alert(
"something went wrong, check your network tab or something idfk",
);
}
}
}}
2024-12-24 20:03:17 +01:00
placeholder="your review"
2024-12-24 19:55:44 +01:00
class="reviewText"
name=""
id=""
cols="25"
rows="3"
></textarea>
2024-12-24 14:02:54 +01:00
2024-12-24 19:55:44 +01:00
<div class="flexButton">
<button
onclick={async () => {
try {
const success = await sendReview(ref.value, token);
if (success) {
alert("Review sent successfully!");
} else {
alert(
"Failed to send review. open your browser's network tab for more info lmao",
);
}
} catch (error) {
alert("how");
}
}}
class="sendButton"
>
2024-12-24 20:03:17 +01:00
send your review
2024-12-24 19:55:44 +01:00
</button>
2024-12-24 14:02:54 +01:00
</div>
2024-12-24 19:55:44 +01:00
</div>
2024-12-24 14:02:54 +01:00
</div>
2024-12-24 19:55:44 +01:00
);
2024-12-24 14:02:54 +01:00
}