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:
co-authored by
Rotimi Best
parent
8ad0141ab8
commit
a83e172e6d
@@ -19,6 +19,8 @@ import {
|
||||
ilike,
|
||||
inArray,
|
||||
isNotNull,
|
||||
ne,
|
||||
not,
|
||||
notInArray,
|
||||
or,
|
||||
sql
|
||||
@@ -214,15 +216,19 @@ export async function insertOrganizationMembersOnConflictDoNothing(
|
||||
}
|
||||
}
|
||||
|
||||
export const checkSiteNameExists = async (siteName: string): Promise<boolean> => {
|
||||
export const checkSiteNameExists = async (siteName: string, excludeOrgId?: string): Promise<boolean> => {
|
||||
const conditions = [eq(schema.organization.siteName, siteName)];
|
||||
|
||||
if (excludeOrgId) {
|
||||
conditions.push(ne(schema.organization.id, excludeOrgId));
|
||||
}
|
||||
|
||||
const result = await db
|
||||
.select({ id: schema.organization.id })
|
||||
.from(schema.organization)
|
||||
.where(eq(schema.organization.siteName, siteName))
|
||||
.where(and(...conditions))
|
||||
.limit(1);
|
||||
|
||||
console.debug('checkSiteNameExists result:', result);
|
||||
|
||||
return result.length > 0;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user