diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index 196383d..0f1376c 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -9,6 +9,7 @@ import { useInterval } from "../../lib/useInterval"; import trainList from "../../assets/originData/trainList"; import { objectIsEmpty } from "../../lib/objectIsEmpty"; import { parseAllTrainDiagram } from "../../lib/parseAllTrainDiagram"; +import { getTrainType } from "../../lib/getTrainType"; let diagramData = undefined; @@ -332,18 +333,6 @@ const EachData = ({ setTrainInfo, EachTrainInfoAsSR, }) => { - const getTrainType = (data) => { - switch (data) { - case "Rapid": - return { color: "aqua", name: "快速", data: "rapid" }; - case "LTDEXP": - return { color: "red", name: "特急", data: "express" }; - case "NightLTDEXP": - return { color: "red", name: "寝台特急", data: "express" }; - case "Normal": - return { color: "white", name: "普通列車", data: "normal" }; - } - }; const openTrainInfo = (d) => { console.log(train); console.log(d); @@ -387,16 +376,13 @@ const EachData = ({ d={d} getTrainType={getTrainType(train.type)} /> - - - + + + - {trainDescriptionSwitch && !!train.info && } + {trainDescriptionSwitch && !!train.info && ( + + )} ); }; @@ -426,7 +412,7 @@ const TrainName = ({ train, trainIDSwitch, d, getTrainType }) => { ); }; -const LastStation = ({ d: { lastStation } }) => { +const LastStation = ({ lastStation }) => { return ( { ); }; -const DependTime = ({ d: { time } }) => { + +const DependTime = ({ time }) => { return ( { else return notNyujoData[0]; }; -const StatusAndDelay = ({ currentTrain, d, props, trainDescriptionSwitch }) => { +const StatusAndDelay = ({ currentTrain, train }) => { // 土讃線複数存在対策 const getTrainDelayStatus = (current) => { if (!current) return () => {}; @@ -496,14 +483,14 @@ const StatusAndDelay = ({ currentTrain, d, props, trainDescriptionSwitch }) => { }} > {getTrainDelayStatus( - checkDuplicateTrainData(currentTrain.filter((a) => a.num == d.train)) + checkDuplicateTrainData(currentTrain.filter((a) => a.num == train)) )} ); }; -const Description = ({ train }) => { +const Description = ({ info }) => { return ( { }} > {" "} - > {train.info} + > {info} diff --git a/lib/getTrainType.js b/lib/getTrainType.js new file mode 100644 index 0000000..e026863 --- /dev/null +++ b/lib/getTrainType.js @@ -0,0 +1,14 @@ +export const getTrainType = (data) => { + switch (data) { + case "Rapid": + return { color: "aqua", name: "快速", data: "rapid" }; + case "LTDEXP": + return { color: "red", name: "特急", data: "express" }; + case "NightLTDEXP": + return { color: "red", name: "寝台特急", data: "express" }; + case "Normal": + return { color: "white", name: "普通列車", data: "normal" }; + default: + return { color: "white", name: "その他", data: "normal" }; + } +};