first commit

This commit is contained in:
Your NamebaishaliHolocron
2026-06-15 12:57:03 +05:30
commit b9ac5ae0b2
398 changed files with 49583 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
import { UUID } from "crypto";
import { baseApiRequest } from "../apiRequests/baseApiRequest";
const PRODUCT_API = `${process.env.NEXT_PUBLIC_PROJECT_MANAGEMENT_API_URL}/api/v1/products`;
// Allocation payload shape
export interface ProductAllocation {
id?: string;
allocation: Record<string, number>;
detailedAllocation: Record<string, Record<string, any>>;
resourceType: string;
role: string;
gradeId: number;
employeeName: string;
taskName: string;
resourceId: string;
taskId: number;
}
// List allocations for a product
export const getResourceAllocations = async (productIdentifier: UUID) => {
return baseApiRequest(
`${PRODUCT_API}/${productIdentifier}/resource-allocations`,
{
method: "GET",
cache: "no-store",
},
{ isAccessTokenRequird: true }
);
};
// Get a single allocation
export const getAllocation = async (productIdentifier: UUID, allocationIdentifier: UUID) => {
return baseApiRequest(
`${PRODUCT_API}/${productIdentifier}/resource-allocations/${allocationIdentifier}`,
{
method: "GET",
cache: "no-store",
},
{ isAccessTokenRequird: true }
);
};
// Create allocation
export const createAllocation = async (productIdentifier: UUID, allocation: ProductAllocation) => {
return baseApiRequest(
`${PRODUCT_API}/${productIdentifier}/resource-allocations`,
{
method: "POST",
body: JSON.stringify(allocation),
},
{ isAccessTokenRequird: true }
);
};
// Update allocation
export const updateAllocation = async (
productIdentifier: UUID,
allocationIdentifier: UUID,
updatedAllocation: ProductAllocation
) => {
return baseApiRequest(
`${PRODUCT_API}/${productIdentifier}/resource-allocations/${allocationIdentifier}`,
{
method: "PUT",
body: JSON.stringify(updatedAllocation),
},
{ isAccessTokenRequird: true }
);
};
// Delete allocation
export const deleteAllocation = async (productIdentifier: UUID, allocationIdentifier: UUID) => {
return baseApiRequest(
`${PRODUCT_API}/${productIdentifier}/resource-allocations/${allocationIdentifier}`,
{
method: "DELETE",
},
{ isAccessTokenRequird: true }
);
};