Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_API_URL=http://localhost:4000
REACT_APP_API_URL=http://localhost:4000/
Copy link

@coderabbitai coderabbitai bot Oct 7, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Verify trailing slash handling in API URL usage.

The trailing slash added to REACT_APP_API_URL could cause double-slash issues (e.g., http://localhost:4000//api/endpoint) if the code concatenates paths without accounting for it. Ensure all API calls handle this correctly.

Run the following script to check how the API URL is used throughout the codebase:


🏁 Script executed:

#!/bin/bash
# Description: Find usages of REACT_APP_API_URL to verify trailing slash handling

# Search for direct usage of REACT_APP_API_URL
rg -n "REACT_APP_API_URL" --type ts --type tsx --type js --type jsx -C3

# Search for common API call patterns that might concatenate URLs
rg -n "process\.env\.REACT_APP_API_URL\s*\+\s*['\"]/" --type ts --type tsx --type js --type jsx -C3

Length of output: 55


🏁 Script executed:

#!/bin/bash
# Broad search for REACT_APP_API_URL usages
rg -n "REACT_APP_API_URL" -C3

# Search for concatenation patterns
rg -n "process\.env\.REACT_APP_API_URL\s*\+" -C3

# Search for template literal usage
rg -n "\`.*process\.env\.REACT_APP_API_URL.*\`" -C3

Length of output: 16087


Normalize or remove trailing slash in REACT_APP_API_URL
.env.sample currently defines REACT_APP_API_URL=http://localhost:4000/, which leads to URLs like http://localhost:4000//upload-file when concatenated. Either drop the trailing slash in .env.sample or strip it at runtime (e.g. envApiUrl.replace(/\/$/, '')) before appending paths.

🤖 Prompt for AI Agents
In .env.sample around line 1, REACT_APP_API_URL includes a trailing slash which
can produce double-slash URLs when concatenating paths; remove the trailing
slash from the sample value (change to http://localhost:4000) or, alternatively,
ensure the app normalizes the env value at startup by stripping any trailing
slash (e.g., call a single-strip operation like replace(/\/$/, '') on the loaded
REACT_APP_API_URL) before using it to build endpoint paths so concatenation
never produces duplicate slashes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ene odoo yajiinaa mi hu

Copy link
Collaborator

Choose a reason for hiding this comment

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

ene odoo yajiinaa mi hu

Copy link

Choose a reason for hiding this comment

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

@KhBaterdene Thank you for confirming! If you've verified that the trailing slash works correctly with your API endpoint handling, that's great. The change looks good to proceed.

Just for future reference, if you notice any double-slash issues in API URLs (like http://localhost:4000//api/...), you'll know the trailing slash in the .env file is the place to adjust. ✨

Copy link

Choose a reason for hiding this comment

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

@KhBaterdene Glad to hear it's working well now! 🎉


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

NODE_ENV=development
MONGO_URL=mongodb://localhost:27017/erxes
NODE_OPTIONS=--max-old-space-size=1536
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

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

eniig baiikhgu bolgoh

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const getPluginsRoutes = () => {
pluginName: plugin.name,
})),
);

