import React from "react"; import moment from "moment"; import { Badge } from "../../lib/common/badge"; import { IRateByTruckGroup, TripCustomerPrice } from "./type"; import BookTruckDialog from "./bookTruckDialog"; import Nodata from "../../lib/common/nodata"; import util from "../../lib/util"; const RateByTruckGroup = (props: IRateByTruckGroup) => { const { cityPriceData, hasLoadMore, loading, loadMore, showBookLink, utmSource, showRatePerTon, translatedWords } = props; const { ton: tonLabel = 'Ton', loadMore: loadMoreLabel = 'Load more', noMoreData = 'No more data', noData } = translatedWords || {} const loadingComp =
return ( <> {util.isEmptyArray(cityPriceData) && loading ? loadingComp : util.isEmptyArray(cityPriceData) ? : cityPriceData.map((cpd: TripCustomerPrice, index: number) => { const { customer_price, source_id, source_name, branch_id, destination_id, destination_name, destination_branch_id, truck_type, ton, created_at } = cpd const queryData = { ext: true, s_id: source_id, s_n: source_name, sb_id: branch_id, d_id: destination_id, d_n: destination_name, db_id: destination_branch_id, t_id: truck_type?.id, t_n: truck_type?.web_name, mt: ton, }; return (
{source_name} {destination_name} {ton ? `- ${ton} ${tonLabel}` : ''}
{`${moment(created_at).format("DD-MMM-YY")} | ${truck_type?.web_name}`}

₹{customer_price || '-'}

{showRatePerTon && ton &&
{`${util.roundedBy50(customer_price/ton)} ₹/ton`}
}
{showBookLink ? : null}
) }) } {hasLoadMore && !util.isEmptyArray(cityPriceData) && loading ? loadingComp : null} {(hasLoadMore && !util.isEmptyArray(cityPriceData) && !loading) ? ( ) : null } {!hasLoadMore && !util.isEmptyArray(cityPriceData) ?
{noMoreData}
: null} ); }; export default RateByTruckGroup;