utils.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { SingleEvent } from '@api/events';
  2. import { Text } from 'react-native';
  3. export const renderSpotsText = (e: SingleEvent) => {
  4. if (e.type === 4) {
  5. if (e.interested > 0 && e.joining > 0) {
  6. return (
  7. <Text>
  8. <Text style={{ fontWeight: '700' }}>{e.interested}</Text> interested /{' '}
  9. <Text style={{ fontWeight: '700' }}>{e.joining}</Text> going
  10. </Text>
  11. );
  12. } else if (e.interested > 0) {
  13. return (
  14. <Text>
  15. <Text style={{ fontWeight: '700' }}>{e.interested}</Text> interested
  16. </Text>
  17. );
  18. } else if (e.joining > 0) {
  19. return (
  20. <Text>
  21. <Text style={{ fontWeight: '700' }}>{e.joining}</Text> going
  22. </Text>
  23. );
  24. }
  25. }
  26. // if (e.type === 1 && e.joining > 0) {
  27. if (e.joining > 0) {
  28. return (
  29. <Text>
  30. <Text style={{ fontWeight: '700' }}>{e.joining}</Text> going
  31. </Text>
  32. );
  33. }
  34. switch (e.registrations_info) {
  35. case 2:
  36. return (
  37. <Text>
  38. <Text style={{ fontWeight: '700' }}>{(e.capacity ?? 0) - (e.available ?? 0)}</Text> total
  39. spots available
  40. </Text>
  41. );
  42. case 3:
  43. return (
  44. <Text>
  45. <Text style={{ fontWeight: '700' }}>{e.available}</Text> spots remaining
  46. </Text>
  47. );
  48. case 4:
  49. return (
  50. <Text>
  51. <Text style={{ fontWeight: '700' }}>{e.participants}</Text> Nomads interested
  52. </Text>
  53. );
  54. case 5:
  55. return (
  56. <Text>
  57. <Text style={{ fontWeight: '700' }}>
  58. {e.available ?? (e.capacity ?? 0) - (e.participants ?? 0)} / {e.capacity}
  59. </Text>{' '}
  60. spots available
  61. </Text>
  62. );
  63. default:
  64. return '';
  65. }
  66. };