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 <best@classroomio.com>
This commit is contained in:
Victor Jack
2026-08-06 06:24:07 +01:00
committed by GitHub
co-authored by Rotimi Best
parent 8ad0141ab8
commit a83e172e6d
7 changed files with 89 additions and 17 deletions
+8 -1
View File
@@ -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;