2019-12-02 13:58:56 +01:00
|
|
|
import React, { FC } from "react";
|
2019-12-02 15:59:32 +01:00
|
|
|
import { ColumnProps } from "./table";
|
2019-11-29 15:57:36 +01:00
|
|
|
|
|
|
|
|
type Props = ColumnProps & {
|
|
|
|
|
dataKey: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TextColumn: FC<Props> = ({ row, dataKey }) => {
|
|
|
|
|
return row[dataKey];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TextColumn.defaultProps = {
|
2019-12-03 16:04:11 +01:00
|
|
|
createComparator: (props: Props) => {
|
2019-11-29 15:57:36 +01:00
|
|
|
return (a: any, b: any) => {
|
|
|
|
|
if (a[props.dataKey] < b[props.dataKey]) {
|
|
|
|
|
return -1;
|
|
|
|
|
} else if (a[props.dataKey] > b[props.dataKey]) {
|
|
|
|
|
return 1;
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
2019-11-29 17:13:39 +01:00
|
|
|
},
|
2019-12-02 13:58:56 +01:00
|
|
|
ascendingIcon: "sort-alpha-down-alt",
|
|
|
|
|
descendingIcon: "sort-alpha-down"
|
2019-11-29 15:57:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TextColumn;
|