feat: updated the useage of listCurrent in the app and use org role from session (#14653)

* feat: include org role in org session data

* update contents

* fix: type err

---------

Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-04-22 14:07:43 +00:00
1 parent 3ce6c23603
commit 74f09c332b
6 files changed
+26 -44

No files matched your search

@@ -1,4 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useSession } from "next-auth/react";
import type { Dispatch } from "react";
import { useMemo } from "react";
import { Controller, useForm } from "react-hook-form";
@@ -55,6 +56,8 @@ export function EditForm({
}) {
const [setMutationLoading] = useEditMode((state) => [state.setMutationloading], shallow);
const { t } = useLocale();
const session = useSession();
const org = session?.data?.user?.org;
const utils = trpc.useUtils();
const form = useForm({
resolver: zodResolver(editSchema),
@@ -69,8 +72,7 @@ export function EditForm({
},
});
const { data: currentMembership } = trpc.viewer.organizations.listCurrent.useQuery();
const isOwner = currentMembership?.user.role === MembershipRole.OWNER;
const isOwner = org?.role === MembershipRole.OWNER;
const membershipOptions = useMemo<MembershipOption[]>(() => {
const options: MembershipOption[] = [