Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/utils/services/.server/tenantDeletionStatusService.ts
T

24 lines
1000 B
TypeScript

// AK-P21 — deletion_pending read-only state. While a tenant deletion request
// sits in its 30-day grace window (or is executing), the workspace is
// read-only. Enforced by the same central write guard as the AK-P20/BILL-05
// billing frozen mode (assertTenantWritableForRequest); the privacy area
// stays writable so admins can withdraw the request or pull an export.
import { getDbClient } from "@hivegrid/db/client.server";
export type TenantDeletionReadOnlyState = {
readOnly: boolean;
status: "none" | "pending" | "executing";
};
export async function getTenantDeletionReadOnlyState(tenantId: string): Promise<TenantDeletionReadOnlyState> {
const request = await getDbClient().tenantDeletionRequest.findFirst({
where: { tenantId, status: { in: ["pending", "executing"] } },
select: { status: true },
});
if (!request) {
return { readOnly: false, status: "none" };
}
return { readOnly: true, status: request.status === "executing" ? "executing" : "pending" };
}