50 lines
2.4 KiB
JavaScript
50 lines
2.4 KiB
JavaScript
import React, { createContext, useContext, useEffect, useState } from "react";
|
|
const initialState = {
|
|
allTrainDiagram: undefined,
|
|
setAllTrainDiagram: () => {},
|
|
};
|
|
|
|
const AllTrainDiagramContext = createContext(initialState);
|
|
|
|
export const useAllTrainDiagram = () => {
|
|
return useContext(AllTrainDiagramContext);
|
|
};
|
|
|
|
export const AllTrainDiagramProvider = ({ children }) => {
|
|
const [allTrainDiagram, setAllTrainDiagram] = useState();
|
|
const customData = {
|
|
//9001: "岡山,発,10:11#児島,発,11:05#坂出,発,11:41#高松,着,12:00#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
|
9001: "ウェルカムセレモニー,頃,9:40#岡山,頃,10:10#琴平,頃,14:00#琴平観光,以降,14:00#湯山荘 阿讃琴南,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS,提,https://www.the-royalexpress.jp/plan/2614/#",
|
|
//9029: "高松,発,12:42#琴平,着,13:57#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
|
9029: "ウェルカムセレモニー,頃,9:40#岡山,頃,10:10#琴平,頃,14:00#琴平観光,以降,14:00#湯山荘 阿讃琴南,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS,提,https://www.the-royalexpress.jp/plan/2614/#",
|
|
//9003: "多度津,発,10:09#今治,発,13:20#伊予亀岡,発,13:55#菊間,発,14:04#松山,着,14:50#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
|
9003: "湯山荘 阿讃琴南,頃,9:00#多度津,頃,10:10#松山,頃,14:50#宿泊施設,以降,14:50#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第2章\n ~四国の伝統文化を感じて~\n多度津・坂出・松山,提,https://www.the-royalexpress.jp/plan/2614/#",
|
|
};
|
|
useEffect(() => {
|
|
fetch(
|
|
"https://script.google.com/macros/s/AKfycbx_s7RB-xTy-iAslFJg7LfplLV09-hjDXEjdi9kCP_JT45wq17Af_IPOKIOqIfaNDg/exec"
|
|
)
|
|
.then((res) => res.json())
|
|
.then((res) => {
|
|
const data = {};
|
|
res.forEach((d) => {
|
|
const keys = Object.keys(d);
|
|
data[keys] = d[keys];
|
|
});
|
|
return data;
|
|
})
|
|
.then((res) => {
|
|
Object.assign(res, customData);
|
|
setAllTrainDiagram(res);
|
|
});
|
|
}, []);
|
|
|
|
return (
|
|
<AllTrainDiagramContext.Provider
|
|
value={{ allTrainDiagram, setAllTrainDiagram }}
|
|
>
|
|
{children}
|
|
</AllTrainDiagramContext.Provider>
|
|
);
|
|
};
|