mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { apiDelete, apiGet, apiPost } from '@/lib/api-client';
|
|
import {
|
|
backendResourceFlowSchema,
|
|
createResourceFlowRequestSchema,
|
|
type BackendResourceFlow,
|
|
type CreateResourceFlowRequest,
|
|
} from '@/schemas/backend/resource-flow';
|
|
|
|
/**
|
|
* Get resource flow by ID
|
|
*/
|
|
export async function getResourceFlowById(id: string): Promise<BackendResourceFlow> {
|
|
const data = await apiGet<BackendResourceFlow>(`/resources/${id}`);
|
|
return backendResourceFlowSchema.parse(data);
|
|
}
|
|
|
|
/**
|
|
* Get resource flows by site ID
|
|
*/
|
|
export async function getResourceFlowsBySite(siteId: string): Promise<BackendResourceFlow[]> {
|
|
const data = await apiGet<BackendResourceFlow[]>(`/resources/site/${siteId}`);
|
|
return data.map((flow) => backendResourceFlowSchema.parse(flow));
|
|
}
|
|
|
|
/**
|
|
* Get resource flows by organization ID
|
|
* Resource flows belong to Organizations (not just Businesses)
|
|
*/
|
|
export async function getResourceFlowsByOrganization(
|
|
organizationId: string
|
|
): Promise<BackendResourceFlow[]> {
|
|
const data = await apiGet<BackendResourceFlow[]>(`/resources/organization/${organizationId}`);
|
|
return data.map((flow) => backendResourceFlowSchema.parse(flow));
|
|
}
|
|
|
|
/**
|
|
* @deprecated Use getResourceFlowsByOrganization instead
|
|
* Kept for backwards compatibility during migration
|
|
*/
|
|
export const getResourceFlowsByBusiness = getResourceFlowsByOrganization;
|
|
|
|
/**
|
|
* Create a new resource flow
|
|
*/
|
|
export async function createResourceFlow(
|
|
request: CreateResourceFlowRequest
|
|
): Promise<BackendResourceFlow> {
|
|
const validated = createResourceFlowRequestSchema.parse(request);
|
|
const data = await apiPost<BackendResourceFlow>('/resources', validated);
|
|
return backendResourceFlowSchema.parse(data);
|
|
}
|
|
|
|
/**
|
|
* Delete a resource flow
|
|
*/
|
|
export async function deleteResourceFlow(id: string): Promise<void> {
|
|
await apiDelete<void>(`/resources/${id}`);
|
|
}
|