browsertrix/frontend/src/utils/orgs.ts
sua yoo 1a6892572d
chore: Refactor frontend shared state (#1997)
Refactors custom components to enable shared state accessors
(like `authState`) and helpers (like `api.fetch`.) Schemas are now
defined with [zod](https://zod.dev/?id=basic-usage) which enables
runtime schema validation.

See subtasks for full description of change:

- https://github.com/webrecorder/browsertrix/pull/1979
- https://github.com/webrecorder/browsertrix/pull/1981
- https://github.com/webrecorder/browsertrix/pull/1985
- https://github.com/webrecorder/browsertrix/pull/1986

---------

Co-authored-by: Emma Segal-Grossman <hi@emma.cafe>
2024-08-12 17:57:31 -07:00

34 lines
774 B
TypeScript

import { AccessCode, type OrgData } from "@/types/org";
export * from "@/types/org";
export function isOwner(accessCode?: AccessCode): boolean {
if (!accessCode) return false;
return accessCode === AccessCode.owner;
}
export function isAdmin(accessCode?: AccessCode): boolean {
if (!accessCode) return false;
return accessCode >= AccessCode.owner;
}
export function isCrawler(accessCode?: AccessCode): boolean {
if (!accessCode) return false;
return accessCode >= AccessCode.crawler;
}
export function isArchivingDisabled(
org?: OrgData | null,
checkExecMinutesQuota = false,
): boolean {
return Boolean(
!org ||
org.readOnly ||
org.storageQuotaReached ||
(checkExecMinutesQuota ? org.execMinutesQuotaReached : false),
);
}