saleor-dashboard/src/components/WeightRange/WeightRange.tsx

43 lines
959 B
TypeScript
Raw Normal View History

2019-08-09 10:26:22 +00:00
import React from "react";
import { FormattedMessage } from "react-intl";
2019-06-19 14:40:52 +00:00
import { Weight } from "../Weight";
export interface WeightRangeProps {
from?: Weight;
to?: Weight;
}
const WeightRange: React.FC<WeightRangeProps> = ({ from, to }) =>
from && to ? (
<FormattedMessage
id="5x6yT9"
defaultMessage="{fromValue} {fromUnit} - {toValue} {toUnit}"
description="weight"
values={{
2019-06-19 14:40:52 +00:00
fromUnit: from.unit,
fromValue: from.value,
toUnit: to.unit,
toValue: to.value,
}}
/>
) : from && !to ? (
<FormattedMessage
id="LICZeR"
defaultMessage="from {value} {unit}"
description="weight"
values={from}
/>
) : !from && to ? (
<FormattedMessage
id="qMB6d2"
defaultMessage="to {value} {unit}"
description="weight"
values={to}
/>
) : (
<span>-</span>
);
2019-06-19 14:40:52 +00:00
WeightRange.displayName = "WeightRange";
export default WeightRange;