2019-11-29 17:13:39 +01:00
|
|
|
import React, {FC} from "react";
|
|
|
|
|
import {ColumnProps, SortTypes} from "./types";
|
2019-11-29 15:57:36 +01:00
|
|
|
|
|
|
|
|
type Props = ColumnProps & {
|
|
|
|
|
dataKey: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TextColumn: FC<Props> = ({ row, dataKey }) => {
|
|
|
|
|
return row[dataKey];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TextColumn.defaultProps = {
|
|
|
|
|
createComparator: (props: Props) => {
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
sortType: SortTypes.Text
|
2019-11-29 15:57:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TextColumn;
|