feat: implement axios client with interceptors, dashboard caching, and core application modules
This commit is contained in:
2
.env
Normal file
2
.env
Normal 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
2
.env.production
Normal 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
BIN
dist-seekright.zip
Normal file
Binary file not shown.
@@ -22,6 +22,17 @@ axiosClient.interceptors.request.use(
|
|||||||
if (user?.db_name) {
|
if (user?.db_name) {
|
||||||
config.params = { ...config.params, dbName: 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;
|
return config;
|
||||||
},
|
},
|
||||||
(error) => Promise.reject(error)
|
(error) => Promise.reject(error)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
Dialog, DialogContent, Typography, Box, IconButton, Button,
|
Dialog, DialogContent, Typography, Box, Button,
|
||||||
TextField, RadioGroup, FormControlLabel, Radio, Checkbox,
|
TextField, RadioGroup, FormControlLabel, Radio, Checkbox,
|
||||||
CircularProgress, Select, MenuItem
|
CircularProgress, Select, MenuItem
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
@@ -250,7 +250,7 @@ export const BulkDeleteDialog: React.FC<BulkDeleteDialogProps> = ({ open, onClos
|
|||||||
sx={{ color: '#64748b', '&.Mui-checked': { color: '#3b82f6' } }}
|
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 }}
|
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' } }}
|
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 }}
|
sx={{ width: '100%', m: 0 }}
|
||||||
/>
|
/>
|
||||||
<Box sx={{ ml: 3, display: 'flex', flexDirection: 'column' }}>
|
<Box sx={{ ml: 3, display: 'flex', flexDirection: 'column' }}>
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ export const GlobalFeed: React.FC = () => {
|
|||||||
isTrueFalse: isRectActive ? 'both' : (auditStatus === 'False Audits' ? 'true' : 'both'),
|
isTrueFalse: isRectActive ? 'both' : (auditStatus === 'False Audits' ? 'true' : 'both'),
|
||||||
auto_audit: isRectActive ? '' : (auditStatus === 'Auto Audits' ? 'true' : (auditStatus === 'Manual' ? 'false' : '')),
|
auto_audit: isRectActive ? '' : (auditStatus === 'Auto Audits' ? 'true' : (auditStatus === 'Manual' ? 'false' : '')),
|
||||||
isRectificationEnabled: isRectActive,
|
isRectificationEnabled: isRectActive,
|
||||||
|
sortByDateAsc: false,
|
||||||
anomalyIds: searchAnomalyId,
|
anomalyIds: searchAnomalyId,
|
||||||
plaza: filterPlaza,
|
plaza: filterPlaza,
|
||||||
assetsIds: assetIdsKey,
|
assetsIds: assetIdsKey,
|
||||||
@@ -131,6 +132,7 @@ export const GlobalFeed: React.FC = () => {
|
|||||||
isTrueFalse: isRectActive ? 'both' : (auditStatus === 'False Audits' ? 'true' : 'both'),
|
isTrueFalse: isRectActive ? 'both' : (auditStatus === 'False Audits' ? 'true' : 'both'),
|
||||||
auto_audit: isRectActive ? '' : (auditStatus === 'Auto Audits' ? 'true' : (auditStatus === 'Manual' ? 'false' : '')),
|
auto_audit: isRectActive ? '' : (auditStatus === 'Auto Audits' ? 'true' : (auditStatus === 'Manual' ? 'false' : '')),
|
||||||
isRectificationEnabled: isRectActive,
|
isRectificationEnabled: isRectActive,
|
||||||
|
sortByDateAsc: false,
|
||||||
anomalyIds: searchAnomalyId,
|
anomalyIds: searchAnomalyId,
|
||||||
plaza: filterPlaza,
|
plaza: filterPlaza,
|
||||||
assetsIds: assetIdsKey,
|
assetsIds: assetIdsKey,
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ export const AuditSession: React.FC = () => {
|
|||||||
const nextPage = (activeTab.page || 0) + 1;
|
const nextPage = (activeTab.page || 0) + 1;
|
||||||
const selectedSiteId = selectedSite?.site_id ?? '';
|
const selectedSiteId = selectedSite?.site_id ?? '';
|
||||||
const assetIdsKey = selectedAssetIds.join(',');
|
const assetIdsKey = selectedAssetIds.join(',');
|
||||||
const isReviewMode = location.state?.isReviewMode;
|
|
||||||
const feedPageSize = activeTab.rowsPerPage || 20;
|
const feedPageSize = activeTab.rowsPerPage || 20;
|
||||||
|
|
||||||
const res: any = await activityFeedsService.getHistory({
|
const res: any = await activityFeedsService.getHistory({
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export const Dashboard: React.FC = () => {
|
|||||||
batchAudited: 0,
|
batchAudited: 0,
|
||||||
batchPending: 0,
|
batchPending: 0,
|
||||||
batchAnomaliesFound: 0,
|
batchAnomaliesFound: 0,
|
||||||
|
firstPendingIndex: -1,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// Only show loading spinner if there's no cached result for these filters
|
// Only show loading spinner if there's no cached result for these filters
|
||||||
@@ -106,7 +107,6 @@ export const Dashboard: React.FC = () => {
|
|||||||
fetchStats();
|
fetchStats();
|
||||||
}, [currentFilterKey]); // eslint-disable-line react-hooks/exhaustive-deps
|
}, [currentFilterKey]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
const progressPercent = stats.batchTotal > 0 ? Math.round((stats.batchAudited / stats.batchTotal) * 100) : 0;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ width: '100%', maxWidth: '100vw', display: 'flex', flexDirection: 'column' }}>
|
<Box sx={{ width: '100%', maxWidth: '100vw', display: 'flex', flexDirection: 'column' }}>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ interface DashboardCache {
|
|||||||
batchAudited: number;
|
batchAudited: number;
|
||||||
batchPending: number;
|
batchPending: number;
|
||||||
batchAnomaliesFound: number;
|
batchAnomaliesFound: number;
|
||||||
|
firstPendingIndex: number;
|
||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,25 +5,10 @@ import react from '@vitejs/plugin-react'
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
allowedHosts: true,
|
||||||
'/api/dashboard': {
|
// Reverse proxy is no longer needed since endpoints allow CORS natively
|
||||||
target: 'https://sr-backend-api.takeleap.in',
|
},
|
||||||
changeOrigin: true,
|
preview: {
|
||||||
rewrite: (path) => path.replace(/^\/api\/dashboard/, ''),
|
allowedHosts: true,
|
||||||
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/'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user