Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add formatter helper for date time for safari browser and fix auth pages

Joshen Limd5b71185b3bc
diff --git a/studio/components/interfaces/Authentication/Users/UsersListItem.tsx b/studio/components/interfaces/Authentication/Users/UsersListItem.tsx
index 471e226e733..4e39ffd4e11 100644
--- a/studio/components/interfaces/Authentication/Users/UsersListItem.tsx
+++ b/studio/components/interfaces/Authentication/Users/UsersListItem.tsx
@@ -1,9 +1,10 @@
import dayjs from 'dayjs'
import { FC } from 'react'
import { observer } from 'mobx-react-lite'
-import { Badge, IconUser, Typography } from '@supabase/ui'
-import Table from 'components/to-be-cleaned/Table'
+import { Badge } from '@supabase/ui'
+import { formatPgDateString } from 'lib/helpers'
+import Table from 'components/to-be-cleaned/Table'
import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'
import UserDropdown from './UserDropdown'
@@ -13,6 +14,9 @@ interface Props {
const UserListItem: FC<Props> = ({ user }) => {
const isUserConfirmed = user.email_confirmed_at || user.phone_confirmed_at
+ const createdAt = formatPgDateString(user.created_at)
+ const lastSignedIn = formatPgDateString(user.last_sign_in_at)
+
return (
<Table.tr key={user.id}>
<Table.td className="whitespace-nowrap">
@@ -29,15 +33,13 @@ const UserListItem: FC<Props> = ({ user }) => {
</span>
</Table.td>
<Table.td className="hidden 2xl:table-cell">
- <span className="text-scale-1200">
- {dayjs(user.created_at).format('DD MMM, YYYY HH:mm')}
- </span>
+ <span className="text-scale-1200">{dayjs(createdAt).format('DD MMM, YYYY HH:mm')}</span>
</Table.td>
<Table.td className="hidden xl:table-cell">
{!isUserConfirmed ? (
<Badge color="yellow">Waiting for verification..</Badge>
) : user.last_sign_in_at ? (
- dayjs(user.last_sign_in_at).format('DD MMM, YYYY HH:mm')
+ dayjs(lastSignedIn).format('DD MMM, YYYY HH:mm')
) : (
'Never'
)}
diff --git a/studio/lib/helpers.ts b/studio/lib/helpers.ts
index 286697320bf..48f737e7346 100644
--- a/studio/lib/helpers.ts
+++ b/studio/lib/helpers.ts
@@ -198,3 +198,34 @@ export async function passwordStrength(value: string) {
strength,
}
}
+
+export const detectBrowser = () => {
+ if (!navigator) return undefined
+
+ if (navigator.userAgent.indexOf('Chrome') !== -1) {
+ return 'Chrome'
+ } else if (navigator.userAgent.indexOf('Firefox') !== -1) {
+ return 'Firefox'
+ } else if (navigator.userAgent.indexOf('Safari') !== -1) {
+ return 'Safari'
+ }
+}
+
+/**
+ * Formats a PG datetime string into a format that's
+ * readable across browsers.
+ * - Postgres: 2022-05-12 09:24:12.639463+00
+ *
+ * These are the acceptable formats that Joshen has experimented so far
+ * - Chrome: 2022-05-12 09:24:12.639463+00 (No format required)
+ * - Firefox: 2022-05-12 09:24:12.639463+00 (No format required)
+ * - Safari: 2022-05-12T09:24:12.639463+00
+ */
+export const formatPgDateString = (dateString: string) => {
+ const browser = detectBrowser()
+ if (browser === 'Safari') {
+ return dateString.replace(' ', 'T')
+ } else {
+ return dateString
+ }
+}