import React from 'react';
import { View, StyleSheet, ScrollView } from 'react-native';
import {
PaymentOptionStripe,
useSession,
useLanguage
} from 'ordering-components/native';
import { PlaceholderLine } from 'rn-placeholder';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import { getIconCard } from '../../utils';
import { OAlert, OText } from '../shared';
import { NotFoundSource } from '../NotFoundSource';
import {
OSItem,
OSItemContent,
OSItemActions,
} from '../PaymentOptionStripe/styles';
import { useTheme } from 'styled-components/native';
const StripeCardsListUI = (props: any) => {
const {
onSelectCard,
deleteCard,
cardSelected,
cardsList,
handleCardClick,
} = props;
const theme = useTheme();
const [{ token }] = useSession();
const [, t] = useLanguage();
const handleCardSelected = (card: any) => {
handleCardClick(card);
onSelectCard(card);
}
return (
<>
{token && !cardsList.loading && cardsList.cards && cardsList.cards.length === 0 && (
{t('YOU_DONT_HAVE_CARDS', 'You don\'t have cards')}
)}
{token && cardsList.error && cardsList.error.length > 0 && (
)}
{token && cardsList.loading && (
{[...Array(2)].map((_, i) => (
))}
)}
{token && cardsList.cards && cardsList.cards.length > 0 && (
{cardsList.cards.map((card: any) => (
handleCardSelected(card)}>
{card.id === cardSelected?.id ? (
) : (
)}
{getIconCard(card.brand, 26)}
XXXX-XXXX-XXXX-{card.last4}
deleteCard(card)}
>
))}
)}
>
)
}
const styles = StyleSheet.create({
viewStyle: {
marginRight: 5
},
cardsList: {
width: '100%',
maxHeight: 130
},
})
export const StripeCardsList = (props: any) => {
const stripeCardsListProps = {
...props,
UIComponent: StripeCardsListUI
}
return (
)
}