feat: implement axios client with interceptors, dashboard caching, and core application modules

This commit is contained in:
2026-06-22 15:27:19 +05:30
parent 514a656fa8
commit 39c4e1b390
11 changed files with 29 additions and 27 deletions

2
.env Normal file
View File

@@ -0,0 +1,2 @@
VITE_DASHBOARD_API_URL=https://sr-backend-api.takeleap.in
VITE_AUDIT_API_URL=https://sr-audit.takeleap.in

2
.env.production Normal file
View File

@@ -0,0 +1,2 @@
VITE_DASHBOARD_API_URL=https://python.seekright.com
VITE_AUDIT_API_URL=https://node-audit.seekright.com

BIN
dist-seekright.zip Normal file

Binary file not shown.

View File

@@ -22,6 +22,17 @@ axiosClient.interceptors.request.use(
if (user?.db_name) {
config.params = { ...config.params, dbName: user.db_name };
}
// Automatically rewrite local proxy paths to the real URLs from environment variables
// This allows us to remove the Vite/Nginx proxy completely!
if (config.url?.startsWith('/api/dashboard')) {
const dashboardUrl = import.meta.env.VITE_DASHBOARD_API_URL || 'https://sr-backend-api.takeleap.in';
config.url = config.url.replace('/api/dashboard', dashboardUrl);
} else if (config.url?.startsWith('/api/audit')) {
const auditUrl = import.meta.env.VITE_AUDIT_API_URL || 'https://sr-audit.takeleap.in';
config.url = config.url.replace('/api/audit', auditUrl);
}
return config;
},
(error) => Promise.reject(error)

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import {
Dialog, DialogContent, Typography, Box, IconButton, Button,
Dialog, DialogContent, Typography, Box, Button,
TextField, RadioGroup, FormControlLabel, Radio, Checkbox,
CircularProgress, Select, MenuItem
} from '@mui/material';
@@ -250,7 +250,7 @@ export const BulkDeleteDialog: React.FC<BulkDeleteDialogProps> = ({ open, onClos
sx={{ color: '#64748b', '&.Mui-checked': { color: '#3b82f6' } }}
/>
}
label={<Typography variant="body2" fontWeight="bold" color="#f8fafc">SELECT ALL</Typography>}
label={<Typography variant="body2" sx={{ fontWeight: 'bold', color: '#f8fafc' }}>SELECT ALL</Typography>}
sx={{ width: '100%', m: 0 }}
/>
@@ -272,7 +272,7 @@ export const BulkDeleteDialog: React.FC<BulkDeleteDialogProps> = ({ open, onClos
sx={{ color: '#64748b', '&.Mui-checked, &.MuiCheckbox-indeterminate': { color: '#3b82f6' } }}
/>
}
label={<Typography variant="body2" fontWeight="bold" color="#cbd5e1" sx={{ textTransform: 'uppercase' }}>{type.type_name.replace(/_/g, ' ')}</Typography>}
label={<Typography variant="body2" sx={{ fontWeight: 'bold', color: '#cbd5e1', textTransform: 'uppercase' }}>{type.type_name.replace(/_/g, ' ')}</Typography>}
sx={{ width: '100%', m: 0 }}
/>
<Box sx={{ ml: 3, display: 'flex', flexDirection: 'column' }}>

View File

@@ -80,6 +80,7 @@ export const GlobalFeed: React.FC = () => {
isTrueFalse: isRectActive ? 'both' : (auditStatus === 'False Audits' ? 'true' : 'both'),
auto_audit: isRectActive ? '' : (auditStatus === 'Auto Audits' ? 'true' : (auditStatus === 'Manual' ? 'false' : '')),
isRectificationEnabled: isRectActive,
sortByDateAsc: false,
anomalyIds: searchAnomalyId,
plaza: filterPlaza,
assetsIds: assetIdsKey,
@@ -131,6 +132,7 @@ export const GlobalFeed: React.FC = () => {
isTrueFalse: isRectActive ? 'both' : (auditStatus === 'False Audits' ? 'true' : 'both'),
auto_audit: isRectActive ? '' : (auditStatus === 'Auto Audits' ? 'true' : (auditStatus === 'Manual' ? 'false' : '')),
isRectificationEnabled: isRectActive,
sortByDateAsc: false,
anomalyIds: searchAnomalyId,
plaza: filterPlaza,
assetsIds: assetIdsKey,

View File

@@ -141,7 +141,6 @@ export const AuditSession: React.FC = () => {
const nextPage = (activeTab.page || 0) + 1;
const selectedSiteId = selectedSite?.site_id ?? '';
const assetIdsKey = selectedAssetIds.join(',');
const isReviewMode = location.state?.isReviewMode;
const feedPageSize = activeTab.rowsPerPage || 20;
const res: any = await activityFeedsService.getHistory({

View File

@@ -34,6 +34,7 @@ export const Dashboard: React.FC = () => {
batchAudited: 0,
batchPending: 0,
batchAnomaliesFound: 0,
firstPendingIndex: -1,
}
);
// Only show loading spinner if there's no cached result for these filters
@@ -106,7 +107,6 @@ export const Dashboard: React.FC = () => {
fetchStats();
}, [currentFilterKey]); // eslint-disable-line react-hooks/exhaustive-deps
const progressPercent = stats.batchTotal > 0 ? Math.round((stats.batchAudited / stats.batchTotal) * 100) : 0;
return (
<Box sx={{ width: '100%', maxWidth: '100vw', display: 'flex', flexDirection: 'column' }}>

View File

@@ -32,6 +32,7 @@ interface DashboardCache {
batchAudited: number;
batchPending: number;
batchAnomaliesFound: number;
firstPendingIndex: number;
} | null;
}

View File

@@ -5,25 +5,10 @@ import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
proxy: {
'/api/dashboard': {
target: 'https://sr-backend-api.takeleap.in',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/dashboard/, ''),
headers: {
Origin: 'https://auditor-qa.seekright.com',
Referer: 'https://auditor-qa.seekright.com/'
}
},
'/api/audit': {
target: 'https://sr-audit.takeleap.in',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/audit/, ''),
headers: {
Origin: 'https://auditor-qa.seekright.com',
Referer: 'https://auditor-qa.seekright.com/'
}
},
},
allowedHosts: true,
// Reverse proxy is no longer needed since endpoints allow CORS natively
},
preview: {
allowedHosts: true,
},
})