Replace discord admin fetches and add API_BASE
cgen-ec0f7cd2ccf645de821c45f9cac147dd
This commit is contained in:
parent
5452adf1ed
commit
bca29e4a21
1 changed files with 7 additions and 4 deletions
|
|
@ -24,6 +24,9 @@ import {
|
||||||
type BotHealthStatus,
|
type BotHealthStatus,
|
||||||
} from "../../lib/discord-bot-status";
|
} from "../../lib/discord-bot-status";
|
||||||
|
|
||||||
|
// API Base URL for fetch requests
|
||||||
|
const API_BASE = import.meta.env.VITE_API_BASE || "";
|
||||||
|
|
||||||
interface RoleMapping {
|
interface RoleMapping {
|
||||||
id: string;
|
id: string;
|
||||||
arm: string;
|
arm: string;
|
||||||
|
|
@ -83,7 +86,7 @@ export function AdminDiscordManagement() {
|
||||||
const fetchMappings = async () => {
|
const fetchMappings = async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await fetch("/api/discord/role-mappings");
|
const response = await fetch(`${API_BASE}/api/discord/role-mappings`);
|
||||||
|
|
||||||
// Read body only once
|
// Read body only once
|
||||||
let data: any;
|
let data: any;
|
||||||
|
|
@ -123,7 +126,7 @@ export function AdminDiscordManagement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/api/discord/role-mappings", {
|
const response = await fetch(`${API_BASE}/api/discord/role-mappings`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify(newMapping),
|
body: JSON.stringify(newMapping),
|
||||||
|
|
@ -154,7 +157,7 @@ export function AdminDiscordManagement() {
|
||||||
|
|
||||||
const handleDeleteMapping = async (id: string) => {
|
const handleDeleteMapping = async (id: string) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/discord/role-mappings?id=${id}`, {
|
const response = await fetch(`${API_BASE}/api/discord/role-mappings?id=${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -190,7 +193,7 @@ export function AdminDiscordManagement() {
|
||||||
|
|
||||||
console.log("[Discord] Registering commands with token...");
|
console.log("[Discord] Registering commands with token...");
|
||||||
|
|
||||||
const response = await fetch("/api/discord/admin-register-commands", {
|
const response = await fetch(`${API_BASE}/api/discord/admin-register-commands`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue