All files / components/Commons Profits.js

100% Statements 4/4
100% Branches 2/2
100% Functions 2/2
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 32 33 34 35              3x   30x 3x           30x                                    
import React from "react";
import { Card } from "react-bootstrap";
import ProfitsTable from "main/components/Commons/ProfitsTable";
 
import { timestampToDate } from "main/utils/dateUtils";
 
 
const Profits = ({ profits,commons }) => {
    const profitsForTable =
        profits ?
        profits.map(profit => ({
            date: timestampToDate(profit.timestamp),
            ...profit
        })) : 
        // Stryker disable next-line ArrayDeclaration : no need to test what happens if [] is replaced with ["Stryker was here"]
        [];
    return (
        <Card>
            <Card.Header as="h5">
                Profits
            </Card.Header>
            <Card.Body>
                {/* change 4am to admin-appointed time? And consider adding milk bottle as decoration */}
                <Card.Title>
                    You will earn profits from milking your cows everyday at 4am.
                </Card.Title>
                <Card.Title>Market Milk Price: ${commons?.milkPrice} per healthy cow.</Card.Title>
                <ProfitsTable profits={profitsForTable} />
            </Card.Body>
        </Card>
    );
};
 
export default Profits;