index.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. },
  45. {
  46. label: 'Trips',
  47. icon: <TripIcon fill={Colors.DARK_BLUE} width={20} height={20} />,
  48. },
  49. {
  50. label: 'Photos',
  51. icon: <ImagesIcon fill={Colors.DARK_BLUE} width={20} height={20} />,
  52. },
  53. ];
  54. return (
  55. <PageWrapper>
  56. {buttons.map((button, index) => (
  57. <MenuButton
  58. label={button.label}
  59. icon={button.icon}
  60. buttonFn={button.buttonFn}
  61. key={'travels-button-' + index}
  62. />
  63. ))}
  64. <WarningModal
  65. type={'unauthorized'}
  66. isVisible={isModalVisible}
  67. onClose={() => setIsModalVisible(false)}
  68. />
  69. </PageWrapper>
  70. );
  71. };
  72. export default TravelsScreen;