All files / src/screens/home/CarouselView CarouselView.tsx

0% Statements 0/1
100% Branches 0/0
0% Functions 0/1
0% Lines 0/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71                                                                                                                                             
/**
 * @fileoverview Carousel view component
 * @module CarouselView
 * @description Component that renders the carousel view, it allows users to see places in a carousel.
 * @requires react react-native
 * @requires ScrollView react-native
 * @requires RefreshControl react-native
 */
import React from 'react'
import { RefreshControl, ScrollView } from 'react-native'
import { Place } from '@global/types/Places'
import Category from './Views/Category'
 
interface CarouselViewProps {
  places: Place[]
  latestPlaces: Place[]
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  navigation: any
  getNearestPlaces: () => Place[]
  isLoading: boolean
  onRefresh: () => void
}
 
/**
 * @function CarouselView
 * @description Component that renders the carousel view.
 * @param places Places to display on the carousel
 * @param navigation Navigation object
 * @param getNearestPlaces Function to get the nearest places
 * @param isLoading Loading state of the carousel
 * @param onRefresh Function to refresh the carousel
 * @returns {React.JSX.Element}
 */
export default function CarouselView({
  places,
  latestPlaces,
  navigation,
  getNearestPlaces,
  isLoading,
  onRefresh,
}: CarouselViewProps): React.JSX.Element {
  return (
    <ScrollView
      style={{ paddingLeft: 20 }}
      showsVerticalScrollIndicator={false}
      refreshControl={
        <RefreshControl
          refreshing={isLoading}
          onRefresh={onRefresh}
        />
      }
    >
      <Category
        text='Découvrir des musées'
        places={places}
        navigation={navigation}
      />
      <Category
        text='Nouveaux lieux'
        places={latestPlaces}
        navigation={navigation}
      />
      <Category
        text='Lieux à proximité'
        places={getNearestPlaces()}
        navigation={navigation}
      />
    </ScrollView>
  )
}