sessionRow.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import styled from '@emotion/styled';
  2. import PanelItem from 'sentry/components/panels/panelItem';
  3. import TimeSince from 'sentry/components/timeSince';
  4. import {space} from 'sentry/styles/space';
  5. import type {InternetProtocol} from 'sentry/types';
  6. import {tableLayout} from './utils';
  7. function SessionRow({
  8. ipAddress,
  9. lastSeen,
  10. firstSeen,
  11. countryCode,
  12. regionCode,
  13. }: Omit<InternetProtocol, 'id'>) {
  14. return (
  15. <SessionPanelItem>
  16. <IpAndLocation>
  17. <IpAddress>{ipAddress}</IpAddress>
  18. {countryCode && regionCode && (
  19. <CountryCode>{`${countryCode} (${regionCode})`}</CountryCode>
  20. )}
  21. </IpAndLocation>
  22. <div>
  23. <StyledTimeSince date={firstSeen} />
  24. </div>
  25. <div>
  26. <StyledTimeSince date={lastSeen} />
  27. </div>
  28. </SessionPanelItem>
  29. );
  30. }
  31. export default SessionRow;
  32. const IpAddress = styled('div')`
  33. margin-bottom: ${space(0.5)};
  34. font-weight: bold;
  35. `;
  36. const CountryCode = styled('div')`
  37. font-size: ${p => p.theme.fontSizeRelativeSmall};
  38. `;
  39. const StyledTimeSince = styled(TimeSince)`
  40. font-size: ${p => p.theme.fontSizeRelativeSmall};
  41. `;
  42. const IpAndLocation = styled('div')`
  43. flex: 1;
  44. `;
  45. const SessionPanelItem = styled(PanelItem)`
  46. ${tableLayout};
  47. `;