process approvals on the frontend

This commit is contained in:
Fred KISSIE
2026-01-14 03:31:49 +01:00
parent bc20a34a49
commit 0c5daa7173
5 changed files with 107 additions and 36 deletions

View File

@@ -45,7 +45,7 @@ const querySchema = z.strictObject({
approvalState: z
.enum(["pending", "approved", "denied", "all"])
.optional()
.default("pending")
.default("all")
.catch("all")
});

View File

@@ -18,7 +18,7 @@ import { z } from "zod";
import { fromError } from "zod-validation-error";
import { build } from "@server/build";
import { approvals, clients, db, orgs } from "@server/db";
import { approvals, clients, db, orgs, type Approval } from "@server/db";
import { getOrgTierData } from "@server/lib/billing";
import { TierId } from "@server/lib/billing/tiers";
import response from "@server/lib/response";
@@ -27,13 +27,15 @@ import type { NextFunction, Request, Response } from "express";
const paramsSchema = z.strictObject({
orgId: z.string(),
approvalId: z.int()
approvalId: z.string().transform(Number).pipe(z.int().positive())
});
const bodySchema = z.strictObject({
decision: z.enum(["approved", "denied"])
});
export type ProcessApprovalResponse = Approval;
export async function processPendingApproval(
req: Request,
res: Response,