Added a "last login" to the users
This commit is contained in:
@@ -279,10 +279,10 @@ export default function UserList({
|
||||
) as any,
|
||||
cell: (info) =>
|
||||
info.getValue()
|
||||
? `${countryCodes.findOne("countryCode" as any, info.getValue()).flag} ${
|
||||
countries[info.getValue() as unknown as keyof TCountries].name
|
||||
} (+${countryCodes.findOne("countryCode" as any, info.getValue()).countryCallingCode})`
|
||||
: "Not available",
|
||||
? `${countryCodes.findOne("countryCode" as any, info.getValue())?.flag} ${
|
||||
countries[info.getValue() as unknown as keyof TCountries]?.name
|
||||
} (+${countryCodes.findOne("countryCode" as any, info.getValue())?.countryCallingCode})`
|
||||
: "N/A",
|
||||
}),
|
||||
columnHelper.accessor("demographicInformation.phone", {
|
||||
header: (
|
||||
@@ -291,7 +291,7 @@ export default function UserList({
|
||||
<SorterArrow name="phone" />
|
||||
</button>
|
||||
) as any,
|
||||
cell: (info) => info.getValue() || "Not available",
|
||||
cell: (info) => info.getValue() || "N/A",
|
||||
enableSorting: true,
|
||||
}),
|
||||
columnHelper.accessor(
|
||||
@@ -301,14 +301,23 @@ export default function UserList({
|
||||
id: "employment",
|
||||
header: (
|
||||
<button className="flex gap-2 items-center" onClick={() => setSorter((prev) => selectSorter(prev, "employment"))}>
|
||||
<span>Employment/Position</span>
|
||||
<span>Employment</span>
|
||||
<SorterArrow name="employment" />
|
||||
</button>
|
||||
) as any,
|
||||
cell: (info) => (info.row.original.type === "corporate" ? info.getValue() : capitalize(info.getValue())) || "Not available",
|
||||
cell: (info) => (info.row.original.type === "corporate" ? info.getValue() : capitalize(info.getValue())) || "N/A",
|
||||
enableSorting: true,
|
||||
},
|
||||
),
|
||||
columnHelper.accessor("lastLogin", {
|
||||
header: (
|
||||
<button className="flex gap-2 items-center" onClick={() => setSorter((prev) => selectSorter(prev, "lastLogin"))}>
|
||||
<span>Last Login</span>
|
||||
<SorterArrow name="lastLogin" />
|
||||
</button>
|
||||
) as any,
|
||||
cell: (info) => (!!info.getValue() ? moment(info.getValue()).format("YYYY-MM-DD HH:mm") : "N/A"),
|
||||
}),
|
||||
columnHelper.accessor("demographicInformation.gender", {
|
||||
header: (
|
||||
<button className="flex gap-2 items-center" onClick={() => setSorter((prev) => selectSorter(prev, "gender"))}>
|
||||
@@ -316,7 +325,7 @@ export default function UserList({
|
||||
<SorterArrow name="gender" />
|
||||
</button>
|
||||
) as any,
|
||||
cell: (info) => capitalize(info.getValue()) || "Not available",
|
||||
cell: (info) => capitalize(info.getValue()) || "N/A",
|
||||
enableSorting: true,
|
||||
}),
|
||||
{
|
||||
@@ -379,7 +388,7 @@ export default function UserList({
|
||||
columnHelper.accessor("corporateInformation.companyInformation.name", {
|
||||
header: (
|
||||
<button className="flex gap-2 items-center" onClick={() => setSorter((prev) => selectSorter(prev, "companyName"))}>
|
||||
<span>Company Name</span>
|
||||
<span>Company</span>
|
||||
<SorterArrow name="companyName" />
|
||||
</button>
|
||||
) as any,
|
||||
@@ -388,7 +397,7 @@ export default function UserList({
|
||||
columnHelper.accessor("subscriptionExpirationDate", {
|
||||
header: (
|
||||
<button className="flex gap-2 items-center" onClick={() => setSorter((prev) => selectSorter(prev, "expiryDate"))}>
|
||||
<span>Expiry Date</span>
|
||||
<span>Expiration</span>
|
||||
<SorterArrow name="expiryDate" />
|
||||
</button>
|
||||
) as any,
|
||||
@@ -401,7 +410,7 @@ export default function UserList({
|
||||
columnHelper.accessor("isVerified", {
|
||||
header: (
|
||||
<button className="flex gap-2 items-center" onClick={() => setSorter((prev) => selectSorter(prev, "verification"))}>
|
||||
<span>Verification</span>
|
||||
<span>Verified</span>
|
||||
<SorterArrow name="verification" />
|
||||
</button>
|
||||
) as any,
|
||||
@@ -464,6 +473,15 @@ export default function UserList({
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sorter === "lastLogin" || sorter === reverseString("lastLogin")) {
|
||||
if (!a.lastLogin && b.lastLogin) return sorter === "lastLogin" ? -1 : 1;
|
||||
if (a.lastLogin && !b.lastLogin) return sorter === "lastLogin" ? 1 : -1;
|
||||
if (!a.lastLogin && !b.lastLogin) return 0;
|
||||
if (moment(a.lastLogin).isAfter(b.lastLogin)) return sorter === "lastLogin" ? -1 : 1;
|
||||
if (moment(b.lastLogin).isAfter(a.lastLogin)) return sorter === "lastLogin" ? 1 : -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sorter === "country" || sorter === reverseString("country")) {
|
||||
if (!a.demographicInformation?.country && b.demographicInformation?.country) return sorter === "country" ? -1 : 1;
|
||||
if (a.demographicInformation?.country && !b.demographicInformation?.country) return sorter === "country" ? 1 : -1;
|
||||
|
||||
Reference in New Issue
Block a user