fix: Creating teams for organizations in wizard (#9632)
* Expanding org slug check and adding proper error msg * Duh &&
This commit is contained in:
1 parent
24a1ef6721
commit
ccff528765
4 files changed
+9
-4
No files matched your search
@@ -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