fix: Creating teams for organizations in wizard (#9632)
* Expanding org slug check and adding proper error msg * Duh &&
This commit is contained in:
@@ -1889,5 +1889,6 @@
|
||||
"my_profile": "My Profile",
|
||||
"my_settings": "My Settings",
|
||||
"sender_id_info": "Name or number shown as the sender of an SMS (some countries do not allow alphanumeric sender IDs)",
|
||||
"no_organization_slug": "There was an error creating teams for this organization. Missing URL slug.",
|
||||
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export const AddNewTeamsForm = () => {
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
showToast(t(error.message), "error");
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ export const createHandler = async ({ input }: CreateOptions) => {
|
||||
name,
|
||||
...(!IS_TEAM_BILLING_ENABLED && { slug }),
|
||||
metadata: {
|
||||
requestedSlug: slug,
|
||||
...(IS_TEAM_BILLING_ENABLED && { requestedSlug: slug }),
|
||||
isOrganization: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -18,10 +18,14 @@ type CreateTeamsOptions = {
|
||||
export const createTeamsHandler = async ({ ctx, input }: CreateTeamsOptions) => {
|
||||
const { teamNames, orgId } = input;
|
||||
|
||||
const organization = await prisma.team.findFirst({ where: { id: orgId }, select: { metadata: true } });
|
||||
const organization = await prisma.team.findFirst({
|
||||
where: { id: orgId },
|
||||
select: { slug: true, metadata: true },
|
||||
});
|
||||
const metadata = teamMetadataSchema.parse(organization?.metadata);
|
||||
|
||||
if (!metadata?.requestedSlug) throw new TRPCError({ code: "BAD_REQUEST", message: "no_organization" });
|
||||
if (!metadata?.requestedSlug && !organization?.slug)
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: "no_organization_slug" });
|
||||
|
||||
const userMembership = await prisma.membership.findFirst({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user