mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-04 16:30:33 -06:00
Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com> Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
30 lines
930 B
TypeScript
30 lines
930 B
TypeScript
"use server";
|
|
|
|
import { getOrganization } from "@/lib/organization/service";
|
|
import { authenticatedActionClient } from "@/lib/utils/action-client";
|
|
import { checkAuthorizationUpdated } from "@/lib/utils/action-client/action-client-middleware";
|
|
import { z } from "zod";
|
|
import { ZId } from "@formbricks/types/common";
|
|
|
|
const ZGetOrganizationBillingInfoAction = z.object({
|
|
organizationId: ZId,
|
|
});
|
|
|
|
export const getOrganizationBillingInfoAction = authenticatedActionClient
|
|
.schema(ZGetOrganizationBillingInfoAction)
|
|
.action(async ({ ctx, parsedInput }) => {
|
|
await checkAuthorizationUpdated({
|
|
userId: ctx.user.id,
|
|
organizationId: parsedInput.organizationId,
|
|
access: [
|
|
{
|
|
type: "organization",
|
|
roles: ["owner", "manager", "billing"],
|
|
},
|
|
],
|
|
});
|
|
|
|
const organization = await getOrganization(parsedInput.organizationId);
|
|
return organization?.billing;
|
|
});
|