fix: show clear error when creating or updating organization site name to an existing one (#793)
* fixed error of not showing the org name API response error * Fixed the error also for organization settings page * modified * Keep field-specific mapping in OrgApi --------- Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
co-authored by
Rotimi Best
parent
8ad0141ab8
commit
a83e172e6d
@@ -4,6 +4,7 @@ import type { TGetAudienceQuery, TGetOrganizationCoursesQuery } from '@cio/utils
|
||||
import type { TNewOrganizationPlan, TOrganization, TOrganizationPlan } from '@db/types';
|
||||
import {
|
||||
cancelOrganizationPlan,
|
||||
checkSiteNameExists,
|
||||
createOrganizationPlan,
|
||||
deleteOrganizationAudienceMember,
|
||||
deleteOrganizationMember,
|
||||
@@ -648,7 +649,13 @@ export async function createOrgPlan(data: TNewOrganizationPlan) {
|
||||
*/
|
||||
export async function updateOrg(orgId: string, data: Partial<TOrganization>) {
|
||||
try {
|
||||
// Enforce plan restriction: only paid plans can use non-minimal landing page themes
|
||||
if (data.siteName) {
|
||||
const exists = await checkSiteNameExists(data.siteName, orgId); // exclude current org
|
||||
if (exists) {
|
||||
throw new AppError('Site name already exists', ErrorCodes.SITENAME_EXISTS, 409, 'siteName');
|
||||
}
|
||||
}
|
||||
|
||||
if (data.landingpage && typeof data.landingpage === 'object') {
|
||||
const landingpage = data.landingpage as Record<string, unknown>;
|
||||
const theme = landingpage.theme;
|
||||
|
||||
Reference in New Issue
Block a user