All files / components/Commons ManageCows.js

100% Statements 4/4
100% Branches 0/0
100% Functions 3/3
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31        3x   42x                   2x     2x                      
import React from "react";
import { Card, Button, Row, Col } from "react-bootstrap";
 
// add parameters 
const ManageCows = ({userCommons, commons, onBuy, onSell}) =>  {
    // update cowPrice from fixture
    return (
        <Card>
        <Card.Header as="h5">Manage Cows</Card.Header>
        <Card.Body>
            {/* change $10 to info from fixture */}
            <Card.Title className="text-center">💵 Market Cow Price: ${commons?.cowPrice}</Card.Title>
            <Card.Title className="text-center">🐮 Number of Cows: {userCommons.numOfCows}</Card.Title>
            <Card.Title className="text-center">🥛 Current Milk Price: ${commons?.milkPrice}</Card.Title>
            <Row>
                <Col className="text-center">
                    <Button variant="outline-success" onClick={()=>{onBuy(userCommons)}} data-testid={"buy-cow-button"}>Buy cow</Button>
                </Col>
                <Col className="text-center">
                    <Button variant="outline-danger" onClick={()=>{onSell(userCommons)}} data-testid={"sell-cow-button"}>Sell cow</Button>
                </Col>
            </Row>
                
                    Note: Buying cows buys at current cow price, but selling cows sells at current cow price
                    times the average health of cows as a percentage! 
        </Card.Body>
        </Card>
    ); 
}; 
 
export default ManageCows;