add connexions
This commit is contained in:
+28
-5
@@ -16,16 +16,39 @@ const apiCall = async (url, body = {}) => {
|
||||
return data.result;
|
||||
};
|
||||
|
||||
export const loginClient = (email, password) =>
|
||||
export const loginClient = (email, password) =>
|
||||
apiCall('/api/guest/client/login', { email, password });
|
||||
|
||||
export const getClientProfile = () =>
|
||||
export const getClientProfile = () =>
|
||||
apiCall('/api/client/profile/get');
|
||||
|
||||
// Récupère la liste des services/commandes du client
|
||||
export const getClientOrders = () =>
|
||||
export const getClientOrders = () =>
|
||||
apiCall('/api/client/order/get_list');
|
||||
|
||||
// Récupère les détails techniques du service rattaché à une commande
|
||||
export const getOrderService = (order_id) =>
|
||||
apiCall('/api/client/order/service', { id: order_id });
|
||||
export const getOrderService = (order_id) =>
|
||||
apiCall('/api/client/order/service', { id: order_id });
|
||||
|
||||
// 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) => {
|
||||
try {
|
||||
const response = await fetch('/custom_api/signup.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
username: username,
|
||||
password: password,
|
||||
first_name: firstName, // L'étiquette est "first_name", le contenu est ta variable JS "firstName"
|
||||
last_name: lastName // L'étiquette est "last_name", le contenu est ta variable JS "lastName"
|
||||
})
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.error) throw new Error(data.error.message);
|
||||
return data.result;
|
||||
} catch (err) {
|
||||
console.error("Erreur lors de l'inscription unifiée :", err);
|
||||
throw new Error("Échec de l'inscription. Veuillez réessayer plus tard.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user