feat: Multi-role platform expansion, mobile nav redesign, and UI polish
- Add Owner, Contractor, Vendor, Subcontractor dashboards and role-based routing - Owner now has superuser access to all Admin pages (dashboard, schedule, leaderboard) - Redesign landing page mobile menu as slide-in sidebar (replaces broken Framer Motion overlay) - Add body scroll lock to app sidebar for mobile consistency - Fix Team Schedule to match Admin Dashboard design language (ambient glows, gradient header, SpotlightCard, zinc palette) - Fix login page tab overflow — use abbreviated labels and grid layout for 6 role tabs - Fix Recharts ResponsiveContainer warnings — replace height="100%" with fixed pixel heights - Fix lightbox image viewer — unified nav bar, touch swipe support, no more overlapping text - Add AI Assistant page, People/Vendor/Document management for Owner role - Expand mock data store with contractor, vendor, and subcontractor data
This commit is contained in:
@@ -5,6 +5,16 @@ import { toast } from 'sonner';
|
||||
|
||||
const AuthContext = createContext();
|
||||
|
||||
export const ROLES = {
|
||||
OWNER: 'OWNER',
|
||||
ADMIN: 'ADMIN',
|
||||
CONTRACTOR: 'CONTRACTOR',
|
||||
SUBCONTRACTOR: 'SUBCONTRACTOR',
|
||||
VENDOR: 'VENDOR',
|
||||
FIELD_AGENT: 'FIELD_AGENT',
|
||||
CUSTOMER: 'CUSTOMER'
|
||||
};
|
||||
|
||||
export const AuthProvider = ({ children }) => {
|
||||
const [user, setUser] = useState(null);
|
||||
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
||||
@@ -16,11 +26,15 @@ export const AuthProvider = ({ children }) => {
|
||||
if (u.type !== type) return false;
|
||||
if (type === 'customer') return u.username === identifier && u.password === password;
|
||||
if (type === 'employee') return u.empId === identifier && u.password === password;
|
||||
// Support new role types
|
||||
if (['owner', 'contractor', 'subcontractor', 'vendor'].includes(type) || u.type === type) {
|
||||
return (u.email === identifier || u.username === identifier) && u.password === password;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (foundUser) {
|
||||
// Ensure specific role exists
|
||||
// Ensure specific role exists and matches requested type if applicable
|
||||
const userWithRole = {
|
||||
...foundUser,
|
||||
role: foundUser.role || 'CUSTOMER'
|
||||
|
||||
Reference in New Issue
Block a user