import React, { useMemo } from "react"; import PropTypes from "prop-types"; import { BottomDetails, HeaderDetails, StatusText, StatusValue, } from "./StatisticDetails.styled"; import { useTranslation } from "react-i18next"; const StatisticDetails = (props) => { const { t } = useTranslation(); const offer = props.offer; const percentOfSucceededExchanges = useMemo(() => { if (offer?.user?.statistics?.exchanges?.succeeded === 0) { return 0 + "%"; } else { return ( Math.ceil( (offer?.user?.statistics?.exchanges?.total / offer?.user?.statistics?.exchanges?.succeeded) * 100 ) + "%" ); } }); return ( {offer?.user?.statistics?.publishes?.count} {t("itemDetailsCard.offers")} {offer?.user?.statistics?.views?.count} {t("itemDetailsCard.totalViews")} {percentOfSucceededExchanges} {t("itemDetailsCard.successfulExchanges")} {percentOfSucceededExchanges} {t("itemDetailsCard.correctCommunications")} ); }; StatisticDetails.propTypes = { offer: PropTypes.any, }; export default StatisticDetails;