mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-03 01:24:58 +02:00
Add support for menu children and moved invitations under users
This commit is contained in:
parent
c7f3c9da92
commit
7a55c9ad03
8 changed files with 105 additions and 58 deletions
|
@ -72,7 +72,6 @@ export async function listInvitations(
|
|||
next: NextFunction
|
||||
): Promise<any> {
|
||||
try {
|
||||
// Validate query parameters
|
||||
const parsedQuery = listInvitationsQuerySchema.safeParse(req.query);
|
||||
if (!parsedQuery.success) {
|
||||
return next(
|
||||
|
@ -84,7 +83,6 @@ export async function listInvitations(
|
|||
}
|
||||
const { limit, offset } = parsedQuery.data;
|
||||
|
||||
// Validate path parameters
|
||||
const parsedParams = listInvitationsParamsSchema.safeParse(req.params);
|
||||
if (!parsedParams.success) {
|
||||
return next(
|
||||
|
@ -96,16 +94,13 @@ export async function listInvitations(
|
|||
}
|
||||
const { orgId } = parsedParams.data;
|
||||
|
||||
// Query invitations
|
||||
const invitations = await queryInvitations(orgId, limit, offset);
|
||||
|
||||
// Get total count of invitations
|
||||
const [{ count }] = await db
|
||||
.select({ count: sql<number>`count(*)` })
|
||||
.from(userInvites)
|
||||
.where(sql`${userInvites.orgId} = ${orgId}`);
|
||||
|
||||
// Return response
|
||||
return response<ListInvitationsResponse>(res, {
|
||||
data: {
|
||||
invitations,
|
||||
|
|
|
@ -22,7 +22,6 @@ export async function removeInvitation(
|
|||
next: NextFunction
|
||||
): Promise<any> {
|
||||
try {
|
||||
// Validate path parameters
|
||||
const parsedParams = removeInvitationParamsSchema.safeParse(req.params);
|
||||
if (!parsedParams.success) {
|
||||
return next(
|
||||
|
@ -35,7 +34,6 @@ export async function removeInvitation(
|
|||
|
||||
const { orgId, inviteId } = parsedParams.data;
|
||||
|
||||
// Delete the invitation from the database
|
||||
const deletedInvitation = await db
|
||||
.delete(userInvites)
|
||||
.where(
|
||||
|
@ -46,7 +44,6 @@ export async function removeInvitation(
|
|||
)
|
||||
.returning();
|
||||
|
||||
// If no rows were deleted, the invitation was not found
|
||||
if (deletedInvitation.length === 0) {
|
||||
return next(
|
||||
createHttpError(
|
||||
|
@ -56,7 +53,6 @@ export async function removeInvitation(
|
|||
);
|
||||
}
|
||||
|
||||
// Return success response
|
||||
return response(res, {
|
||||
data: null,
|
||||
success: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue