()
| 7 | import styles from './Commerce.styles'; |
| 8 | |
| 9 | export const Commerce = () => { |
| 10 | const handleClick = (item: CommerceItem) => { |
| 11 | const purchasedItem = new IterableCommerceItem( |
| 12 | item.id, |
| 13 | item.name, |
| 14 | item.price, |
| 15 | 1 |
| 16 | ); |
| 17 | const totalPrice = item.price; |
| 18 | const purchaseItems = [purchasedItem]; |
| 19 | const dataFields = null; |
| 20 | |
| 21 | Iterable.trackPurchase(totalPrice, purchaseItems, dataFields); |
| 22 | |
| 23 | console.group('Purchase tracked with the following arguments:'); |
| 24 | console.log('Total price:', totalPrice); |
| 25 | console.log('Purchase items:', [...purchaseItems]); |
| 26 | console.log('Data fields:', dataFields); |
| 27 | console.groupEnd(); |
| 28 | |
| 29 | Alert.alert( |
| 30 | `Tracked purchase: ${item.name}, $${item.price}`, |
| 31 | 'Check logs for output' |
| 32 | ); |
| 33 | }; |
| 34 | |
| 35 | return ( |
| 36 | <SafeAreaView> |
| 37 | <ScrollView> |
| 38 | <View style={styles.container}> |
| 39 | <Text style={styles.title}>Commerce</Text> |
| 40 | <Text style={styles.subtitle}> |
| 41 | Purchase will be tracked when "Buy" is clicked. See logs for |
| 42 | output. |
| 43 | </Text> |
| 44 | {items.map((item) => ( |
| 45 | <View key={item.id} style={styles.cardContainer}> |
| 46 | <View style={styles.infoContainer}> |
| 47 | <View style={styles.imageContainer}> |
| 48 | <Image source={item.icon} style={styles.cardImage} /> |
| 49 | </View> |
| 50 | <View style={styles.textContainer}> |
| 51 | <Text style={styles.cardTitle}>{item.name}</Text> |
| 52 | <Text style={styles.cardSubtitle}>{item.subtitle}</Text> |
| 53 | <Text style={styles.price}>${item.price}</Text> |
| 54 | <Pressable |
| 55 | style={styles.button} |
| 56 | onPress={() => handleClick(item)} |
| 57 | > |
| 58 | <Text style={styles.buttonText}>Buy</Text> |
| 59 | </Pressable> |
| 60 | </View> |
| 61 | </View> |
| 62 | </View> |
| 63 | ))} |
| 64 | </View> |
| 65 | </ScrollView> |
| 66 | </SafeAreaView> |
nothing calls this directly
no test coverage detected
searching dependent graphs…