Complete super admin panel with CRUD, bookings, profile, and dev API proxy.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { api } from './client';
|
||||
import type {
|
||||
AssignOwnerPayload,
|
||||
Business,
|
||||
CreateBusinessPayload,
|
||||
UpdateBusinessPayload,
|
||||
} from './types';
|
||||
|
||||
export function fetchBusinesses(params?: {
|
||||
categoryId?: string;
|
||||
isActive?: boolean;
|
||||
}) {
|
||||
const search = new URLSearchParams();
|
||||
if (params?.categoryId) search.set('categoryId', params.categoryId);
|
||||
if (params?.isActive !== undefined) search.set('isActive', String(params.isActive));
|
||||
const query = search.toString();
|
||||
return api<Business[]>(`/businesses${query ? `?${query}` : ''}`);
|
||||
}
|
||||
|
||||
export function fetchBusiness(id: string) {
|
||||
return api<Business>(`/businesses/${id}`);
|
||||
}
|
||||
|
||||
export function createBusiness(payload: CreateBusinessPayload) {
|
||||
return api<Business>('/businesses', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateBusiness(id: string, payload: UpdateBusinessPayload) {
|
||||
return api<Business>(`/businesses/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteBusiness(id: string) {
|
||||
return api<{ success: true }>(`/businesses/${id}`, { method: 'DELETE' });
|
||||
}
|
||||
|
||||
export function assignBusinessOwner(id: string, payload: AssignOwnerPayload) {
|
||||
return api<Business>(`/businesses/${id}/assign-owner`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user