Implement pocketbase API

This commit is contained in:
2025-07-04 15:07:01 +02:00
parent 7bc4724cc8
commit 7808907861
4 changed files with 139 additions and 112 deletions

View File

@@ -1,18 +1,30 @@
import type { IndFacilityRecord, IndFacilityResponse } from '../lib/pbtypes';
import pb from '../lib/pocketbase';
import { Facility } from './jobService';
export type { IndFacilityRecord as Facility } from '../lib/pbtypes';
// Stub functions - to be implemented with PocketBase
export const facilityService = {
async getFacilities(): Promise<Facility[]> {
// TODO: Implement with PocketBase
console.log('Fetching facilities');
// Mock data for development
return [
{ id: '1', name: 'Jita IV - Moon 4 - Caldari Navy Assembly Plant', location: 'Jita' },
{ id: '2', name: 'Amarr VIII (Oris) - Emperor Family Academy', location: 'Amarr' },
{ id: '3', name: 'Dodixie IX - Moon 20 - Federation Navy Assembly Plant', location: 'Dodixie' },
{ id: '4', name: 'Rens VI - Moon 8 - Brutor Tribe Treasury', location: 'Rens' },
{ id: '5', name: 'Hek VIII - Moon 12 - Boundless Creation Factory', location: 'Hek' }
];
export async function getFacilities(): Promise<IndFacilityResponse[]> {
const result = await pb.collection('ind_facility').getFullList();
return result as IndFacilityResponse[];
}
export async function getFacility(id: string): Promise<IndFacilityResponse | null> {
try {
return await pb.collection('ind_facility').getOne(id) as IndFacilityResponse;
} catch (e) {
if (e.status === 404) return null;
throw e;
}
};
}
export async function createFacility(facility: Omit<IndFacilityRecord, 'id' | 'created' | 'updated'>): Promise<IndFacilityResponse> {
return await pb.collection('ind_facility').create(facility) as IndFacilityResponse;
}
export async function updateFacility(id: string, updates: Partial<IndFacilityRecord>): Promise<IndFacilityResponse> {
return await pb.collection('ind_facility').update(id, updates) as IndFacilityResponse;
}
export async function deleteFacility(id: string): Promise<void> {
await pb.collection('ind_facility').delete(id);
}