Skip to content

Phase 5 frontend - #5

Merged
Aditya2550 merged 6 commits into
mainfrom
phase-5-frontend
Aug 5, 2026
Merged

Aditya2550 merged 6 commits into
mainfrom
phase-5-frontend

Conversation

@Aditya2550

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI lite review requested due to automatic review settings August 5, 2026 05:34
@Aditya2550
Aditya2550 merged commit d723454 into main Aug 5, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Approval Rules” configuration flow across frontend + backend, replacing the previous workflow-rules approach with a dedicated /approval-rules API and a richer admin UI for selecting rule types.

Changes:

  • Reworked Admin Panel to support Sequential / Percentage / Hybrid approval-rule configuration and preview.
  • Added backend approvalRules module (routes/model/controller) and mounted it at /approval-rules.
  • Updated example environment ports to 5000 and adjusted the frontend approval API client accordingly.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/pages/AdminPanelPage.jsx New admin UI for selecting/saving approval-rule types and rendering a live preview.
frontend/src/api/approvalService.js Replaces workflow-rules API calls with getApprovalRules / saveApprovalRules.
frontend/.env.example Updates example frontend API/socket URLs to port 5000.
backend/src/routes/index.js Mounts the new /approval-rules routes.
backend/src/modules/approvalRules/approvalRules.routes.js Adds authenticated/admin-only GET/PUT endpoints for approval rules and history.
backend/src/modules/approvalRules/approvalRules.model.js Adds DB accessors for latest rule, history, and create.
backend/src/modules/approvalRules/approvalRules.controller.js Implements get current/history + save rule endpoints.
backend/src/middleware/errorHandler.js Minor formatting change + adds logging for non-ApiError errors.
backend/.env.example Updates example backend port to 5000.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import { asyncHandler } from "../../utils/asyncHandler.js";
import { approvalRulesModel } from "./approvalRules.model.js";

const VALID_TYPES = ["sequential", "percentage", "hybrid"];
Comment on lines +23 to +39
export const saveRule = asyncHandler(async (req, res) => {
const companyId = req.user.companyId;
const { type, config } = req.body;

if (!VALID_TYPES.includes(type)) {
return res.status(400).json({
message: `type must be one of: ${VALID_TYPES.join(", ")}`,
});
}

if (!config || typeof config !== "object" || Array.isArray(config)) {
return res.status(400).json({ message: "config must be an object" });
}

const result = await approvalRulesModel.create({ companyId, type, config });
res.status(201).json(result.rows[0]);
});
Comment on lines +148 to +152
if (ruleType === "sequential" && sequentialRoles.length === 0) {
throw new Error("Add at least one approver role");
}
await saveApprovalRules(payload);
setSaveMessage("Approval rule saved successfully.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants