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