refactor: replace Supabase SDK with self-hosted REST API client layer
WHY: migrating from Supabase BaaS to self-hosted iloom backend
(Go microservices) deployed on K3s. Supabase client and realtime
subscriptions no longer applicable.
HOW:
- add src/api/ layer (client.ts, auth.ts, purchaser.ts, textile.ts,
washing.ts, websocket.ts) targeting iloom-gateway REST endpoints
- rewrite all hooks (usePlanData, useInventoryData, useDashboardData,
useRealtime, etc.) to use new API client instead of Supabase queries
- rewrite all page/component data fetching and mutations accordingly
- delete src/supabase/client.ts, remove @supabase/supabase-js dep
- add Dockerfile (multi-stage node build + nginx) and nginx.conf
with reverse proxy to iloom-gateway for /api/ and /ws/ routes
- adjust webpack.config.js for API_URL environment variable injection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-14 12:38:47 +08:00
|
|
|
import { http } from './client';
|
|
|
|
|
import type { Company, CompanyMember, Profile } from '../types';
|
|
|
|
|
|
|
|
|
|
interface Notification {
|
|
|
|
|
id: string;
|
|
|
|
|
type: string;
|
|
|
|
|
title: string;
|
|
|
|
|
content: string;
|
|
|
|
|
is_read: boolean;
|
|
|
|
|
created_at: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface CompanyRelationship {
|
|
|
|
|
id: string;
|
|
|
|
|
company: Company;
|
|
|
|
|
role: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const commonApi = {
|
|
|
|
|
getCompany: (id: string) =>
|
|
|
|
|
http.get<Company>(`/common/companies/${id}`).then(r => r.data),
|
|
|
|
|
|
|
|
|
|
listRelationships: () =>
|
|
|
|
|
http.get<CompanyRelationship[]>('/common/companies').then(r => r.data),
|
|
|
|
|
|
|
|
|
|
listMembers: () =>
|
|
|
|
|
http.get<(CompanyMember & { profile: Profile })[]>('/common/members').then(r => r.data),
|
|
|
|
|
|
|
|
|
|
createMember: (data: { username: string; password: string; display_name: string; phone?: string }) =>
|
|
|
|
|
http.post<CompanyMember>('/common/members', data).then(r => r.data),
|
|
|
|
|
|
|
|
|
|
deleteMember: (id: string) =>
|
|
|
|
|
http.delete(`/common/members/${id}`),
|
|
|
|
|
|
|
|
|
|
listNotifications: () =>
|
|
|
|
|
http.get<Notification[]>('/common/notifications').then(r => r.data),
|
|
|
|
|
|
|
|
|
|
markNotificationRead: (id: string) =>
|
|
|
|
|
http.patch(`/common/notifications/${id}`, { is_read: true }),
|
|
|
|
|
|
2026-06-30 07:15:26 +08:00
|
|
|
createShareLink: (data: { resource_type: string; resource_id: string }) =>
|
refactor: replace Supabase SDK with self-hosted REST API client layer
WHY: migrating from Supabase BaaS to self-hosted iloom backend
(Go microservices) deployed on K3s. Supabase client and realtime
subscriptions no longer applicable.
HOW:
- add src/api/ layer (client.ts, auth.ts, purchaser.ts, textile.ts,
washing.ts, websocket.ts) targeting iloom-gateway REST endpoints
- rewrite all hooks (usePlanData, useInventoryData, useDashboardData,
useRealtime, etc.) to use new API client instead of Supabase queries
- rewrite all page/component data fetching and mutations accordingly
- delete src/supabase/client.ts, remove @supabase/supabase-js dep
- add Dockerfile (multi-stage node build + nginx) and nginx.conf
with reverse proxy to iloom-gateway for /api/ and /ws/ routes
- adjust webpack.config.js for API_URL environment variable injection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-14 12:38:47 +08:00
|
|
|
http.post<{ code: string }>('/common/share-links', data).then(r => r.data),
|
|
|
|
|
|
|
|
|
|
getShareLink: (code: string) =>
|
|
|
|
|
http.get<unknown>(`/common/share-links/${code}`).then(r => r.data),
|
|
|
|
|
|
|
|
|
|
submitFeedback: (data: { content: string }) =>
|
|
|
|
|
http.post('/common/feedback', data),
|
|
|
|
|
};
|