Skip to content

Commit da89e4b

Browse files
committed
Merge branch 'dev'
2 parents 001650b + 206ad39 commit da89e4b

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

admin/src/components/DynamicTable/FirebaseTableRows/FirebaseTableRows.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { CarretDown } from "@strapi/icons";
1111
import { RxCross2, RxCheck } from "react-icons/rx";
1212
import { Typography } from "@strapi/design-system";
1313
import styled from "styled-components";
14+
import { format } from "date-fns";
1415
import { MapProviderToIcon } from "../../../utils/provider";
1516
import { User } from "../../../../../model/User";
1617

@@ -141,6 +142,22 @@ export const FirebaseTableRows = ({
141142
<Td key={data.disabled}>
142143
{data.disabled ? <RxCheck size={24} /> : <RxCross2 size={24} />}
143144
</Td>
145+
<Td key={data.createdAt}>
146+
<TypographyMaxWidth ellipsis textColor="neutral800">
147+
{data.createdAt
148+
? format(new Date(data.createdAt), "yyyy/MM/dd kk:mm")
149+
: data.metadata?.creationTime
150+
? format(new Date(data.metadata.creationTime), "yyyy/MM/dd kk:mm")
151+
: '-'}
152+
</TypographyMaxWidth>
153+
</Td>
154+
<Td key={data.lastSignInTime}>
155+
<TypographyMaxWidth ellipsis textColor="neutral800">
156+
{data.metadata?.lastSignInTime
157+
? format(new Date(data.metadata.lastSignInTime), "yyyy/MM/dd kk:mm")
158+
: '-'}
159+
</TypographyMaxWidth>
160+
</Td>
144161
<Flex alignItems="center" paddingTop={3} gap={4}>
145162
<Box key={data.uid}>
146163
<SimpleMenu

admin/src/components/DynamicTable/TableHeaders.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,30 @@ export const tableHeaders = [
116116
},
117117
key: "__disabled_key__",
118118
},
119+
{
120+
name: "createdAt",
121+
fieldSchema: {
122+
configurable: false,
123+
type: "string",
124+
},
125+
metadatas: {
126+
label: "Created At",
127+
sortable: true,
128+
searchable: false,
129+
},
130+
key: "__createdAt_key__",
131+
},
132+
{
133+
name: "lastSignInTime",
134+
fieldSchema: {
135+
configurable: false,
136+
type: "string",
137+
},
138+
metadatas: {
139+
label: "Last Sign In",
140+
sortable: true,
141+
searchable: false,
142+
},
143+
key: "__lastSignInTime_key__",
144+
},
119145
];

model/User.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface FirebaseUser {
2424
tokensValidAfterTime: string;
2525
phoneNumber: string;
2626
localUser?: StrapiUser;
27+
lastSignInTime?: string; // Computed field for table display
2728
}
2829

2930
export interface StrapiUser {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swensonhe/strapi-plugin-firebase-auth",
3-
"version": "1.0.15",
3+
"version": "1.0.16",
44
"description": "This is a Strapi plugin connect and authenticate users using firebase",
55
"strapi": {
66
"name": "firebase-auth",

server/services/userService.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,31 @@ export default ({ strapi }) => ({
9999
const [sortField, sortOrder] = sort.split(':');
100100

101101
sortedUsers = [...allUsers.users].sort((a, b) => {
102-
const aValue = a[sortField];
103-
const bValue = b[sortField];
102+
let aValue = a[sortField];
103+
let bValue = b[sortField];
104+
105+
// Special handling for createdAt and lastSignInTime - use Firebase metadata
106+
if (sortField === 'createdAt') {
107+
aValue = aValue || a.metadata?.creationTime;
108+
bValue = bValue || b.metadata?.creationTime;
109+
} else if (sortField === 'lastSignInTime') {
110+
// For Last Sign In, only use Firebase metadata (no fallback to Strapi updatedAt)
111+
aValue = a.metadata?.lastSignInTime;
112+
bValue = b.metadata?.lastSignInTime;
113+
}
104114

105115
// Handle null/undefined values - push them to the end
106116
if (aValue == null && bValue == null) return 0;
107117
if (aValue == null) return 1;
108118
if (bValue == null) return -1;
109119

120+
// For date fields (createdAt, lastSignInTime), parse as dates
121+
if (sortField === 'createdAt' || sortField === 'lastSignInTime') {
122+
const aDate = new Date(aValue).getTime();
123+
const bDate = new Date(bValue).getTime();
124+
return sortOrder === 'DESC' ? bDate - aDate : aDate - bDate;
125+
}
126+
110127
// For numeric fields, use numeric comparison
111128
if (typeof aValue === 'number' && typeof bValue === 'number') {
112129
return sortOrder === 'DESC' ? bValue - aValue : aValue - bValue;

0 commit comments

Comments
 (0)