Migrace sestavování klienta na Vite

This commit is contained in:
2024-12-11 22:54:57 +01:00
parent b0d8a1a830
commit 18f2b72133
16 changed files with 5786 additions and 11889 deletions

View File

@@ -1,15 +1,3 @@
/**
* Vrátí kořenovou URL serveru na základě aktuálního prostředí (vývojovou či produkční).
*
* @returns kořenová URL serveru
*/
export const getBaseUrl = (): string => {
if (process.env.PUBLIC_URL) {
return process.env.PUBLIC_URL;
}
return 'http://127.0.0.1:3001';
}
const TOKEN_KEY = "token";
/**

View File

@@ -1,5 +1,5 @@
import { toast } from "react-toastify";
import { getBaseUrl, getToken } from "../Utils";
import { getToken } from "../Utils";
/**
* Wrapper pro volání API, u kterých chceme automaticky zobrazit toaster s chybou ze serveru.
@@ -23,7 +23,7 @@ async function request<TResponse>(
config.headers = config?.headers ? new Headers(config.headers) : new Headers();
config.headers.set("Authorization", `Bearer ${getToken()}`);
try {
const response = await fetch(getBaseUrl() + url, config);
const response = await fetch(url, config);
if (!response.ok) {
// TODO tohle je blbě, jelikož automaticky očekáváme, že v případě chyby přijde vždy JSON, což není pravda
const json = await response.json();
@@ -48,7 +48,7 @@ async function blobRequest(
config.headers = config?.headers ? new Headers(config.headers) : new Headers();
config.headers.set("Authorization", `Bearer ${getToken()}`);
try {
const response = await fetch(getBaseUrl() + url, config);
const response = await fetch(url, config);
if (!response.ok) {
const json = await response.json();
// Vyhodíme samotnou hlášku z odpovědi, odchytí si jí errorHandler
@@ -67,7 +67,7 @@ export const api = {
}
export const getQrUrl = (login: string) => {
return `${getBaseUrl()}/api/qr?login=${login}`;
return `/api/qr?login=${login}`;
}
export const getData = async (dayIndex?: number) => {

View File

@@ -1 +0,0 @@
/// <reference types="react-scripts" />