TokenCells.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import dayjs from 'dayjs'
  2. import { TimestampInfo } from 'ui-patterns/TimestampInfo'
  3. import { TableCell } from 'ui/src/components/shadcn/ui/table'
  4. interface TokenNameCellProps {
  5. name: string
  6. tokenAlias: string
  7. }
  8. export const TokenNameCell = ({ name, tokenAlias }: TokenNameCellProps) => (
  9. <TableCell className="w-auto max-w-96">
  10. <p className="truncate" title={name}>
  11. {name}
  12. </p>
  13. <p
  14. className="font-mono text-foreground-lighter truncate text-xs mt-1 max-w-32 sm:max-w-48 lg:max-w-full"
  15. title={tokenAlias}
  16. >
  17. {tokenAlias}
  18. </p>
  19. </TableCell>
  20. )
  21. interface LastUsedCellProps {
  22. lastUsedAt: string | null | undefined
  23. }
  24. export const LastUsedCell = ({ lastUsedAt }: LastUsedCellProps) => (
  25. <TableCell className="text-foreground-light min-w-28">
  26. {lastUsedAt ? (
  27. <TimestampInfo
  28. utcTimestamp={lastUsedAt}
  29. label={dayjs(lastUsedAt).fromNow()}
  30. className="text-sm"
  31. />
  32. ) : (
  33. <p className="text-foreground-light text-sm">Never used</p>
  34. )}
  35. </TableCell>
  36. )
  37. interface ExpiresCellProps {
  38. expiresAt: string | null | undefined
  39. }
  40. export const ExpiresCell = ({ expiresAt }: ExpiresCellProps) => (
  41. <TableCell className="min-w-28 text-foreground-light">
  42. {expiresAt ? (
  43. dayjs(expiresAt).isBefore(dayjs()) ? (
  44. <TimestampInfo utcTimestamp={expiresAt} label="Expired" className="text-sm" />
  45. ) : (
  46. <TimestampInfo
  47. utcTimestamp={expiresAt}
  48. label={dayjs(expiresAt).format('DD MMM YYYY')}
  49. className="text-sm"
  50. />
  51. )
  52. ) : (
  53. <p className="text-foreground-light text-sm">Never</p>
  54. )}
  55. </TableCell>
  56. )