customerInvoices.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import moment from 'moment-timezone';
  2. import {Tag} from 'sentry/components/core/badge/tag';
  3. import Link from 'sentry/components/links/link';
  4. import ResultGrid from 'admin/components/resultGrid';
  5. type Props = Partial<React.ComponentProps<typeof ResultGrid>> & {
  6. orgId: string;
  7. region: string;
  8. };
  9. const getRow = (orgId: string, region: string, row: any) => [
  10. <td key="name">
  11. <Link to={`/_admin/customers/${orgId}/invoices/${region}/${row.id}/`}>
  12. {moment(row.dateCreated).format('ll')}
  13. </Link>
  14. </td>,
  15. <td key="stripeId" style={{textAlign: 'center'}}>
  16. <a href={`https://dashboard.stripe.com/invoices/${row.stripeInvoiceID}`}>
  17. {row.stripeInvoiceID}
  18. </a>
  19. </td>,
  20. <td key="channel" style={{textAlign: 'center'}}>
  21. {row.channel || 'n/a'}
  22. </td>,
  23. <td key="status" style={{textAlign: 'center'}}>
  24. <Tag type={row.isPaid ? 'success' : 'warning'}>{row.isPaid ? 'Paid' : 'Pending'}</Tag>
  25. </td>,
  26. <td key="amount" style={{textAlign: 'right'}}>
  27. ${(row.amount / 100).toLocaleString()}
  28. <br />
  29. {row.isRefunded && (
  30. <small>(${(row.amountRefunded / 100).toLocaleString()} refunded)</small>
  31. )}
  32. </td>,
  33. ];
  34. function CustomerInvoices({orgId, region, ...props}: Props) {
  35. return (
  36. <ResultGrid
  37. path={`/_admin/customers/${orgId}/`}
  38. endpoint={`/customers/${orgId}/invoices/`}
  39. method="GET"
  40. defaultParams={{per_page: 10}}
  41. columns={[
  42. <th key="name">Invoice</th>,
  43. <th key="stripeId" style={{width: 150, textAlign: 'center'}}>
  44. Stripe ID
  45. </th>,
  46. <th key="channel" style={{width: 100, textAlign: 'center'}}>
  47. Channel
  48. </th>,
  49. <th key="status" style={{width: 100, textAlign: 'center'}}>
  50. Status
  51. </th>,
  52. <th key="amount" style={{width: 150, textAlign: 'right'}}>
  53. Amount
  54. </th>,
  55. ]}
  56. columnsForRow={row => getRow(orgId, region, row)}
  57. {...props}
  58. />
  59. );
  60. }
  61. export default CustomerInvoices;