resolution connexions
Deploy Nexus Portal to HestiaCP (FTP) / build-and-deploy (push) Successful in 15s

This commit is contained in:
2026-06-12 21:16:13 +02:00
parent be589ca677
commit e662c8d530
+32 -15
View File
@@ -1,49 +1,66 @@
// src/services/api.js const BASE_URL = import.meta.env.VITE_API_BASE_URL || '';
const apiCall = async (url, body = {}) => { const apiCall = async (url, body = null) => {
const response = await fetch(url, { // Configuration de base pour l'appel réseau
method: 'POST', const options = {
method: body ? 'POST' : 'GET', // Devient GET s'il n'y a pas de body (ex: getClientProfile)
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json', 'Accept': 'application/json',
}, },
credentials: 'include', // Garde bien ça pour envoyer le cookie de session credentials: 'include', // CRUCIAL : Maintient la session active avec FOSSBilling
body: JSON.stringify(body) };
});
if (body) {
options.body = JSON.stringify(body);
}
const response = await fetch(url, options);
const data = await response.json(); const data = await response.json();
// Interception des erreurs de l'API FOSSBilling
if (data.error) throw new Error(data.error.message); if (data.error) throw new Error(data.error.message);
return data.result; return data.result;
}; };
// ==========================================
// ROUTES FOSSBILLING NATIVES (BACKTICKS INTÉGRÉS)
// ==========================================
export const loginClient = (email, password) => export const loginClient = (email, password) =>
apiCall('/api/guest/client/login', { email, password }); apiCall(`${BASE_URL}/api/guest/client/login`, { email, password });
export const getClientProfile = () => export const getClientProfile = () =>
apiCall('/api/client/profile/get'); apiCall(`${BASE_URL}/api/client/profile/get`);
// Récupère la liste des services/commandes du client // Récupère la liste des services/commandes du client
export const getClientOrders = () => export const getClientOrders = () =>
apiCall('/api/client/order/get_list'); apiCall(`${BASE_URL}/api/client/order/get_list`);
// Récupère les détails techniques du service rattaché à une commande // Récupère les détails techniques du service rattaché à une commande
export const getOrderService = (order_id) => export const getOrderService = (order_id) =>
apiCall('/api/client/order/service', { id: order_id }); apiCall(`${BASE_URL}/api/client/order/service`, { id: order_id });
// ==========================================
// ROUTES PERSONNALISÉES (CUSTOM API)
// ==========================================
// Fonction d'inscription unifiee pour créer un compte client et commander un service en une seule étape
export const registerUnifiedClient = async (email, username, password, firstName, lastName) => { export const registerUnifiedClient = async (email, username, password, firstName, lastName) => {
try { try {
const response = await fetch('https://web.gise.be/custom_api/signup.php', { // Utilisation des backticks ici aussi !
const response = await fetch(`${BASE_URL}/custom_api/signup.php`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ body: JSON.stringify({
email: email, email: email,
username: username, username: username,
password: password, password: password,
first_name: firstName, // L'étiquette est "first_name", le contenu est ta variable JS "firstName" first_name: firstName,
last_name: lastName // L'étiquette est "last_name", le contenu est ta variable JS "lastName" last_name: lastName
}) })
}); });
const data = await response.json(); const data = await response.json();
if (data.error) throw new Error(data.error.message); if (data.error) throw new Error(data.error.message);
return data.result; return data.result;