first commit
This commit is contained in:
48
frontend/app/utils/api/productOfprojectsApi/index.tsx
Normal file
48
frontend/app/utils/api/productOfprojectsApi/index.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { UUID } from "crypto";
|
||||
import { baseApiRequest } from "../apiRequests/baseApiRequest";
|
||||
|
||||
const PROJECT_API = `${process.env.NEXT_PUBLIC_PROJECT_MANAGEMENT_API_URL}/api/v1/projects`;
|
||||
const USER_API =
|
||||
"https://ikoncloud-dev.keross.com/ikon-api/platform/user/current";
|
||||
|
||||
|
||||
// READ
|
||||
export const getAllProductsByProject = async (projectIdentifier: UUID) => {
|
||||
return baseApiRequest(
|
||||
`${PROJECT_API}/${projectIdentifier}/products`,
|
||||
{
|
||||
method: "GET",
|
||||
cache: "no-store", // optional but recommended for fresh data
|
||||
},
|
||||
{ isAccessTokenRequird: true },
|
||||
);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
export const getProductById = async (projectId: UUID, productIdentifier: UUID) => {
|
||||
return baseApiRequest(
|
||||
`${PROJECT_API}/${projectId}/products/${productIdentifier}`,
|
||||
{
|
||||
method: "GET",
|
||||
cache: "no-store",
|
||||
},
|
||||
{ isAccessTokenRequird: true }
|
||||
);
|
||||
};
|
||||
|
||||
// UPDATE
|
||||
export const updateProduct = async (projectId: UUID, productIdentifier: UUID, updatedProduct: any) => {
|
||||
return baseApiRequest(
|
||||
`${PROJECT_API}/${projectId}/products/${productIdentifier}`,
|
||||
{
|
||||
method: "PUT",
|
||||
body: JSON.stringify(updatedProduct),
|
||||
},
|
||||
{ isAccessTokenRequird: true },
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user