import React, { useEffect } from 'react' import { Typography, Container, SkeletonLoader } from '@toptal/picasso' import { useNotifications } from '@toptal/picasso/utils' import { useGetCountries } from './data' export const COUNTRIES_ERROR_MESSAGE = "Couldn't get list of countries" const NUMBER_OF_COUNTRIES = 5 const AddressDetails = () => { const { showError } = useNotifications() const { loading: countriesLoading, data: countriesData, error, } = useGetCountries() useEffect(() => { if (error) { showError(COUNTRIES_ERROR_MESSAGE) } }, [!!error]) if (error) { return null } if (countriesLoading) { return ( ) } return ( <> Top {NUMBER_OF_COUNTRIES} countries from GQL Gateway API: {countriesData?.countries.nodes .slice(0, NUMBER_OF_COUNTRIES) .map(country => ( {country.googleName} ))} ) } AddressDetails.displayName = 'AddressDetails' export default AddressDetails