UNPKG

702 BJSXView Raw
1// @flow
2
3import words from "./words";
4
5type InfoPropTypes = {
6 shown: number;
7 total: number;
8 one: string;
9 all: string;
10};
11
12import React from "react";
13import { numberToLocaleForm } from "x25/utility";
14
15const getNumberForm = (value : number, one : string, all : string) : string => {
16 if (value === 1) {
17 return `1 ${one}`;
18 }
19
20 return `${numberToLocaleForm(value)} ${all}`;
21};
22
23const Info = ({ shown, total, one, all } : InfoPropTypes) => (
24 <div className="text-muted">
25 {`${words.Showing} `}
26 {
27 (shown === total) ? `${words.All} - ` : `${shown} ${words.Of}`
28 }
29 {` ${getNumberForm(total, one, all)}`}
30 </div>
31);
32
33export default Info;