GAHHH I BROKE IT
This commit is contained in:
parent
1075e0a995
commit
85e70157ad
1 changed files with 104 additions and 94 deletions
|
@ -1,4 +1,4 @@
|
||||||
import {createSignal, onMount} from "solid-js"
|
import { createSignal, onMount } from "solid-js";
|
||||||
import { ishover } from "../App";
|
import { ishover } from "../App";
|
||||||
|
|
||||||
interface Review {
|
interface Review {
|
||||||
|
@ -10,49 +10,52 @@ interface Review {
|
||||||
|
|
||||||
interface NeoReview extends Review {
|
interface NeoReview extends Review {
|
||||||
global_name: string;
|
global_name: string;
|
||||||
username: string
|
username: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default function Reviews() {
|
export default function Reviews() {
|
||||||
const [reviews, setReviews] = createSignal<NeoReview[]>([]);
|
const [reviews, setReviews] = createSignal<NeoReview[]>([]);
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
fetch("https://review.exhq.dev/getreviews")
|
fetch("https://review.exhq.dev/getreviews")
|
||||||
.then(response => response.json())
|
.then((response) => response.json())
|
||||||
.then((data: Review[]) => {
|
.then((data: Review[]) => {
|
||||||
const promises = data.map(review => (
|
const promises = data.map((review) =>
|
||||||
fetch(`https://dc-lookup.spiro.exhq.dev/v1/user/${review.discordID}`)
|
fetch(`https://dc-lookup.spiro.exhq.dev/v1/user/${review.discordID}`)
|
||||||
.then(response => response.json())
|
.then((response) => response.json())
|
||||||
.then(user => ({
|
.then((user) => ({
|
||||||
...review,
|
...review,
|
||||||
global_name: user.global_name,
|
global_name: user.global_name,
|
||||||
username: user.username
|
username: user.username,
|
||||||
}))
|
})),
|
||||||
));
|
);
|
||||||
|
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(yeah => {
|
.then((yeah) => {
|
||||||
setReviews(yeah);
|
setReviews(yeah);
|
||||||
})
|
})
|
||||||
.catch(error => console.error("Error fetching Discord user data:", error));
|
.catch((error) =>
|
||||||
|
console.error("Error fetching Discord user data:", error),
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch(error => console.error("Error fetching reviews:", error));
|
.catch((error) => console.error("Error fetching reviews:", error));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<a style={{
|
<a
|
||||||
display: ishover() ? "inline" : "none"
|
style={{
|
||||||
|
display: ishover() ? "inline" : "none",
|
||||||
}}
|
}}
|
||||||
href="https://discord.com/oauth2/authorize?client_id=1208380910525743134&response_type=token&redirect_uri=https%3A%2F%2Fexhq.dev%2Freview%2F&scope=identify">
|
href="https://discord.com/oauth2/authorize?client_id=1208380910525743134&response_type=code&redirect_uri=https%3A%2F%2Famy.rip%2Freview%2F&scope=identify"
|
||||||
|
>
|
||||||
<p class="fadein">add your reviews here</p>
|
<p class="fadein">add your reviews here</p>
|
||||||
</a>
|
</a>
|
||||||
<h1 class="reviewheadertext">Reviews</h1>
|
<h1 class="reviewheadertext">Reviews</h1>
|
||||||
<div
|
<div class="actualreviewdiv">
|
||||||
class="actualreviewdiv">
|
|
||||||
{reviews().length > 0 ? (
|
{reviews().length > 0 ? (
|
||||||
reviews().reverse().map((review) => (
|
reviews()
|
||||||
|
.reverse()
|
||||||
|
.map((review) => (
|
||||||
<div>
|
<div>
|
||||||
<SingleReview {...review} />
|
<SingleReview {...review} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,13 +65,14 @@ export default function Reviews() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
);
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const theImager = async (id: string): Promise<string> =>
|
||||||
export const theImager = async (id: string): Promise<string> => (await fetch(`https://dc-lookup.spiro.exhq.dev/v1/user/${id}`)
|
await fetch(`https://dc-lookup.spiro.exhq.dev/v1/user/${id}`)
|
||||||
.then(res => res.json()).then(data => "https://proxy.spiro.exhq.dev/_/plain/"+data.avatar.link).catch(() => "https://http.cat/status/100"));
|
.then((res) => res.json())
|
||||||
|
.then((data) => "https://proxy.spiro.exhq.dev/_/plain/" + data.avatar.link)
|
||||||
|
.catch(() => "https://http.cat/status/100");
|
||||||
|
|
||||||
function SingleReview(props: NeoReview) {
|
function SingleReview(props: NeoReview) {
|
||||||
const [imageSrc, setImageSrc] = createSignal("");
|
const [imageSrc, setImageSrc] = createSignal("");
|
||||||
|
@ -95,14 +99,20 @@ function SingleReview(props: NeoReview) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function sendReview(review: string, token: string): Promise<boolean> {
|
export async function sendReview(
|
||||||
|
review: string,
|
||||||
|
token: string,
|
||||||
|
): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`https://review.exhq.dev/sendreview?review=${review}`, {
|
const response = await fetch(
|
||||||
|
`https://review.exhq.dev/sendreview?review=${review}`,
|
||||||
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Auth": token,
|
Auth: token,
|
||||||
},
|
},
|
||||||
method: "POST"
|
method: "POST",
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue