import BlackStarSvg from '@/assets/icons/svg/blackStar.svg'; import { ThemedText } from "@/components/ThemedText"; import { useTranslation } from 'react-i18next'; import { ScrollView, StyleProp, StyleSheet, TouchableOpacity, View, ViewStyle } from "react-native"; import { maxDiscountProduct } from './utils'; interface Props { style?: StyleProp; payType: string; setPayType: (type: string) => void; premiumPay: any; loading: boolean; setShowTerms: (visible: boolean) => void; restorePurchases: () => void; } export interface PayItem { id: number; product_id: number; product_type: string; product_code: string; product_name: string; unit_price: { amount: string; currency: string; }, discount_amount: { amount: string; currency: string; } } const Premium = (props: Props) => { const { style, payType, setPayType, premiumPay, loading, setShowTerms, restorePurchases } = props; const bestValue = maxDiscountProduct(premiumPay)?.product_code const { t } = useTranslation(); return ( {loading ? {t('loading', { ns: 'common' })} : premiumPay?.map((item: PayItem) => { return { setPayType(item?.product_code); }} key={item?.product_code} style={[styles.yearly, { borderColor: payType === item?.product_code ? '#FFB645' : '#E1E1E1', opacity: payType === item?.product_code ? 1 : 0.5 }]} activeOpacity={0.8} > {t('rights.bestValue', { ns: 'personal' })} {item.product_code?.split('_')[item.product_code?.split('_')?.length - 1]} $ {(Number(item.unit_price.amount) - Number(item.discount_amount.amount)).toFixed(2)} $ {item.unit_price.amount} }) } {t('personal:rights.restorePurchase')} {t('personal:rights.restore')} ); } export default Premium; const styles = StyleSheet.create({ proInfo: { borderRadius: 24, display: "flex", width: "100%", }, yearly: { display: "flex", flexDirection: "column", alignItems: "center", gap: 16, borderColor: "#FFB645", borderWidth: 2, borderRadius: 24, width: 200, paddingBottom: 16 }, title: { display: "flex", flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 8, backgroundColor: "#FFB645", borderTopLeftRadius: 20, borderTopRightRadius: 20, padding: 4, width: "100%" }, titleText: { color: '#4C320C', fontWeight: '700' } });