return allModules.map((module) => (
<Route
key={module.name}
Expand Down
2 changes: 1 addition & 1 deletion frontend/plugins/operation_ui/module-federation.config.ts
Copy link
Collaborator

Choose a reason for hiding this comment

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

eniig ch bas

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const config: ModuleFederationConfig = {
'./operation': './src/modules/main/Main.tsx',
'./teamSettings': './src/modules/team/Settings.tsx',
'./relationWidget': './src/widgets/relation/RelationWidgets.tsx',
'./notificationWidget':
'./notificationWidget':
'./src/widgets/notifications/NotificationsWidgets.tsx',
},

Expand Down
1 change: 0 additions & 1 deletion frontend/plugins/operation_ui/src/modules/main/Main.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

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

eniig bas

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const taskMain = () => {
<Route path="/" element={<Navigate to="tasks" replace />} />
<Route path="tasks" element={<TasksPage />} />
<Route path="tasks/:taskId" element={<TaskDetailPage />} />

<Route path="projects" element={<ProjectsPage />} />
<Route path="projects/:projectId" element={<ProjectLayout />}>
<Route index element={<Navigate to="overview" replace />} />
Expand Down
3 changes: 3 additions & 0 deletions frontend/plugins/pos_ui/src/modules/states/PosCount.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

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

ene ter chigeere ustaagui yu

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { atom } from 'jotai';

export const posTotalCountAtom = atom<number | null>(null);
3 changes: 1 addition & 2 deletions frontend/plugins/sales_ui/module-federation.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ const config: ModuleFederationConfig = {
name: 'sales_ui',
exposes: {
'./config': './src/config.tsx',
'./deals': './src/modules/deals/Main.tsx',
'./sales': './src/modules/main/Main.tsx',
'./dealsSettings': './src/pages/SettingsPage.tsx',
'./Widgets': './src/widgets/Widgets.tsx',
'./pos': './src/modules/pos/pos/Main.tsx',
'./posSettings': './src/modules/pos/pos/Settings.tsx',
},

Expand Down
26 changes: 20 additions & 6 deletions frontend/plugins/sales_ui/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import {
import { lazy, Suspense } from 'react';

const SalesNavigation = lazy(() =>
import('./modules/SalesNavigation').then((module) => ({
import('./modules/navigation/SalesNavigation').then((module) => ({
default: module.SalesNavigation,
})),
);

const PosOrderNavigation = lazy(() =>
import('./modules/navigation/PosOrderNavigation').then((module) => ({
default: module.PosOrderNavigation,
})),
);

export const CONFIG = {
name: 'sales',
icon: IconBriefcase,
Expand All @@ -24,20 +30,28 @@ export const CONFIG = {
<SalesNavigation />
</Suspense>
),
subGroups: () => (
<Suspense fallback={<div />}>
<PosOrderNavigation />
</Suspense>
),
},
modules: [
{
name: 'deals',
icon: IconSandbox,
path: 'deals',
hasSettings: true,
name: 'sales',
icon: IconBriefcase,
path: 'sales',
hasSettings: false,
hasRelationWidget: true,
hasFloatingWidget: false,
Comment on lines +41 to +46
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify breaking changes: module rename and disabled settings.

This segment contains potentially breaking changes:

  1. Module renamed from 'deals' to 'sales' (lines 41, 43) — any code referencing the 'deals' module or routing to /deals will break
  2. hasSettings changed to false (line 44) — this disables settings UI that may have been previously accessible

Ensure these changes are intentional and that:

  • All references to the 'deals' module/route are updated
  • Removal of settings functionality is coordinated (or was never implemented)

Run the following script to verify references to the old module name and settings usage:


🏁 Script executed:

#!/bin/bash
# Search for references to 'deals' module that might break
rg -nP --type=ts --type=tsx -C3 "['\"](deals)['\"]|/deals\b" -g '!frontend/plugins/sales_ui/src/config.tsx'

# Search for hasSettings usage to understand impact
rg -nP --type=ts --type=tsx -C3 'hasSettings' -g '!frontend/plugins/sales_ui/src/config.tsx'

Length of output: 55


🏁 Script executed:

#!/bin/bash
# Search for references to 'deals' module or route outside config.tsx
rg -nP -C3 "(\"deals\"|'deals')|/deals\b" -g '!frontend/plugins/sales_ui/src/config.tsx'

# Search for any usage of hasSettings outside config.tsx
rg -nP -C3 'hasSettings' -g '!frontend/plugins/sales_ui/src/config.tsx'

Length of output: 297


🏁 Script executed:

#!/bin/bash
# Unfiltered search for references to 'deals' module or route
rg -nP -C3 "(\"deals\"|'deals')|/deals\b"

# Unfiltered search for any usage of hasSettings
rg -nP -C3 'hasSettings'

Length of output: 106095


Update all references after renaming ‘deals’ to ‘sales’ and disabling settings

  • Replace import paths (@/deals/…) and routes (/deals, /settings/deals) to use sales
  • Update backend plugin registrations and tRPC calls still referencing module: 'deals'
  • Review hasSettings: false—remove or adjust settings links/UI in SalesIndexPage and StagesList
🤖 Prompt for AI Agents
In frontend/plugins/sales_ui/src/config.tsx around lines 41 to 46, the plugin
was renamed from “deals” to “sales” and settings were disabled, but many
references remain unchanged; update all frontend import paths and route strings
from "@/deals/..." and "/deals" or "/settings/deals" to use "sales" and "/sales"
respectively, update any backend plugin registration and trpc/module identifiers
that still use module: 'deals' to module: 'sales', and remove or hide settings
links/UI in SalesIndexPage and StagesList (or conditionally render them based on
hasSettings: false) so the UI no longer shows settings actions for this plugin.

},
{
name: 'pos',
icon: IconCashRegister,
path: 'pos',
hasSettings: true,
hasSettings: false,
hasRelationWidget: true,
hasFloatingWidget: false,
},
],
};
10 changes: 0 additions & 10 deletions frontend/plugins/sales_ui/src/modules/SalesNavigation.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions frontend/plugins/sales_ui/src/modules/deals/Main.tsx

This file was deleted.

37 changes: 37 additions & 0 deletions frontend/plugins/sales_ui/src/modules/main/Main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Navigate, Route, Routes } from 'react-router';
import { Suspense, lazy } from 'react';
import { Spinner } from 'erxes-ui/components';

const DealsMain = lazy(() =>
import('~/pages/SalesIndexPage').then((module) => ({
default: module.SalesIndexPage,
})),
);

const OrdersMain = lazy(() =>
import('~/pages/OrdersPage').then((module) => ({
default: module.OrdersPage,
})),
);

const PosMain = lazy(() =>
import('~/pages/PosIndexPage').then((module) => ({
default: module.PosIndexPage,
})),
);

const App = () => {
return (
<Suspense fallback={<Spinner />}>
<Routes>
<Route path="/" element={<Navigate to="deals" replace />} />
<Route path="/deals" element={<DealsMain />} />
<Route path="/pos" element={<Navigate to="orders" replace />} />
<Route path="/pos/:posId/orders" element={<OrdersMain />} />
Comment on lines +29 to +30
Copy link

@coderabbitai coderabbitai bot Oct 10, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Redirect is missing the required posId.

Navigating to /pos ends up at /orders (or /pos/orders), but no such route exists; only /pos/:posId/orders is defined. Users hitting /pos will land on a 404. Please redirect to a concrete route that includes a valid posId (e.g., fetch the default POS first, then navigate to /pos/<id>/orders).

Copy link
Collaborator

Choose a reason for hiding this comment

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

eniig harsan uu

Copy link

Choose a reason for hiding this comment

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

@KhBaterdene Yes, I've reviewed this route configuration. The issue I flagged is still present in the current code:

The Problem:
Line 29 redirects /pos to the relative path "orders", which resolves to /pos/orders. However, your route definition on line 30 is /pos/:posId/orders, which requires a posId parameter. This mismatch will cause a 404 error when users navigate to /pos.

Suggested Fix:
You have a few options:

  1. Fetch a default POS and redirect to it:
<Route path="/pos" element={<PosRedirect />} />

Where PosRedirect is a component that fetches the user's first POS and redirects to /pos/<posId>/orders

  1. Add an intermediary route:
<Route path="/pos" element={<Navigate to="/deals" replace />} />

Redirect to deals instead if there's no default POS

  1. Add a route without posId:
<Route path="/pos/orders" element={<OrdersMain />} />
<Route path="/pos/:posId/orders" element={<OrdersMain />} />

And handle the missing posId inside the OrdersMain component

Which approach would work best for your use case?

<Route path="/pos/:posId" element={<PosMain />} />
</Routes>
</Suspense>
);
};

export default App;
Loading