fix Loading... message on date select in historical view

This commit is contained in:
HF 2020-01-10 20:50:25 +01:00
parent d037d34e1f
commit 7abe936cd1
2 changed files with 8 additions and 6 deletions

View File

@ -21,7 +21,8 @@ async function getTimes(day, canvasId) {
return []; return [];
} }
const times = await response.json(); const times = await response.json();
const parsedTimes = times.map((a) => `${a.substr(0, 2)}:${a.substr(-2, 2)}`); const parsedTimes = times
.map((a) => `${a.substr(0, 2)}:${a.substr(-2, 2)}`);
return parsedTimes; return parsedTimes;
} catch { } catch {
return []; return [];
@ -41,7 +42,7 @@ class HistorySelect extends React.Component {
this.state = { this.state = {
submitting: false, submitting: false,
selectedDate: new Date(), selectedDate: null,
max, max,
}; };
@ -59,6 +60,7 @@ class HistorySelect extends React.Component {
this.setState({ this.setState({
submitting: true, submitting: true,
times: [],
}); });
const { const {
canvasId, canvasId,
@ -99,14 +101,15 @@ class HistorySelect extends React.Component {
<div> <div>
{ (times && times.length > 0) { (times && times.length > 0)
? ( ? (
<select onChange={(evt) => setTime(selectedDate, evt.target.value)}> <select onChange={(e) => setTime(selectedDate, e.target.value)}>
{times.map((value) => ( {times.map((value) => (
<option value={value}>{value}</option> <option value={value}>{value}</option>
))} ))}
</select> </select>
) )
: <p>Select Date</p> } : null }
{ (submitting) ? <p>Loading...</p> : null } { (submitting) ? <p>Loading...</p> : null }
{ (!selectedDate && !submitting) ? <p>Select Date above</p> : null }
</div> </div>
</div> </div>
); );

View File

@ -180,9 +180,8 @@ kbd {
background-color: rgba(226, 226, 226, 0.80); background-color: rgba(226, 226, 226, 0.80);
color: black; color: black;
font-size: 14px; font-size: 14px;
line-height: 30px; line-height: 26px;
text-align: center; text-align: center;
vertical-align: middle;
border: solid black; border: solid black;
border-width: thin; border-width: thin;
padding: 0 24px; padding: 0 24px;