2 chained application designed and new stage inited
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { fetchDataWithToken } from "@/fetchers/fecther";
|
||||
import { urlBuildingsList, urlBuildingsUpdate, urlBuildingsCreate } from "@/fetchers/index";
|
||||
import { Pagination } from "@/fetchers/types";
|
||||
import { fetchResponseStatus } from "@/fetchers/utils";
|
||||
|
||||
async function getBuildingsList(pagination: Pagination) {
|
||||
const response = await fetchDataWithToken(urlBuildingsList, pagination, "POST", false);
|
||||
if (fetchResponseStatus(response)) { return response.data }
|
||||
else { throw new Error(response.error || "Bir hata oluştu") }
|
||||
}
|
||||
|
||||
async function updateBuilding(uuid: string, data: any) {
|
||||
const newUrlOfUpdate = `${urlBuildingsUpdate}/${uuid}`;
|
||||
const response = await fetchDataWithToken(newUrlOfUpdate, data, "POST", false);
|
||||
if (fetchResponseStatus(response)) { return response.data }
|
||||
else { throw new Error(response.error || "Bir hata oluştu") }
|
||||
}
|
||||
|
||||
async function createBuilding(data: any) {
|
||||
const newUrl = `${urlBuildingsCreate}`;
|
||||
const response = await fetchDataWithToken(newUrl, data, "POST", false);
|
||||
if (fetchResponseStatus(response)) { return response.data }
|
||||
else { throw new Error(response.error || "Bir hata oluştu") }
|
||||
}
|
||||
|
||||
export {
|
||||
getBuildingsList,
|
||||
updateBuilding,
|
||||
createBuilding
|
||||
}
|
||||
@@ -31,6 +31,14 @@ const urlLogoutEndpoint = `${baseUrlAuth}/authentication/logout`;
|
||||
|
||||
const urlTesterList = `${baseUrlTester}/tester/list`;
|
||||
|
||||
const urlBuildingsList = `${baseUrlBuilding}/builds/list`;
|
||||
const urlBuildingsCreate = `${baseUrlBuilding}/builds/create`;
|
||||
const urlBuildingsUpdate = `${baseUrlBuilding}/builds/update`;
|
||||
|
||||
const urlPartsList = `${baseUrlBuilding}/parts/list`;
|
||||
const urlPartsCreate = `${baseUrlBuilding}/parts/create`;
|
||||
const urlPartsUpdate = `${baseUrlBuilding}/parts/update`;
|
||||
|
||||
export {
|
||||
urlCheckToken,
|
||||
urlPageValid,
|
||||
@@ -38,6 +46,12 @@ export {
|
||||
urlLoginEndpoint,
|
||||
urlLoginSelectEndpoint,
|
||||
urlLogoutEndpoint,
|
||||
urlBuildingsList,
|
||||
urlBuildingsCreate,
|
||||
urlBuildingsUpdate,
|
||||
urlPartsList,
|
||||
urlPartsCreate,
|
||||
urlPartsUpdate,
|
||||
// For test use only
|
||||
urlTesterList,
|
||||
};
|
||||
|
||||
@@ -21,4 +21,12 @@ interface CookieObject {
|
||||
priority: string;
|
||||
}
|
||||
|
||||
export type { HttpMethod, ApiResponse, FetchOptions, CookieObject };
|
||||
interface Pagination {
|
||||
page?: number;
|
||||
size?: number;
|
||||
orderField?: string[];
|
||||
orderType?: string[];
|
||||
query?: Record<string, any>;
|
||||
}
|
||||
|
||||
export type { HttpMethod, ApiResponse, FetchOptions, CookieObject, Pagination };
|
||||
|
||||
Reference in New Issue
Block a user