小コード整理
This commit is contained in:
parent
4d921854c9
commit
673f7d94cf
@ -58,6 +58,7 @@ export default function LED_vision(props) {
|
||||
const [finalSwitch, setFinalSwitch] = useState(false);
|
||||
const [trainIDSwitch, setTrainIDSwitch] = useState(false);
|
||||
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("LED");
|
||||
fetch(
|
||||
@ -91,6 +92,7 @@ export default function LED_vision(props) {
|
||||
setStationDiagram(returnData);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const getTime = () => {
|
||||
const returnData = [];
|
||||
Object.keys(stationDiagram).forEach((d) => {
|
||||
@ -112,20 +114,15 @@ export default function LED_vision(props) {
|
||||
});
|
||||
|
||||
return returnData.sort((a, b) => {
|
||||
if (parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0])) {
|
||||
return -1;
|
||||
} else if (
|
||||
parseInt(a.time.split(":")[0]) > parseInt(b.time.split(":")[0])
|
||||
) {
|
||||
return 1;
|
||||
} else if (
|
||||
parseInt(a.time.split(":")[1]) < parseInt(b.time.split(":")[1])
|
||||
) {
|
||||
return -1;
|
||||
} else if (
|
||||
parseInt(a.time.split(":")[1]) > parseInt(b.time.split(":")[1])
|
||||
) {
|
||||
return 1;
|
||||
switch (true) {
|
||||
case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]):
|
||||
return -1;
|
||||
case parseInt(a.time.split(":")[0]) > parseInt(b.time.split(":")[0]):
|
||||
return 1;
|
||||
case parseInt(a.time.split(":")[1]) < parseInt(b.time.split(":")[1]):
|
||||
return -1;
|
||||
case parseInt(a.time.split(":")[1]) > parseInt(b.time.split(":")[1]):
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user