feat: add company sidebar filters, internal phone, mail icon fix, and update script
This commit is contained in:
+15
-3
@@ -34,6 +34,7 @@ const App = () => {
|
||||
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [selectedDept, setSelectedDept] = useState(null);
|
||||
const [selectedCompany, setSelectedCompany] = useState(null);
|
||||
const [activeView, setActiveView] = useState('directory'); // 'directory', 'login', 'admin'
|
||||
const [selectedEmployee, setSelectedEmployee] = useState(null);
|
||||
|
||||
@@ -117,10 +118,13 @@ const App = () => {
|
||||
|
||||
// Client-side search and filtering
|
||||
const filteredEmployees = employees.filter((emp) => {
|
||||
// 1. Department filter
|
||||
// 1. Company filter
|
||||
if (selectedCompany && emp.company_id !== selectedCompany) return false;
|
||||
|
||||
// 2. Department filter
|
||||
if (selectedDept && emp.department_id !== selectedDept) return false;
|
||||
|
||||
// 2. Search query filter (Case-insensitive, fragments, normalized phone)
|
||||
// 3. Search query filter (Case-insensitive, fragments, normalized phone)
|
||||
if (searchQuery.trim()) {
|
||||
const queryClean = searchQuery.toLowerCase().trim();
|
||||
const queryDigits = getQueryPhoneDigits(queryClean);
|
||||
@@ -132,13 +136,18 @@ const App = () => {
|
||||
const empPhoneDigits = getPhoneDigits(emp.phone);
|
||||
const phoneMatch = queryDigits.length > 0 && empPhoneDigits.includes(queryDigits);
|
||||
|
||||
// Match internal phone
|
||||
const empInternalPhoneDigits = getPhoneDigits(emp.internal_phone);
|
||||
const internalPhoneMatch = queryDigits.length > 0 && empInternalPhoneDigits.includes(queryDigits);
|
||||
const internalPhoneStringMatch = emp.internal_phone && emp.internal_phone.toLowerCase().includes(queryClean);
|
||||
|
||||
// Secondary match parameters (Job title, Company, Location)
|
||||
const titleMatch = emp.job_title.toLowerCase().includes(queryClean);
|
||||
const companyMatch = emp.company_name && emp.company_name.toLowerCase().includes(queryClean);
|
||||
const deptMatch = emp.department_name && emp.department_name.toLowerCase().includes(queryClean);
|
||||
const buildingMatch = emp.building && emp.building.toLowerCase().includes(queryClean);
|
||||
|
||||
return nameMatch || phoneMatch || titleMatch || companyMatch || deptMatch || buildingMatch;
|
||||
return nameMatch || phoneMatch || internalPhoneMatch || internalPhoneStringMatch || titleMatch || companyMatch || deptMatch || buildingMatch;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -203,6 +212,9 @@ const App = () => {
|
||||
{activeView === 'directory' && (
|
||||
<div className="directory-layout">
|
||||
<Sidebar
|
||||
companies={companies}
|
||||
selectedCompany={selectedCompany}
|
||||
setSelectedCompany={setSelectedCompany}
|
||||
departments={departments}
|
||||
selectedDept={selectedDept}
|
||||
setSelectedDept={setSelectedDept}
|
||||
|
||||
Reference in New Issue
Block a user