import React from "react"; import { StyleSheet, Dimensions, Image, FlatList, TouchableWithoutFeedback } from "react-native"; import { Block, Text, theme } from "galio-framework"; // butoane text mai gros ca la register screen import { Card, Select, Button } from "../components/"; import { argonTheme } from "../constants/"; import { cart } from "../constants"; const { width } = Dimensions.get("screen"); export default class Cart extends React.Component { state = { cart: cart.products }; handleQuantity = (id, qty) => { const { cart } = this.state; const updatedCart = cart.map(product => { if (product.id === id) product.qty = qty; return product; }); this.setState({ cart: updatedCart }); }; handleDelete = id => { const { cart } = this.state; const updatedCart = cart.filter(product => product.id !== id); this.setState({ cart: updatedCart }); }; handleAdd = item => { const { cart } = this.state; cart.push({ ...item, id: cart.length + 1, stock: true, qty: 1 }); this.setState({ cart }); }; renderProduct = ({ item }) => { const { navigation } = this.props; return ( navigation.navigate("Product", { product: item })} > navigation.navigate("Product", { product: item }) } > {item.title} {item.stock ? "In Stock" : "Out of Stock"} ${item.price * item.qty}