|
@@ -1,6 +1,6 @@
|
|
|
import React, { useState, FunctionComponent, useEffect } from 'react';
|
|
import React, { useState, FunctionComponent, useEffect } from 'react';
|
|
|
import Critter, { Time, Month, Colors } from 'types';
|
|
import Critter, { Time, Month, Colors } from 'types';
|
|
|
-import { Table as Tb } from 'reactstrap';
|
|
|
|
|
|
|
+import { Table as Tb, Spinner } from 'reactstrap';
|
|
|
import Tag from 'components/Tag';
|
|
import Tag from 'components/Tag';
|
|
|
import Button from 'components/Button';
|
|
import Button from 'components/Button';
|
|
|
import Input from 'components/Input';
|
|
import Input from 'components/Input';
|
|
@@ -8,7 +8,6 @@ import moment from 'moment';
|
|
|
import { parseMonth } from 'services/DataParser';
|
|
import { parseMonth } from 'services/DataParser';
|
|
|
import { includes, descend, ascend, sortWith } from 'ramda';
|
|
import { includes, descend, ascend, sortWith } from 'ramda';
|
|
|
import { FaSort, FaSortUp, FaSortDown } from 'react-icons/fa';
|
|
import { FaSort, FaSortUp, FaSortDown } from 'react-icons/fa';
|
|
|
-
|
|
|
|
|
import './styles.css';
|
|
import './styles.css';
|
|
|
|
|
|
|
|
export type Column<T> = {
|
|
export type Column<T> = {
|
|
@@ -219,37 +218,46 @@ const Table = <T extends Critter>({ data, columns }: TableProps<T>) => {
|
|
|
<Button onClick={() => { availableNow() }} color="primary">Available now</Button>
|
|
<Button onClick={() => { availableNow() }} color="primary">Available now</Button>
|
|
|
<Button onClick={() => { showAll() }}>Show all</Button>
|
|
<Button onClick={() => { showAll() }}>Show all</Button>
|
|
|
</div>
|
|
</div>
|
|
|
- <Tb striped hover responsive className="critter-table">
|
|
|
|
|
- <thead>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th></th>
|
|
|
|
|
- {
|
|
|
|
|
- columns.map(({ label, sort, key }, i) => (
|
|
|
|
|
- <th key={i}>{label} {sort ? showSortIcon(key as string, sort) : null}</th>
|
|
|
|
|
- ))
|
|
|
|
|
- }
|
|
|
|
|
- </tr>
|
|
|
|
|
- </thead>
|
|
|
|
|
- <tbody>
|
|
|
|
|
- {
|
|
|
|
|
- critters.map((critter, key) => (
|
|
|
|
|
- <tr key={key}>
|
|
|
|
|
- <td className="critter-img"><img className="critter-img" src={`${process.env.REACT_APP_API}/${critter.img}`} alt={critter.name}/></td>
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ critters.length ? (
|
|
|
|
|
+ <Tb striped hover responsive className="critter-table">
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th></th>
|
|
|
{
|
|
{
|
|
|
- columns.map(({ key, display, type }, i) => (
|
|
|
|
|
- <td key={i}>
|
|
|
|
|
- { type ? DisplayData(type)(critter) :
|
|
|
|
|
- display ? display(critter) :
|
|
|
|
|
- critter[key]
|
|
|
|
|
- }
|
|
|
|
|
- </td>
|
|
|
|
|
|
|
+ columns.map(({ label, sort, key }, i) => (
|
|
|
|
|
+ <th key={i}>{label} {sort ? showSortIcon(key as string, sort) : null}</th>
|
|
|
))
|
|
))
|
|
|
}
|
|
}
|
|
|
</tr>
|
|
</tr>
|
|
|
- ))
|
|
|
|
|
- }
|
|
|
|
|
- </tbody>
|
|
|
|
|
- </Tb>
|
|
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ {
|
|
|
|
|
+ critters.map((critter, key) => (
|
|
|
|
|
+ <tr key={key}>
|
|
|
|
|
+ <td className="critter-img"><img className="critter-img" src={`${process.env.REACT_APP_API}/${critter.img}`} alt={critter.name}/></td>
|
|
|
|
|
+ {
|
|
|
|
|
+ columns.map(({ key, display, type }, i) => (
|
|
|
|
|
+ <td key={i}>
|
|
|
|
|
+ { type ? DisplayData(type)(critter) :
|
|
|
|
|
+ display ? display(critter) :
|
|
|
|
|
+ critter[key]
|
|
|
|
|
+ }
|
|
|
|
|
+ </td>
|
|
|
|
|
+ ))
|
|
|
|
|
+ }
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ ))
|
|
|
|
|
+ }
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </Tb>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <div className="cc-critter-schedule-loading">
|
|
|
|
|
+ <Spinner type="grow" color="info" />
|
|
|
|
|
+ <h5>Loading data</h5>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|