Files
supabase/studio/components/interfaces/Auth/Users/UsersListItem.tsx
T
Ivan Vasilov 76db9f27b3 Migrate dropdowns to use the new Dropdown component (#17427)
* Remove unneeded component.

* Update the dropdown content to support size prop (medium by default). Add space-x-2 to the dropdown item. Add flex to DropdownTrigger so that it's more vertically centered.

* Migrate Insert row dropdown in the TableEditor.

* Refactor UserDropdown to use the new Dropdown from shadcn.

* Migrate the ColumnMenu to use the new dropdown.

* Migrate the rest of the dropdowns.

* Remove the size prop and set the w-64 as default.

* Fix build errors.

* More dropdown fixes.

* More fixes.

* More fixes to various dropdowns.

* Remove the flex from the DropdownTrigger and add it in where it's needed.

* Snapshot.

* Remove keys on dropdown separators.

* Fix the dropdown in the SQL editor.

* Minor type fix.

* Remove space-x-2 from DropdownMenuItem and add it to each item where it's needed.

* Remove the space from the dropdown item.

* Fix a build error.

* Fix the item text in some of the dropdowns.

* Remove duplicate CSS from all dropdown items.

* The SubMenuContent text should be lighter to match MenuContent.

* Fix various CSS issues.

* Revert "Remove unneeded component."

This reverts commit ef606f6695.

* Fix migrated CSS classes.

* Last round of feedback fixes.
2023-09-26 15:29:07 +02:00

65 lines
2.2 KiB
TypeScript

import { Badge } from 'ui'
import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'
import Table from 'components/to-be-cleaned/Table'
import { User } from 'data/auth/users-query'
import UserDropdown from './UserDropdown'
import { getDateFromIsoString } from './Users.utils'
interface UserListItemProps {
user: User
canRemoveUser: boolean
canRemoveMFAFactors: boolean
}
const UserListItem = ({ user, canRemoveUser, canRemoveMFAFactors }: UserListItemProps) => {
const isUserConfirmed = user.email_confirmed_at || user.phone_confirmed_at
const createdAt = getDateFromIsoString(user.created_at)
const lastSignedIn = getDateFromIsoString(user.last_sign_in_at)
return (
<Table.tr className="relative" key={user.id}>
<Table.td className="whitespace-nowrap">
<div className="flex items-center gap-2">
<span className="text-sm text-foreground">{!user.email ? '-' : user.email}</span>
</div>
</Table.td>
<Table.td className="whitespace-nowrap">
<span className="text-foreground">{!user.phone ? '-' : user.phone}</span>
</Table.td>
<Table.td className="table-cell">
<span className="capitalize text-foreground">{user?.raw_app_meta_data?.provider}</span>
</Table.td>
<Table.td className="table-cell">
<span className="text-foreground">{createdAt?.format('DD MMM, YYYY HH:mm')}</span>
</Table.td>
<Table.td className="table-cell">
{!isUserConfirmed ? (
<Badge color="yellow">Waiting for verification..</Badge>
) : user.last_sign_in_at ? (
lastSignedIn?.format('DD MMM, YYYY HH:mm')
) : (
'Never'
)}
</Table.td>
<Table.td className="table-cell">
<div className="flex max-w-[72px] items-baseline">
<SimpleCodeBlock metastring="" className="font-xs bash">
{user.id}
</SimpleCodeBlock>
<div>...</div>
</div>
</Table.td>
<Table.td className="table-cell">
<UserDropdown
user={user}
canRemoveUser={canRemoveUser}
canRemoveMFAFactors={canRemoveMFAFactors}
/>
</Table.td>
</Table.tr>
)
}
export default UserListItem