feature(database-connection): Refactor UserList.tsx to functional components
This commit is contained in:
@@ -4,16 +4,8 @@ import './UserList.scss';
|
|||||||
import SeasonSwitch from "../SeasonSwitch/SeasonSwitch";
|
import SeasonSwitch from "../SeasonSwitch/SeasonSwitch";
|
||||||
import UserStatsResponse from "../../models/UserStatsResponse";
|
import UserStatsResponse from "../../models/UserStatsResponse";
|
||||||
|
|
||||||
// const UserList: React.FC = () => (
|
const createTableEntries = (entries: TableEntry[]) =>
|
||||||
// <div className="UserList" data-testid="UserList">
|
entries.map((entry, index) => {
|
||||||
// UserList Component
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
|
|
||||||
export default class UserList extends React.Component<IUserListProperties, IUserListState> {
|
|
||||||
|
|
||||||
private createTableEntries(entries: TableEntry[]) {
|
|
||||||
return entries.map((entry, index) => {
|
|
||||||
const placement = index + 1;
|
const placement = index + 1;
|
||||||
const placementClassName = placement === 1 ? "first-place"
|
const placementClassName = placement === 1 ? "first-place"
|
||||||
: (placement === 2 ? "second-place"
|
: (placement === 2 ? "second-place"
|
||||||
@@ -28,24 +20,10 @@ export default class UserList extends React.Component<IUserListProperties, IUser
|
|||||||
</tr>
|
</tr>
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// renderTableData() {
|
const UserList: React.FC<IUserListProperties> = (props: IUserListProperties) => (
|
||||||
// // const { error, isLoaded, users, mock } = this.state;
|
|
||||||
// // if (users != null && isLoaded && error == null) {
|
|
||||||
// // return this.createTableEntries(users);
|
|
||||||
// // } else if (isLoaded && error != null && mock != null) {
|
|
||||||
// // return this.createTableEntries(mock);
|
|
||||||
// // } else if (mock != null) {
|
|
||||||
// // return this.createTableEntries(mock);
|
|
||||||
// // }
|
|
||||||
// return this.createTableEntries();
|
|
||||||
// }
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div className="UserList" data-testid="UserList">
|
<div className="UserList" data-testid="UserList">
|
||||||
<SeasonSwitch onSeasonIdChange={this.props.onSeasonIdChange} userStats={this.props.userStats} />
|
<SeasonSwitch onSeasonIdChange={props.onSeasonIdChange} userStats={props.userStats}/>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -56,13 +34,11 @@ export default class UserList extends React.Component<IUserListProperties, IUser
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{this.createTableEntries(this.props.userStats.stats)}
|
{createTableEntries(props.userStats.stats)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IUserListProperties {
|
export interface IUserListProperties {
|
||||||
userStats: UserStatsResponse
|
userStats: UserStatsResponse
|
||||||
@@ -70,6 +46,4 @@ export interface IUserListProperties {
|
|||||||
onSeasonIdChange: any
|
onSeasonIdChange: any
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IUserListState {
|
export default UserList;
|
||||||
mocked: boolean
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user