Files
WebETA/src/services/public.js
2024-09-25 20:27:00 -06:00

131 lines
3.1 KiB
JavaScript

import api from "../lib/axios";
export const getLoadDirectories = async(filterStr) => {
try {
const endpoint = `/v1/public-loads${filterStr}`;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const getVehicleDirectories = async(filter) => {
try {
const endpoint = `/v1/public-vehicles/published${filter}`;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const getFreeVehicles = async() => {
try {
const endpoint = `/v1/public-vehicles/location`;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const getNews = async() => {
try {
const endpoint = `/news`;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const getCompanies = async(filter) => {
try {
const endpoint = `/v1/companies/${filter}`;
const {data} = await api.get(endpoint);
return data;
} catch (error) {
return null;
}
}
export const getLoadPublic = async(id) => {
try {
const endpoint = `/v1/public-load-tracking/${id}`;
const {data} = await api.get(endpoint);
return data;
} catch (error) {
return null;
}
}
export const getUsersCompany = async(filter) => {
try {
const endpoint = `/v1/users/find?${filter}`;
const {data} = await api.get(endpoint);
return data;
} catch (error) {
return [];
}
}
export const getPublicUsersCompany = async(filter) => {
try {
const endpoint = `/v1/companies/users/${filter}`;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const getSettingsQuery = async(filter) => {
try {
const endpoint = "/v1/meta-data/find?regex=" + filter.query;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const searchcategories = async(query) => {
try {
const endpoint = "/v1/product-categories/find?regex=" + query;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const searchProducts = async(query) => {
try {
const endpoint = "/v1/products/find?regex=" + query;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const searchstates = async(query) => {
try {
const endpoint = "/v1/states/find?regex=" + query;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}
export const searchcities = async(query) => {
try {
const endpoint = "/v1/cities/find?regex=" + query;
const {data} = await api.get(endpoint);
return data.data;
} catch (error) {
return [];
}
}