first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
12
apps/web/modules/saas/organizations/hooks/member-roles.ts
Normal file
12
apps/web/modules/saas/organizations/hooks/member-roles.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import type { OrganizationMemberRole } from "@repo/auth";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
export function useOrganizationMemberRoles() {
|
||||
const t = useTranslations();
|
||||
|
||||
return {
|
||||
member: t("organizations.roles.member"),
|
||||
owner: t("organizations.roles.owner"),
|
||||
admin: t("organizations.roles.admin"),
|
||||
} satisfies Record<OrganizationMemberRole, string>;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { useContext } from "react";
|
||||
import { ActiveOrganizationContext } from "../lib/active-organization-context";
|
||||
|
||||
export const useActiveOrganization = () => {
|
||||
const activeOrganizationContext = useContext(ActiveOrganizationContext);
|
||||
|
||||
type ActiveOrganizationContextType = NonNullable<
|
||||
typeof activeOrganizationContext
|
||||
>;
|
||||
|
||||
if (activeOrganizationContext === undefined) {
|
||||
return {
|
||||
activeOrganization: null,
|
||||
setActiveOrganization: () => Promise.resolve(),
|
||||
refetchActiveOrganization: () => Promise.resolve(),
|
||||
activeOrganizationUserRole: null,
|
||||
isOrganizationAdmin: false,
|
||||
loaded: true,
|
||||
} satisfies ActiveOrganizationContextType;
|
||||
}
|
||||
|
||||
return activeOrganizationContext;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue