import { area_t } from "@/lib/dimensions"; import convert, { Area, Length } from "convert"; import dayjs, { Dayjs } from "dayjs"; import { StyleSheet, Text, View } from "react-native"; export type AreaRugTagProps = { dimensions: area_t, price_per_area: { price: number, per: { n: number, u: Area, } }, date?: Dayjs currencySymbol?: string }; export const AreaRugTag = (props: AreaRugTagProps) => { const date = props.date || dayjs(); const square = props.dimensions.l * props.dimensions.w; const areaUnits = `square ${props.dimensions.u}`; const square2 = convert(square, areaUnits as Area).to(props.price_per_area.per.u) const price = (square2 / props.price_per_area.per.n) * props.price_per_area.price; const sPrice = price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2, }) const currencySymbol = props.currencySymbol || "$"; return ( {props.dimensions.l} x {props.dimensions.w} {currencySymbol} {sPrice} {date.format("YYYY/MM/DD")} [Curent Tag Color] ) }; const styles = StyleSheet.create({ component: { paddingVertical: 100, flex: 1, }, dimensions: { }, price: { }, date: { }, tagColor: { }, })