chore: format
This commit is contained in:
@@ -1,46 +1,46 @@
|
||||
import { z } from "zod"
|
||||
import { authProcedure } from "../trpc"
|
||||
import { prisma } from "../utils/prisma"
|
||||
import { TRPCError } from "@trpc/server"
|
||||
import { z } from "zod";
|
||||
import { authProcedure } from "../trpc";
|
||||
import { prisma } from "../utils/prisma";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
export const getOrganizationById = authProcedure
|
||||
.input(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
})
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
const userOrg = await prisma.userOrganization.findFirst({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
organizationId: input.id,
|
||||
},
|
||||
})
|
||||
.input(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
const userOrg = await prisma.userOrganization.findFirst({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
organizationId: input.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!userOrg) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "You do not have access to this organization.",
|
||||
})
|
||||
}
|
||||
if (!userOrg) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "You do not have access to this organization.",
|
||||
});
|
||||
}
|
||||
|
||||
const organization = await prisma.organization.findUnique({
|
||||
where: { id: input.id },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
})
|
||||
const organization = await prisma.organization.findUnique({
|
||||
where: { id: input.id },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!organization) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Organization not found.",
|
||||
})
|
||||
}
|
||||
if (!organization) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Organization not found.",
|
||||
});
|
||||
}
|
||||
|
||||
return organization
|
||||
})
|
||||
return organization;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user