resolved localCompare error
This commit is contained in:
parent
cbf376d5b6
commit
7c9607cb78
@ -64,7 +64,7 @@ const AttendanceLog = ({
|
||||
const sortByName = (a, b) => {
|
||||
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
|
||||
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
|
||||
return nameA.localeCompare(nameB);
|
||||
return nameA?.localeCompare(nameB);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -20,7 +20,7 @@ const Regularization = ({ handleRequest }) => {
|
||||
const sortByName = (a, b) => {
|
||||
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
|
||||
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
|
||||
return nameA.localeCompare(nameB);
|
||||
return nameA?.localeCompare(nameB);
|
||||
};
|
||||
const filteredData = [...regularizesList]?.sort(sortByName);
|
||||
|
||||
|
@ -510,7 +510,7 @@ const ManageEmployee = ({ employeeId, onClosed }) => {
|
||||
Select Role
|
||||
</option>
|
||||
{[...job_role]
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.sort((a, b) => a?.name?.localeCompare(b.name))
|
||||
.map((item) => (
|
||||
<option value={item?.id} key={item.id}>
|
||||
{item?.name}{" "}
|
||||
|
@ -273,7 +273,7 @@ const EditActivityModal = ({
|
||||
activities
|
||||
.slice()
|
||||
.sort((a, b) =>
|
||||
(a.activityName || "").localeCompare(
|
||||
(a.activityName || "")?.localeCompare(
|
||||
b.activityName || ""
|
||||
)
|
||||
)
|
||||
@ -312,7 +312,7 @@ const EditActivityModal = ({
|
||||
categories
|
||||
.slice()
|
||||
.sort((a, b) =>
|
||||
(a.name || "").localeCompare(
|
||||
(a.name || "")?.localeCompare(
|
||||
b.name || ""
|
||||
)
|
||||
)
|
||||
|
@ -140,7 +140,7 @@ const FloorModel = ({
|
||||
buildings
|
||||
.filter((building) => building?.name)
|
||||
.sort((a, b) =>
|
||||
(a.name || "").localeCompare(b.name || "")
|
||||
(a.name || "")?.localeCompare(b.name || "")
|
||||
)
|
||||
.map((building) => (
|
||||
<option key={building.id} value={building.id}>
|
||||
@ -172,7 +172,7 @@ const FloorModel = ({
|
||||
[...selectedBuilding.floors]
|
||||
.filter((floor) => floor?.floorName)
|
||||
.sort((a, b) =>
|
||||
(a.floorName || "").localeCompare(
|
||||
(a.floorName || "")?.localeCompare(
|
||||
b.floorName || ""
|
||||
)
|
||||
)
|
||||
|
@ -159,7 +159,7 @@ const TaskModel = ({
|
||||
const newCategories = categories?.slice()?.sort((a, b) => {
|
||||
const nameA = a?.name || "";
|
||||
const nameB = b?.name || "";
|
||||
return nameA.localeCompare(nameB);
|
||||
return nameA?.localeCompare(nameB);
|
||||
});
|
||||
setCategoryData(newCategories);
|
||||
setSelectedCategory(newCategories[0])
|
||||
@ -230,7 +230,7 @@ const TaskModel = ({
|
||||
(floor) =>
|
||||
floor?.floorName && Array.isArray(floor.workAreas)
|
||||
)
|
||||
?.sort((a, b) => a.floorName.localeCompare(b.floorName))
|
||||
?.sort((a, b) => a.floorName?.localeCompare(b.floorName))
|
||||
?.map((floor) => (
|
||||
<option key={floor.id} value={floor.id}>
|
||||
{floor.floorName} - ({floor.workAreas.length} Work
|
||||
@ -263,7 +263,7 @@ const TaskModel = ({
|
||||
<option value="0">Select Work Area</option>
|
||||
{selectedFloor.workAreas
|
||||
?.filter((workArea) => workArea?.areaName)
|
||||
?.sort((a, b) => a.areaName.localeCompare(b.areaName))
|
||||
?.sort((a, b) => a.areaName?.localeCompare(b.areaName))
|
||||
?.map((workArea) => (
|
||||
<option key={workArea.id} value={workArea.id}>
|
||||
{workArea.areaName}
|
||||
@ -299,7 +299,7 @@ const TaskModel = ({
|
||||
?.sort((a, b) => {
|
||||
const nameA = a?.activityName || "";
|
||||
const nameB = b?.activityName || "";
|
||||
return nameA.localeCompare(nameB);
|
||||
return nameA?.localeCompare(nameB);
|
||||
})
|
||||
?.map((activity) => (
|
||||
<option key={activity.id} value={activity.id}>
|
||||
|
@ -197,7 +197,7 @@ const WorkAreaModel = ({
|
||||
?.sort((a, b) => {
|
||||
const nameA = a.floorName || "";
|
||||
const nameB = b.floorName || "";
|
||||
return nameA.localeCompare(nameB);
|
||||
return nameA?.localeCompare(nameB);
|
||||
})
|
||||
?.map((floor) => (
|
||||
<option key={floor.id} value={floor.id}>
|
||||
@ -231,7 +231,7 @@ const WorkAreaModel = ({
|
||||
?.sort((a, b) => {
|
||||
const nameA = a.areaName || "";
|
||||
const nameB = b.areaName || "";
|
||||
return nameA.localeCompare(nameB);
|
||||
return nameA?.localeCompare(nameB);
|
||||
})
|
||||
?.map((workArea) => (
|
||||
<option key={workArea.id} value={workArea.id}>
|
||||
|
@ -18,7 +18,7 @@ export const useProjects = () => {
|
||||
const filterProjects = (projectsList) => {
|
||||
return projectsList
|
||||
.filter((proj) => projectIds.includes(String(proj.id)))
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
.sort((a, b) => a?.name?.localeCompare(b.name));
|
||||
};
|
||||
|
||||
const projects_cache = getCachedData("projectslist");
|
||||
|
@ -181,7 +181,7 @@ const Directory = ({ IsPage = true, prefernceContacts }) => {
|
||||
(c.bucketIds || []).some((id) => selectedBucketIds.includes(id));
|
||||
|
||||
return matchesSearch && matchesCategory && matchesBucket;
|
||||
}).sort((a, b) => a.name.localeCompare(b.name));
|
||||
}).sort((a, b) => a?.name?.localeCompare(b.name));
|
||||
}, [
|
||||
ContactList,
|
||||
searchText,
|
||||
|
@ -42,7 +42,7 @@ const AttendancesEmployeeRecords = ({ employee }) => {
|
||||
const sortByName = (a, b) => {
|
||||
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
|
||||
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
|
||||
return nameA.localeCompare(nameB);
|
||||
return nameA?.localeCompare(nameB);
|
||||
};
|
||||
|
||||
const group1 = data
|
||||
|
@ -85,7 +85,7 @@ const EmployeeList = () => {
|
||||
}`.toLowerCase();
|
||||
const nameB = `${b.firstName || ""}${b.middleName || ""}${b.lastName || ""
|
||||
}`.toLowerCase();
|
||||
return nameA.localeCompare(nameB);
|
||||
return nameA?.localeCompare(nameB);
|
||||
});
|
||||
|
||||
setEmployeeList(sorted);
|
||||
@ -559,7 +559,7 @@ const EmployeeList = () => {
|
||||
</td>
|
||||
|
||||
<td className=" d-none d-md-table-cell">
|
||||
{moment(item.joiningDate).format("DD-MMM-YYYY")}
|
||||
{moment(item.joiningDate)?.format("DD-MMM-YYYY")}
|
||||
</td>
|
||||
<td>
|
||||
{showInactive ? (
|
||||
|
@ -34,7 +34,7 @@ const MasterTable = ({ data, columns, loading, handleModalData }) => {
|
||||
if (!sortKey) return 0;
|
||||
const aValue = a[sortKey] || "";
|
||||
const bValue = b[sortKey] || "";
|
||||
return aValue.localeCompare(bValue);
|
||||
return aValue?.localeCompare(bValue);
|
||||
});
|
||||
|
||||
// Pagination logic
|
||||
|
@ -50,7 +50,7 @@ const ProjectList = () => {
|
||||
.filter((statusId) => grouped[statusId])
|
||||
.flatMap((statusId) =>
|
||||
grouped[statusId].sort((a, b) =>
|
||||
a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
||||
a.name.toLowerCase()?.localeCompare(b.name.toLowerCase())
|
||||
)
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user