- Fixed double /api/api/ issue in production - Updated all API files to remove /api/ prefix since baseURL already includes it - Files fixed: platform.ts, oauth.ts, customDomains.ts, domains.ts, business.ts, sandbox.ts - Production build will need to be rebuilt after pulling these changes
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
/**
|
|
* Custom Domains API - Manage custom domains for businesses
|
|
*/
|
|
|
|
import apiClient from './client';
|
|
import { CustomDomain } from '../types';
|
|
|
|
/**
|
|
* Get all custom domains for the current business
|
|
*/
|
|
export const getCustomDomains = async (): Promise<CustomDomain[]> => {
|
|
const response = await apiClient.get<CustomDomain[]>('/business/domains/');
|
|
return response.data;
|
|
};
|
|
|
|
/**
|
|
* Add a new custom domain
|
|
*/
|
|
export const addCustomDomain = async (domain: string): Promise<CustomDomain> => {
|
|
const response = await apiClient.post<CustomDomain>('/business/domains/', {
|
|
domain: domain.toLowerCase().trim(),
|
|
});
|
|
return response.data;
|
|
};
|
|
|
|
/**
|
|
* Delete a custom domain
|
|
*/
|
|
export const deleteCustomDomain = async (domainId: number): Promise<void> => {
|
|
await apiClient.delete(`/business/domains/${domainId}/`);
|
|
};
|
|
|
|
/**
|
|
* Verify a custom domain by checking DNS
|
|
*/
|
|
export const verifyCustomDomain = async (domainId: number): Promise<{ verified: boolean; message: string }> => {
|
|
const response = await apiClient.post<{ verified: boolean; message: string }>(
|
|
`/business/domains/${domainId}/verify/`
|
|
);
|
|
return response.data;
|
|
};
|
|
|
|
/**
|
|
* Set a custom domain as the primary domain
|
|
*/
|
|
export const setPrimaryDomain = async (domainId: number): Promise<CustomDomain> => {
|
|
const response = await apiClient.post<CustomDomain>(
|
|
`/business/domains/${domainId}/set-primary/`
|
|
);
|
|
return response.data;
|
|
};
|