index.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import React, { useState } from 'react';
  2. import { Colors } from '../../../theme';
  3. import { PageWrapper, MenuButton, WarningModal } from '../../../components';
  4. import { MenuButtonType } from '../../../types/components';
  5. import FlagsIcon from '../../../../assets/icons/travels-section/flags.svg';
  6. import RegionsIcon from '../../../../assets/icons/travels-section/regions.svg';
  7. import MapLocationIcon from '../../../../assets/icons/travels-section/map-location.svg';
  8. import SeriesIcon from '../../../../assets/icons/travels-section/series.svg';
  9. import EarthIcon from '../../../../assets/icons/travels-section/earth.svg';
  10. import TripIcon from '../../../../assets/icons/travels-section/trip.svg';
  11. import ImagesIcon from '../../../../assets/icons/travels-section/images.svg';
  12. import { NAVIGATION_PAGES } from 'src/types';
  13. import { storage, StoreType } from '../../../storage';
  14. const TravelsScreen = () => {
  15. const [isModalVisible, setIsModalVisible] = useState(false);
  16. const token = storage.get('token', StoreType.STRING);
  17. const buttons: MenuButtonType[] = [
  18. {
  19. label: 'Countries',
  20. icon: <FlagsIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  21. },
  22. {
  23. label: 'Regions',
  24. icon: <RegionsIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  25. },
  26. {
  27. label: 'DARE',
  28. icon: <MapLocationIcon fill={Colors.DARK_BLUE} width={20} height={20} />
  29. },
  30. {
  31. label: 'Series',
  32. icon: <SeriesIcon fill={Colors.DARK_BLUE} width={20} height={20} />,
  33. buttonFn: (navigation) => {
  34. if (!token) {
  35. setIsModalVisible(true);
  36. } else {
  37. navigation.navigate(NAVIGATION_PAGES.SERIES);
  38. }
  39. }
  40. },
  41. {
  42. label: 'Earth',
  43. icon: <EarthIcon fill={Colors.DARK_BLUE} width={20} height={20} />,
  44. buttonFn: (navigation) => {
  45. if (!token) {
  46. setIsModalVisible(true);
  47. } else {
  48. navigation.navigate(NAVIGATION_PAGES.EARTH);
  49. }
  50. }
  51. },
  52. {
  53. label: 'Trips',
  54. icon: <TripIcon fill={Colors.DARK_BLUE} width={20} height={20} />,
  55. buttonFn: (navigation) => {
  56. if (!token) {
  57. setIsModalVisible(true);
  58. } else {
  59. navigation.navigate(NAVIGATION_PAGES.TRIPS);
  60. }
  61. }
  62. },
  63. {
  64. label: 'Photos',
  65. icon: <ImagesIcon fill={Colors.DARK_BLUE} width={20} height={20} />,
  66. buttonFn: (navigation) => {
  67. if (!token) {
  68. setIsModalVisible(true);
  69. } else {
  70. navigation.navigate(NAVIGATION_PAGES.PHOTOS);
  71. }
  72. }
  73. }
  74. ];
  75. return (
  76. <PageWrapper>
  77. {buttons.map((button, index) => (
  78. <MenuButton
  79. label={button.label}
  80. icon={button.icon}
  81. buttonFn={button.buttonFn}
  82. key={'travels-button-' + index}
  83. />
  84. ))}
  85. <WarningModal
  86. type={'unauthorized'}
  87. isVisible={isModalVisible}
  88. onClose={() => setIsModalVisible(false)}
  89. />
  90. </PageWrapper>
  91. );
  92. };
  93. export default TravelsScreen;