@snapdragonsnursery/react-components 1.19.0 → 1.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/EmployeeSearchModal.jsx +50 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Employee Search Modal Component
|
|
2
2
|
// Provides a modal interface for employee search with advanced filtering and selection capabilities
|
|
3
|
-
// Usage: <EmployeeSearchModal isOpen={isOpen} onClose={onClose} onSelect={handleSelect} />
|
|
3
|
+
// Usage: <EmployeeSearchModal isOpen={isOpen} onClose={onClose} onSelect={handleSelect} showFiltersPanel={false} />
|
|
4
4
|
|
|
5
5
|
import React, { useState, useEffect, useCallback } from "react";
|
|
6
6
|
import { useMsal } from "@azure/msal-react";
|
|
@@ -47,7 +47,7 @@ const EmployeeSearchModal = ({
|
|
|
47
47
|
onClose,
|
|
48
48
|
onSelect,
|
|
49
49
|
title = "Select Employee",
|
|
50
|
-
searchPlaceholder = "Search by name, ID, or email address...",
|
|
50
|
+
searchPlaceholder = "Search by name, Employee ID, or email address...",
|
|
51
51
|
siteId = null,
|
|
52
52
|
siteIds = null,
|
|
53
53
|
sites = null,
|
|
@@ -90,6 +90,8 @@ const EmployeeSearchModal = ({
|
|
|
90
90
|
visibleColumns = null,
|
|
91
91
|
columnLabels = {},
|
|
92
92
|
columnRenderers = {},
|
|
93
|
+
showFiltersPanel = true,
|
|
94
|
+
dataProfile = "full",
|
|
93
95
|
}) => {
|
|
94
96
|
const [searchTerm, setSearchTerm] = useState("");
|
|
95
97
|
const [employees, setEmployees] = useState([]);
|
|
@@ -219,7 +221,9 @@ const EmployeeSearchModal = ({
|
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
|
|
222
|
-
console.warn(
|
|
224
|
+
console.warn(
|
|
225
|
+
`Failed to fetch profile picture for ${entraId}: Non-200 response`
|
|
226
|
+
);
|
|
223
227
|
} catch (error) {
|
|
224
228
|
console.warn(`Error fetching profile picture for ${entraId}:`, error);
|
|
225
229
|
} finally {
|
|
@@ -315,7 +319,7 @@ const EmployeeSearchModal = ({
|
|
|
315
319
|
});
|
|
316
320
|
|
|
317
321
|
// Define default data columns (excluding optional select)
|
|
318
|
-
const
|
|
322
|
+
const basicColumns = [
|
|
319
323
|
columnHelper.accessor("full_name", {
|
|
320
324
|
header: createSortableHeader(
|
|
321
325
|
"full_name",
|
|
@@ -327,9 +331,11 @@ const EmployeeSearchModal = ({
|
|
|
327
331
|
) : (
|
|
328
332
|
<div>
|
|
329
333
|
<div className="font-medium">{row.original.full_name}</div>
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
334
|
+
{dataProfile !== "basic" && row.original.employee_id ? (
|
|
335
|
+
<div className="text-sm text-gray-500">
|
|
336
|
+
ID: {row.original.employee_id}
|
|
337
|
+
</div>
|
|
338
|
+
) : null}
|
|
333
339
|
</div>
|
|
334
340
|
),
|
|
335
341
|
}),
|
|
@@ -366,6 +372,9 @@ const EmployeeSearchModal = ({
|
|
|
366
372
|
<span className="text-sm">{row.original.email}</span>
|
|
367
373
|
),
|
|
368
374
|
}),
|
|
375
|
+
];
|
|
376
|
+
|
|
377
|
+
const extendedColumns = [
|
|
369
378
|
columnHelper.accessor("start_date", {
|
|
370
379
|
header: createSortableHeader(
|
|
371
380
|
"start_date",
|
|
@@ -429,6 +438,11 @@ const EmployeeSearchModal = ({
|
|
|
429
438
|
}),
|
|
430
439
|
];
|
|
431
440
|
|
|
441
|
+
const defaultDataColumns =
|
|
442
|
+
dataProfile === "basic"
|
|
443
|
+
? basicColumns
|
|
444
|
+
: [...basicColumns, ...extendedColumns];
|
|
445
|
+
|
|
432
446
|
const selectColumn = columnHelper.display({
|
|
433
447
|
id: "select",
|
|
434
448
|
header: ({ table }) => (
|
|
@@ -608,6 +622,10 @@ const EmployeeSearchModal = ({
|
|
|
608
622
|
bypass_permissions: bypassPermissions.toString(),
|
|
609
623
|
});
|
|
610
624
|
|
|
625
|
+
if (dataProfile && dataProfile !== "full") {
|
|
626
|
+
params.append("data_profile", dataProfile);
|
|
627
|
+
}
|
|
628
|
+
|
|
611
629
|
// Handle site filtering
|
|
612
630
|
if (siteIds && siteIds.length > 0) {
|
|
613
631
|
params.append("site_ids", siteIds.join(","));
|
|
@@ -745,6 +763,7 @@ const EmployeeSearchModal = ({
|
|
|
745
763
|
debouncedAdvancedFilters,
|
|
746
764
|
applicationContext,
|
|
747
765
|
bypassPermissions,
|
|
766
|
+
dataProfile,
|
|
748
767
|
]);
|
|
749
768
|
|
|
750
769
|
// Search when debounced term changes
|
|
@@ -885,28 +904,30 @@ const EmployeeSearchModal = ({
|
|
|
885
904
|
</div>
|
|
886
905
|
|
|
887
906
|
{/* Advanced Filters */}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
907
|
+
{showFiltersPanel && (
|
|
908
|
+
<EmployeeSearchFilters
|
|
909
|
+
filters={advancedFilters}
|
|
910
|
+
onFiltersChange={setAdvancedFilters}
|
|
911
|
+
onApplyFilters={setAdvancedFilters}
|
|
912
|
+
sites={sites}
|
|
913
|
+
roles={roles}
|
|
914
|
+
managers={managers}
|
|
915
|
+
activeOnly={activeOnly}
|
|
916
|
+
isAdvancedFiltersOpen={isAdvancedFiltersOpen}
|
|
917
|
+
onToggleAdvancedFilters={() =>
|
|
918
|
+
setIsAdvancedFiltersOpen(!isAdvancedFiltersOpen)
|
|
919
|
+
}
|
|
920
|
+
onClearFilters={clearFilters}
|
|
921
|
+
showRoleFilter={showRoleFilter}
|
|
922
|
+
showManagerFilter={showManagerFilter}
|
|
923
|
+
showTermTimeFilter={showTermTimeFilter}
|
|
924
|
+
showMaternityFilter={showMaternityFilter}
|
|
925
|
+
showStartDateFilter={showStartDateFilter}
|
|
926
|
+
showEndDateFilter={showEndDateFilter}
|
|
927
|
+
showDbsFilter={showDbsFilter}
|
|
928
|
+
showWorkingHoursFilter={showWorkingHoursFilter}
|
|
929
|
+
/>
|
|
930
|
+
)}
|
|
910
931
|
|
|
911
932
|
{/* Results */}
|
|
912
933
|
<div className="bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700">
|