ifixkart-admin/New admin panel/ikixkart-dashboard/services/api/systemConfigService.ts
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

83 lines
2.5 KiB
TypeScript

import { apiFetch } from './client';
export interface CrmLocation {
location_id: string;
tenant_id: string;
code: string;
name: string;
address?: string;
city?: string;
state?: string;
pincode?: string;
phone?: string;
is_active: boolean;
is_primary: boolean;
created_at?: string;
}
export interface DeviceTypeRegistry {
device_type_id: string;
tenant_id: string;
category: string;
brand: string;
device_name: string;
name?: string;
code: string;
is_active: boolean;
created_at?: string;
}
export interface DuplicateCheckResult {
is_duplicate: boolean;
duplicate_type?: 'PRODUCT' | 'REPAIR_SERVICE';
existing_item?: any;
message?: string;
}
export const systemConfigService = {
// --- STORE LOCATIONS ---
getLocations: async () => {
return apiFetch<CrmLocation[]>('/api/v1/system/locations');
},
createLocation: async (data: { code: string; name: string; address?: string; city?: string; state?: string; pincode?: string; phone?: string; is_primary?: boolean }) => {
return apiFetch<CrmLocation>('/api/v1/system/locations', {
method: 'POST',
body: JSON.stringify(data),
});
},
// --- DYNAMIC DEVICE TYPES ---
getDeviceTypes: async () => {
return apiFetch<DeviceTypeRegistry[]>('/api/v1/system/device-types');
},
createDeviceType: async (data: { category: string; brand: string; device_name: string; code: string }) => {
return apiFetch<DeviceTypeRegistry>('/api/v1/system/device-types', {
method: 'POST',
body: JSON.stringify(data),
});
},
// --- USER LOCATION ASSIGNMENT ---
assignUserLocations: async (userId: string, locationIds: string[], primaryLocationId?: string) => {
return apiFetch<{ message: string }>('/api/v1/system/user-locations/assign', {
method: 'POST',
body: JSON.stringify({
user_id: userId,
location_ids: locationIds,
primary_location_id: primaryLocationId,
}),
});
},
// --- DEDUPLICATION CHECK ---
checkDuplicate: async (itemType: 'PRODUCT' | 'REPAIR_SERVICE', name: string, categoryId?: string, brandId?: string, deviceModelId?: string) => {
const params = new URLSearchParams({ item_type: itemType, name });
if (categoryId) params.append('category_id', categoryId);
if (brandId) params.append('brand_id', brandId);
if (deviceModelId) params.append('device_model_id', deviceModelId);
return apiFetch<DuplicateCheckResult>(`/api/v1/catalog/check-duplicate?${params.toString()}`);
}
};