mirror of
https://git.meshkee.com/Meshkee/dashboards.git
synced 2026-08-11 22:30:58 +04:30
Initial commit: Meshkee dashboards monorepo.
Includes business, customer, and super-admin apps with shared packages and production deploy scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import { apiRequest } from '../lib/api'
|
||||
import type { BusinessesListResponse, BusinessListItem, CreateBusinessPayload } from '../types/business'
|
||||
|
||||
export interface ListBusinessesParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
name?: string
|
||||
domain?: string
|
||||
category?: string
|
||||
}
|
||||
|
||||
export interface UpdateBusinessPayload {
|
||||
name?: string
|
||||
slug?: string
|
||||
}
|
||||
|
||||
export interface AddDomainPayload {
|
||||
host: string
|
||||
isPrimary?: boolean
|
||||
}
|
||||
|
||||
export interface DisableBusinessPayload {
|
||||
isActive: boolean
|
||||
}
|
||||
|
||||
export interface UpdateDomainPayload {
|
||||
host: string
|
||||
}
|
||||
|
||||
export async function listBusinesses(params: ListBusinessesParams, signal?: AbortSignal) {
|
||||
const q = new URLSearchParams()
|
||||
if (params.page !== undefined) q.set('page', String(params.page))
|
||||
if (params.pageSize !== undefined) q.set('pageSize', String(params.pageSize))
|
||||
if (params.name) q.set('name', params.name)
|
||||
if (params.domain) q.set('domain', params.domain)
|
||||
if (params.category) q.set('category', params.category)
|
||||
|
||||
const query = q.toString()
|
||||
const path = `/businesses${query ? `?${query}` : ''}`
|
||||
return apiRequest<BusinessesListResponse>(path, { auth: true, signal })
|
||||
}
|
||||
|
||||
export async function createBusiness(payload: CreateBusinessPayload) {
|
||||
return apiRequest<BusinessListItem>('/businesses', {
|
||||
method: 'POST',
|
||||
auth: true,
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateBusiness(businessId: string, payload: UpdateBusinessPayload) {
|
||||
return apiRequest<BusinessListItem>(`/businesses/${businessId}`, {
|
||||
method: 'PATCH',
|
||||
auth: true,
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
export async function addBusinessDomain(businessId: string, payload: AddDomainPayload) {
|
||||
return apiRequest(`/businesses/${businessId}/domains`, {
|
||||
method: 'POST',
|
||||
auth: true,
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateBusinessDomain(
|
||||
businessId: string,
|
||||
domainId: number,
|
||||
payload: UpdateDomainPayload,
|
||||
) {
|
||||
return apiRequest(`/businesses/${businessId}/domains/${domainId}`, {
|
||||
method: 'PATCH',
|
||||
auth: true,
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
export async function setBusinessActive(businessId: string, payload: DisableBusinessPayload) {
|
||||
return apiRequest(`/businesses/${businessId}/disable`, {
|
||||
method: 'PATCH',
|
||||
auth: true,
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
export async function removeBusiness(businessId: string) {
|
||||
return apiRequest(`/businesses/${businessId}`, {
|
||||
method: 'DELETE',
|
||||
auth: true,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user