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.
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
/**
|
|
* Organization business logic service
|
|
* Handles data transformation and business rules for organizations
|
|
* Separated from API layer to maintain clean architecture
|
|
*/
|
|
|
|
import type { BackendOrganization } from '@/schemas/backend/organization';
|
|
import {
|
|
transformOrganizationsList,
|
|
transformOrganizationData,
|
|
} from '@/lib/organization-transformer';
|
|
import {
|
|
getOrganizations as getRawOrganizations,
|
|
getOrganizationById as getRawOrganizationById,
|
|
} from '@/services/organizations-api';
|
|
|
|
/**
|
|
* Get all organizations with business logic applied
|
|
* Filters invalid data and applies transformations
|
|
*/
|
|
export async function getOrganizations(): Promise<BackendOrganization[]> {
|
|
const rawData = await getRawOrganizations();
|
|
return transformOrganizationsList(rawData);
|
|
}
|
|
|
|
/**
|
|
* Get organization by ID with business logic applied
|
|
*/
|
|
export async function getOrganizationById(id: string): Promise<BackendOrganization> {
|
|
const rawData = await getRawOrganizationById(id);
|
|
return transformOrganizationData(rawData);
|
|
}
|
|
|
|
/**
|
|
* Validate organization has required fields for display
|
|
*/
|
|
export function isValidOrganization(org: BackendOrganization): boolean {
|
|
return !!(org.ID && org.ID.trim() && org.Name && org.Name.trim());
|
|
}
|
|
|
|
/**
|
|
* Filter organizations by verification status
|
|
*/
|
|
export function filterOrganizationsByVerification(
|
|
organizations: BackendOrganization[],
|
|
verified?: boolean
|
|
): BackendOrganization[] {
|
|
if (verified === undefined) return organizations;
|
|
return organizations.filter((org) => org.Verified === verified);
|
|
}
|
|
|
|
/**
|
|
* Search organizations by name or description
|
|
*/
|
|
export function searchOrganizations(
|
|
organizations: BackendOrganization[],
|
|
searchTerm: string
|
|
): BackendOrganization[] {
|
|
if (!searchTerm.trim()) return organizations;
|
|
|
|
const term = searchTerm.toLowerCase();
|
|
return organizations.filter(
|
|
(org) =>
|
|
org.Name.toLowerCase().includes(term) ||
|
|
(org.Description && org.Description.toLowerCase().includes(term))
|
|
);
|
|
}
|