Phase 5 frontend - #5
Merged
Merged
Conversation
There was a problem hiding this comment.
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
approvalRulesmodule (routes/model/controller) and mounted it at/approval-rules. - Updated example environment ports to
5000and 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."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.