Fix background task + socket in services + cleaning

This commit is contained in:
Sebastien Riviere
2026-02-17 23:48:42 +01:00
parent 05a60612c6
commit 2dfddd86e6
25 changed files with 301 additions and 318 deletions

View File

@@ -0,0 +1,32 @@
// Constants
import { SERVER_URL } from "../constants";
export const uploadTeamImage = async (id, imageUri) => {
if (!imageUri || !id) return;
const data = new FormData();
data.append('file', {
uri: imageUri,
name: 'photo.jpg',
type: 'image/jpeg',
});
try {
const response = await fetch(`${SERVER_URL}/upload?team=${id}`, {
method: 'POST',
body: data,
});
if (!response.ok) throw new Error("Échec de l'upload");
return await response.blob();
} catch (error) {
console.error("Erreur uploadImage :", error);
throw error;
}
};
export const enemyImage = (id) => {
if (!id) return require('../assets/images/missing_image.jpg');
return {uri: `${SERVER_URL}/photo/enemy?team=${id}`};
};