Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,75 @@
|
||||
import { TenantUserType } from "~/application/enums/tenants/TenantUserType";
|
||||
import { db } from "~/utils/db.server";
|
||||
|
||||
export async function getUserInvitation(id: string, tenantId?: string) {
|
||||
return await db.tenantUserInvitation.findFirst({
|
||||
where: {
|
||||
id,
|
||||
...(tenantId ? { tenantId } : {}),
|
||||
pending: true,
|
||||
},
|
||||
include: {
|
||||
tenant: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getUserInvitations(tenantId?: string) {
|
||||
if (!tenantId) {
|
||||
return [];
|
||||
}
|
||||
return await db.tenantUserInvitation.findMany({
|
||||
where: {
|
||||
tenantId,
|
||||
pending: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function createUserInvitation(
|
||||
tenantId: string,
|
||||
data: {
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
type: TenantUserType;
|
||||
fromUserId: string | null;
|
||||
}
|
||||
) {
|
||||
const invitation = await db.tenantUserInvitation.create({
|
||||
data: {
|
||||
tenantId,
|
||||
...data,
|
||||
pending: true,
|
||||
},
|
||||
});
|
||||
|
||||
return invitation;
|
||||
}
|
||||
|
||||
export async function updateUserInvitationPending(id: string) {
|
||||
return await db.tenantUserInvitation.update({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
data: {
|
||||
pending: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteUserInvitation(id: string, tenantId?: string) {
|
||||
if (tenantId) {
|
||||
return await db.tenantUserInvitation.deleteMany({
|
||||
where: {
|
||||
id,
|
||||
tenantId,
|
||||
},
|
||||
});
|
||||
}
|
||||
return await db.tenantUserInvitation.delete({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user