chrone: sperate client and server to different repos.

This commit is contained in:
a.bouhuolia
2021-09-21 17:13:53 +02:00
parent e011b2a82b
commit 18df5530c7
10015 changed files with 17686 additions and 97524 deletions

View File

@@ -0,0 +1,33 @@
import React from 'react';
import PropTypes from 'prop-types';
import If from './If';
const Choose = (props) => {
let when = null;
let otherwise = null;
React.Children.forEach(props.children, (children) => {
if (children.props.condition === undefined) {
otherwise = children;
} else if (!when && children.props.condition === true) {
when = children;
}
});
return when || otherwise;
};
Choose.propTypes = {
children: PropTypes.node,
};
Choose.When = If;
Choose.Otherwise = ({ render, children }) => (render ? render() : children);
Choose.Otherwise.propTypes = {
children: PropTypes.node,
render: PropTypes.func,
};
export default Choose;

View File

@@ -0,0 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
const For = ({render, of}) => of.map((item, index) => render(item, index));
For.propTypes = {
of: PropTypes.array.isRequired,
render: PropTypes.func.isRequired
};
export default For;

View File

@@ -0,0 +1,19 @@
import React from 'react';
import moment from 'moment';
import intl from 'react-intl-universal';
/**
* Format the given date.
*/
export function FormatDate({ value, format = 'YYYY MMM DD' }) {
const localizedFormat = intl.get(`date_formats.${format}`);
return moment().format(localizedFormat);
}
/**
* Format date table cell.
*/
export function FormatDateCell({ value, column: { formatDate } }) {
return <FormatDate value={value} {...formatDate} />;
}

View File

@@ -0,0 +1,10 @@
import React from 'react';
import { formattedAmount } from 'utils';
export function FormatNumber({ value, currency = '', noZero }) {
return formattedAmount(value, currency, { noZero });
}
export function FormatNumberCell({ value, column: { formatNumber } }) {
return <FormatNumber value={value} {...formatNumber} />;
}

View File

@@ -0,0 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
const If = props => props.condition
? (props.render ? props.render() : props.children) : null;
If.propTypes = {
// condition: PropTypes.bool.isRequired,
children: PropTypes.node,
render: PropTypes.func
};
export default If;

View File

@@ -0,0 +1,4 @@
export * from './FormatNumber';
export * from './FormatDate';