2024-09-04 00:52:26 +00:00
|
|
|
import axios from "axios";
|
|
|
|
|
2024-09-04 05:53:00 +00:00
|
|
|
const BASE_URL = import.meta.env.VITE_REACT_APP_SECRET;
|
2024-09-04 00:52:26 +00:00
|
|
|
|
|
|
|
// const API = axios.create({baseURL:"http://localhost:3001"});
|
|
|
|
// const API = axios.create({ baseURL: `${BASE_URL}` });
|
|
|
|
const API = axios.create({ baseURL: BASE_URL });
|
|
|
|
|
|
|
|
|
|
|
|
API.interceptors.request.use((req) => {
|
|
|
|
if (localStorage.getItem("profile")) {
|
|
|
|
req.headers.Authorization = `Bearer ${
|
|
|
|
JSON.parse(localStorage.getItem("profile")).token
|
|
|
|
}`;
|
|
|
|
}
|
|
|
|
return req;
|
|
|
|
});
|
|
|
|
|
|
|
|
export const signUp = (formData) => API.post("/users/signup", formData);
|
|
|
|
export const signIn = (formData) => API.post("/users/signin", formData);
|
2024-09-07 14:16:51 +00:00
|
|
|
export const verifyEmail = (id, token, data) => API.get(`/users/${id}/verify/${token}`, data);
|
2024-09-16 10:55:17 +00:00
|
|
|
export const submitProperty = (propertyData) => API.post("/properties", propertyData);
|
2024-09-22 11:03:36 +00:00
|
|
|
// export const fetchUserProperties = (userId) => API.get(`/properties/user/${userId}`, userId);
|
|
|
|
|
|
|
|
export const fetchUserProperties = (userId, page, limit) => API.get( `/properties/user/${userId}?page=${page}&limit=${limit}`, userId);
|
2024-09-16 15:09:26 +00:00
|
|
|
export const fetchPropertyById = (id) => API.get(`/properties/${id}`, id);
|
2024-09-21 19:01:44 +00:00
|
|
|
export const updateProperty = (id, propertyData) => API.put(`/properties/${id}`, propertyData);
|
|
|
|
|
2024-09-16 15:09:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-16 10:55:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-06 15:02:20 +00:00
|
|
|
|