50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
|
|
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 }),
|
||
|
|
|
||
|
|
createShareLink: (data: { type: string; target_id: string }) =>
|
||
|
|
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),
|
||
|
|
};
|