Build error fixes
This commit is contained in:
parent
a0124f24f6
commit
0b60478cbf
@ -5,12 +5,6 @@ import {
|
||||
LayoutDashboard,
|
||||
Package,
|
||||
Wrench,
|
||||
Users,
|
||||
BarChart3,
|
||||
Building2,
|
||||
Truck,
|
||||
FileText,
|
||||
MapPin,
|
||||
Menu,
|
||||
X,
|
||||
Moon,
|
||||
@ -45,31 +39,31 @@ const Sidebar: React.FC<SidebarProps> = ({ userEmail }) => {
|
||||
};
|
||||
|
||||
// Role-based visibility logic
|
||||
const isMaintenanceManagerKASH = userEmail === 'maintenancemanager-kash@gmail.com';
|
||||
const isMaintenanceManagerTH = userEmail === 'maintenancemanager-th@gmail.com';
|
||||
const isMaintenanceManagerDAJH = userEmail === 'maintenancemanager-dajh@gmail.com';
|
||||
// const isMaintenanceManagerKASH = userEmail === 'maintenancemanager-kash@gmail.com';
|
||||
// const isMaintenanceManagerTH = userEmail === 'maintenancemanager-th@gmail.com';
|
||||
// const isMaintenanceManagerDAJH = userEmail === 'maintenancemanager-dajh@gmail.com';
|
||||
const isFinanceManager = userEmail === 'financemanager@gmail.com';
|
||||
const isEndUser = userEmail && (
|
||||
userEmail.startsWith('enduser1-kash') ||
|
||||
userEmail.startsWith('enduser1-dajh') ||
|
||||
userEmail.startsWith('enduser1-th')
|
||||
);
|
||||
const isTechnician = userEmail && (
|
||||
userEmail.startsWith('technician1-kash') ||
|
||||
userEmail.startsWith('technician1-dajh') ||
|
||||
userEmail.startsWith('technician1-th')
|
||||
);
|
||||
// const isTechnician = userEmail && (
|
||||
// userEmail.startsWith('technician1-kash') ||
|
||||
// userEmail.startsWith('technician1-dajh') ||
|
||||
// userEmail.startsWith('technician1-th')
|
||||
// );
|
||||
|
||||
const showAsset = !isFinanceManager && !isEndUser;
|
||||
const showInventory = !isFinanceManager && !isEndUser;
|
||||
// const showInventory = !isFinanceManager && !isEndUser;
|
||||
const showPreventiveMaintenance = !isFinanceManager && !isEndUser;
|
||||
const showGeneralWO = !isFinanceManager && !isEndUser;
|
||||
const showAMTeam = !isFinanceManager && !isEndUser;
|
||||
const showProjectDashboard = !isMaintenanceManagerKASH && !isMaintenanceManagerTH && !isMaintenanceManagerDAJH && !isFinanceManager && !isEndUser && !isTechnician;
|
||||
const showSiteDashboards = !isFinanceManager && !isEndUser;
|
||||
const showSupplierDashboard = !isFinanceManager && !isEndUser;
|
||||
const showSLA = !isFinanceManager && !isEndUser && !isTechnician;
|
||||
const showSiteInfo = !isFinanceManager && !isEndUser;
|
||||
// const showAMTeam = !isFinanceManager && !isEndUser;
|
||||
// const showProjectDashboard = !isMaintenanceManagerKASH && !isMaintenanceManagerTH && !isMaintenanceManagerDAJH && !isFinanceManager && !isEndUser && !isTechnician;
|
||||
// const showSiteDashboards = !isFinanceManager && !isEndUser;
|
||||
// const showSupplierDashboard = !isFinanceManager && !isEndUser;
|
||||
// const showSLA = !isFinanceManager && !isEndUser && !isTechnician;
|
||||
// const showSiteInfo = !isFinanceManager && !isEndUser;
|
||||
|
||||
const links: SidebarLink[] = [
|
||||
{
|
||||
|
||||
@ -965,7 +965,7 @@ const handlePPMPlan = async () => {
|
||||
|
||||
// Generate Status Summary HTML
|
||||
const statusSummaryHTML = Object.keys(statusCounts).length > 0
|
||||
? Object.entries(statusCounts).map(([status, count], index) => {
|
||||
? Object.entries(statusCounts).map(([status, count]) => {
|
||||
const statusClass = status === 'Completed'
|
||||
? 'bg-green-100 text-green-800 border-green-200'
|
||||
: status === 'Planned'
|
||||
|
||||
@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAssets, useAssetMutations } from '../hooks/useAsset';
|
||||
import { FaPlus, FaSearch, FaEdit, FaEye, FaTrash, FaCopy, FaEllipsisV, FaDownload, FaPrint, FaFileExport, FaTimes, FaFilter, FaChevronDown, FaChevronUp, FaSave,
|
||||
FaStar, FaLock } from 'react-icons/fa';
|
||||
FaStar } from 'react-icons/fa';
|
||||
import LinkField from '../components/LinkField';
|
||||
import { useUserPermissions } from '../hooks/useUserPermissions';
|
||||
|
||||
@ -18,13 +18,13 @@ const AssetList: React.FC = () => {
|
||||
|
||||
// ✅ NEW: Get user permissions for Asset doctype
|
||||
const {
|
||||
isAdmin,
|
||||
// isAdmin,
|
||||
permissionFilters,
|
||||
restrictions,
|
||||
// restrictions,
|
||||
loading: permissionsLoading,
|
||||
error: permissionsError,
|
||||
hasRestriction,
|
||||
getAllowedValues,
|
||||
// hasRestriction,
|
||||
// getAllowedValues,
|
||||
hasAnyRestrictions
|
||||
} = useUserPermissions('Asset');
|
||||
|
||||
@ -211,11 +211,11 @@ const AssetList: React.FC = () => {
|
||||
};
|
||||
|
||||
// Quick filters
|
||||
const applyQuickFilter = (type: 'active' | 'down' | 'recent') => {
|
||||
handleClearFilters();
|
||||
if (type === 'active') setFilterDeviceStatus('Up');
|
||||
else if (type === 'down') setFilterDeviceStatus('Down');
|
||||
};
|
||||
// const applyQuickFilter = (type: 'active' | 'down' | 'recent') => {
|
||||
// handleClearFilters();
|
||||
// if (type === 'active') setFilterDeviceStatus('Up');
|
||||
// else if (type === 'down') setFilterDeviceStatus('Down');
|
||||
// };
|
||||
|
||||
// Cleanup timeouts on unmount
|
||||
useEffect(() => {
|
||||
@ -331,71 +331,71 @@ const AssetList: React.FC = () => {
|
||||
filterAssetName || filterSerialNumber || searchTerm;
|
||||
|
||||
// ✅ NEW: Helper component for restricted select fields
|
||||
const RestrictedSelect: React.FC<{
|
||||
label: string;
|
||||
permissionType: string;
|
||||
value: string;
|
||||
onChange: (val: string) => void;
|
||||
doctype: string;
|
||||
placeholder?: string;
|
||||
filters?: Record<string, any>;
|
||||
}> = ({ label, permissionType, value, onChange, doctype, placeholder, filters: linkFilters }) => {
|
||||
const isRestricted = hasRestriction(permissionType);
|
||||
const allowedValues = getAllowedValues(permissionType);
|
||||
// const RestrictedSelect: React.FC<{
|
||||
// label: string;
|
||||
// permissionType: string;
|
||||
// value: string;
|
||||
// onChange: (val: string) => void;
|
||||
// doctype: string;
|
||||
// placeholder?: string;
|
||||
// filters?: Record<string, any>;
|
||||
// }> = ({ label, permissionType, value, onChange, doctype, placeholder, filters: linkFilters }) => {
|
||||
// const isRestricted = hasRestriction(permissionType);
|
||||
// const allowedValues = getAllowedValues(permissionType);
|
||||
|
||||
if (isRestricted && allowedValues.length > 0) {
|
||||
return (
|
||||
<div className="relative">
|
||||
<label className="block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5 flex items-center gap-1">
|
||||
{label}
|
||||
<FaLock size={8} className="text-amber-500" title={`Restricted to ${allowedValues.length} value(s)`} />
|
||||
</label>
|
||||
<select
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="w-full px-2 py-1 text-xs border border-amber-300 dark:border-amber-600 rounded focus:outline-none focus:ring-2 focus:ring-amber-500 bg-amber-50 dark:bg-amber-900/20 text-gray-900 dark:text-white"
|
||||
>
|
||||
<option value="">All Allowed ({allowedValues.length})</option>
|
||||
{allowedValues.map(val => (
|
||||
<option key={val} value={val}>{val}</option>
|
||||
))}
|
||||
</select>
|
||||
{value && (
|
||||
<button
|
||||
onClick={() => onChange('')}
|
||||
className="absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors"
|
||||
>
|
||||
<FaTimes size={10} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// if (isRestricted && allowedValues.length > 0) {
|
||||
// return (
|
||||
// <div className="relative">
|
||||
// <label className="block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5 flex items-center gap-1">
|
||||
// {label}
|
||||
// <FaLock size={8} className="text-amber-500" title={`Restricted to ${allowedValues.length} value(s)`} />
|
||||
// </label>
|
||||
// <select
|
||||
// value={value}
|
||||
// onChange={(e) => onChange(e.target.value)}
|
||||
// className="w-full px-2 py-1 text-xs border border-amber-300 dark:border-amber-600 rounded focus:outline-none focus:ring-2 focus:ring-amber-500 bg-amber-50 dark:bg-amber-900/20 text-gray-900 dark:text-white"
|
||||
// >
|
||||
// <option value="">All Allowed ({allowedValues.length})</option>
|
||||
// {allowedValues.map(val => (
|
||||
// <option key={val} value={val}>{val}</option>
|
||||
// ))}
|
||||
// </select>
|
||||
// {value && (
|
||||
// <button
|
||||
// onClick={() => onChange('')}
|
||||
// className="absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors"
|
||||
// >
|
||||
// <FaTimes size={10} />
|
||||
// </button>
|
||||
// )}
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
|
||||
// Not restricted - show normal LinkField
|
||||
return (
|
||||
<div className="relative">
|
||||
<LinkField
|
||||
label={label}
|
||||
doctype={doctype}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
placeholder={placeholder || `Select ${label}`}
|
||||
disabled={false}
|
||||
compact={true}
|
||||
filters={linkFilters}
|
||||
/>
|
||||
{value && (
|
||||
<button
|
||||
onClick={() => onChange('')}
|
||||
className="absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors"
|
||||
>
|
||||
<FaTimes size={10} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
// // Not restricted - show normal LinkField
|
||||
// return (
|
||||
// <div className="relative">
|
||||
// <LinkField
|
||||
// label={label}
|
||||
// doctype={doctype}
|
||||
// value={value}
|
||||
// onChange={onChange}
|
||||
// placeholder={placeholder || `Select ${label}`}
|
||||
// disabled={false}
|
||||
// compact={true}
|
||||
// filters={linkFilters}
|
||||
// />
|
||||
// {value && (
|
||||
// <button
|
||||
// onClick={() => onChange('')}
|
||||
// className="absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors"
|
||||
// >
|
||||
// <FaTimes size={10} />
|
||||
// </button>
|
||||
// )}
|
||||
// </div>
|
||||
// );
|
||||
// };
|
||||
|
||||
// ✅ NEW: Loading state for permissions
|
||||
if (permissionsLoading) {
|
||||
|
||||
@ -39,7 +39,7 @@ const ModernDashboard: React.FC = () => {
|
||||
const { data: assetWiseChart } = useDashboardChart('Maintenance - Asset wise Count');
|
||||
const { data: assigneesChart } = useDashboardChart('Asset Maintenance Assignees Status Count');
|
||||
const { data: frequencyChart } = useDashboardChart('Asset Maintenance Frequency Chart');
|
||||
const { data: ppmStatusChart } = useDashboardChart('PPM Status');
|
||||
// const { data: ppmStatusChart } = useDashboardChart('PPM Status');
|
||||
|
||||
// Generate Up & Down Time Chart data from assets
|
||||
useEffect(() => {
|
||||
@ -765,28 +765,28 @@ const CustomerSatisfactionCard: React.FC<{ data: any; title: string; description
|
||||
};
|
||||
|
||||
// Metric Card Component (Bottom Row - Smaller & Compact)
|
||||
const MetricCard: React.FC<{
|
||||
icon: React.ReactNode;
|
||||
label: string;
|
||||
value: string;
|
||||
iconColor?: string;
|
||||
bgColor: string;
|
||||
textColor?: string;
|
||||
}> = ({ icon, label, value, iconColor = "text-white", bgColor, textColor = "text-gray-900 dark:text-white" }) => (
|
||||
<div className={`${bgColor} rounded-lg shadow hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700`}>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<div className={`text-2xl ${iconColor}`}>
|
||||
{icon}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className={`text-[10px] font-medium uppercase tracking-wide mb-1 ${textColor.includes('white') ? 'text-white/80' : 'text-gray-600 dark:text-gray-400'}`}>
|
||||
{label}
|
||||
</div>
|
||||
<div className={`text-2xl font-semibold ${textColor}`}>{value}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
// const MetricCard: React.FC<{
|
||||
// icon: React.ReactNode;
|
||||
// label: string;
|
||||
// value: string;
|
||||
// iconColor?: string;
|
||||
// bgColor: string;
|
||||
// textColor?: string;
|
||||
// }> = ({ icon, label, value, iconColor = "text-white", bgColor, textColor = "text-gray-900 dark:text-white" }) => (
|
||||
// <div className={`${bgColor} rounded-lg shadow hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700`}>
|
||||
// <div className="flex items-center justify-between mb-3">
|
||||
// <div className={`text-2xl ${iconColor}`}>
|
||||
// {icon}
|
||||
// </div>
|
||||
// </div>
|
||||
// <div>
|
||||
// <div className={`text-[10px] font-medium uppercase tracking-wide mb-1 ${textColor.includes('white') ? 'text-white/80' : 'text-gray-600 dark:text-gray-400'}`}>
|
||||
// {label}
|
||||
// </div>
|
||||
// <div className={`text-2xl font-semibold ${textColor}`}>{value}</div>
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
|
||||
// Mini Area Chart Component
|
||||
const MiniAreaChart: React.FC = () => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { usePPMDetails, usePPMMutations } from '../hooks/usePPM';
|
||||
import { FaArrowLeft, FaSave, FaEdit, FaBuilding, FaTools, FaCalendarCheck, FaDollarSign } from 'react-icons/fa';
|
||||
import { FaArrowLeft, FaSave, FaEdit, FaTools } from 'react-icons/fa';
|
||||
import type { CreatePPMData } from '../services/ppmService';
|
||||
|
||||
const PPMDetail: React.FC = () => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { usePPMs, usePPMMutations } from '../hooks/usePPM';
|
||||
import { FaPlus, FaSearch, FaEdit, FaEye, FaTrash, FaCopy, FaEllipsisV, FaFileExport, FaCalendarCheck, FaTools, FaBuilding } from 'react-icons/fa';
|
||||
import { FaPlus, FaSearch, FaEdit, FaEye, FaTrash, FaCopy, FaEllipsisV, FaFileExport, FaCalendarCheck, FaBuilding } from 'react-icons/fa';
|
||||
|
||||
const PPMList: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user