saleor-dashboard/src/components/WeightRange/WeightRange.tsx
Dominik Żegleń 94c0833766 Refactor translations in components (#133)
* Refactor translations in components

* Update pot file
2019-08-29 14:42:59 +02:00

39 lines
904 B
TypeScript

import React from "react";
import { FormattedMessage } from "react-intl";
import { Weight } from "../Weight";
export interface WeightRangeProps {
from?: Weight;
to?: Weight;
}
const WeightRange: React.FC<WeightRangeProps> = ({ from, to }) =>
from && to ? (
<FormattedMessage
defaultMessage="{fromValue} {fromUnit} - {toValue} {toUnit}"
description="weight"
values={{
fromUnit: from.unit,
fromValue: from.value,
toUnit: to.unit,
toValue: to.value
}}
/>
) : from && !to ? (
<FormattedMessage
defaultMessage="from {value} {unit}"
description="weight"
values={from}
/>
) : !from && to ? (
<FormattedMessage
defaultMessage="to {value} {unit}"
description="weight"
values={to}
/>
) : (
<span>-</span>
);
WeightRange.displayName = "WeightRange";
export default WeightRange;