feat: request on api
CI / 🔍 Lint & Type Check (push) Successful in 1m5s
CI / 🐳 Build & Push Image (push) Successful in 17s

This commit is contained in:
2026-07-10 23:07:43 +02:00
parent 1e85e66bc2
commit 0a289b6c23
3 changed files with 11 additions and 11 deletions
+1
View File
@@ -1 +1,2 @@
DISCORD_WHITELIST_WEBHOOK_URL=""
NEXT_PUBLIC_API_URL="https://api.leonmorival.xyz"
+9 -11
View File
@@ -1,6 +1,7 @@
"use client";
import { FormEvent, useState } from "react";
import { siteConfig } from "../lib/server-config";
type FormStatus = {
tone: "success" | "error";
@@ -19,29 +20,27 @@ export default function MinecraftWhitelistForm() {
const formData = new FormData(form);
const payload = {
username: String(formData.get("username") ?? ""),
reason: String(formData.get("reason") ?? ""),
game_username: String(formData.get("username") ?? ""),
message: String(formData.get("reason") ?? ""),
server_slug: "minecraft",
};
try {
const response = await fetch("/api/minecraft/whitelist/request", {
const response = await fetch(`${siteConfig.apiUrl}/api/access-requests`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
const result = (await response.json()) as {
ok?: boolean;
message?: string;
};
if (!response.ok || !result.ok) {
if (!response.ok) {
const result = await response.json().catch(() => ({})) as { message?: string };
throw new Error(result.message ?? "Demande refusée.");
}
form.reset();
setStatus({
tone: "success",
message: result.message ?? "Demande envoyée.",
message: "Demande envoyée.",
});
} catch (error) {
setStatus({
@@ -78,8 +77,7 @@ export default function MinecraftWhitelistForm() {
<textarea
id="minecraft-reason"
name="reason"
minLength={10}
maxLength={800}
maxLength={255}
rows={5}
placeholder="Je voudrais rejoindre le serveur..."
required
+1
View File
@@ -5,6 +5,7 @@ export const siteConfig = {
jellyfinUrl: "https://momostreaming.com",
minecraftPath: "/minecraft",
astroneerPath: "/astroneer",
apiUrl: process.env.NEXT_PUBLIC_API_URL ?? "",
};
export const minecraftServer = {