暫定的に投稿機能新型を実装
This commit is contained in:
parent
5d97ab2f87
commit
d412941635
@ -26,19 +26,27 @@ export const TrainDataView = ({
|
|||||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||||
|
|
||||||
const [platformNumber, setPlatformNumber] = useState();
|
const [platformNumber, setPlatformNumber] = useState();
|
||||||
|
const [lineNumber, setLineNumber] = useState();
|
||||||
const [platformDescription, setPlatformDescription] = useState();
|
const [platformDescription, setPlatformDescription] = useState();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//currentTrainData.Pos = "鴨川~端岡"; //test
|
//currentTrainData.Pos = "鴨川~端岡"; //test
|
||||||
if (!currentTrainData) return;
|
if (!currentTrainData) return;
|
||||||
fetch(
|
fetch(
|
||||||
`https://n8n.haruk.in/webhook/JR-shikoku-PosID?PosNum=${currentTrainData?.PosNum}&Line=${currentTrainData?.Line}`
|
`https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3?PosId=${currentTrainData?.PosNum}&lineName=${currentTrainData?.Line}&StationName=${currentTrainData?.Pos}`
|
||||||
)
|
)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
setPlatformNumber(data?.type == "Station" ? data?.platform : undefined);
|
if (!data) return;
|
||||||
setPlatformDescription(
|
const {type, stationName, lineNumber, platformNumber, position, description} = data;
|
||||||
data?.type == "Station" ? data?.description : undefined
|
if (type == "Station") {
|
||||||
);
|
setLineNumber(lineNumber);
|
||||||
|
setPlatformNumber(platformNumber);
|
||||||
|
setPlatformDescription(description);
|
||||||
|
} else {
|
||||||
|
setLineNumber(undefined);
|
||||||
|
setPlatformNumber(undefined);
|
||||||
|
setPlatformDescription(undefined);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, [currentTrainData]);
|
}, [currentTrainData]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -50,7 +58,8 @@ export const TrainDataView = ({
|
|||||||
const { from, to, Pos } = PosData;
|
const { from, to, Pos } = PosData;
|
||||||
if (isBetween === true) return `${from}~${to}`;
|
if (isBetween === true) return `${from}~${to}`;
|
||||||
if (Pos == "") return "";
|
if (Pos == "") return "";
|
||||||
return `${Pos}${platformNumber ? ` ${platformNumber}番線` : ""}`;
|
if (platformNumber) return `${Pos} ${platformNumber}番乗り場`;
|
||||||
|
if (lineNumber) return `${Pos} ${lineNumber}番線`;
|
||||||
};
|
};
|
||||||
const [dialog, setDialog] = useState(false);
|
const [dialog, setDialog] = useState(false);
|
||||||
const [deleteDialog, setDeleteDialog] = useState(false);
|
const [deleteDialog, setDeleteDialog] = useState(false);
|
||||||
@ -58,6 +67,7 @@ export const TrainDataView = ({
|
|||||||
const [descInput, setDescInput] = useState("");
|
const [descInput, setDescInput] = useState("");
|
||||||
const [stationInput, setStationInput] = useState("");
|
const [stationInput, setStationInput] = useState("");
|
||||||
const [stationNumberInput, setStationNumberInput] = useState("");
|
const [stationNumberInput, setStationNumberInput] = useState("");
|
||||||
|
const [lineInput, setLineInput] = useState("");
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TrainPositionDataPush
|
<TrainPositionDataPush
|
||||||
@ -70,8 +80,10 @@ export const TrainDataView = ({
|
|||||||
descInput={descInput}
|
descInput={descInput}
|
||||||
setPosInput={setPosInput}
|
setPosInput={setPosInput}
|
||||||
setDescInput={setDescInput}
|
setDescInput={setDescInput}
|
||||||
|
lineInput={lineInput}
|
||||||
|
setLineInput={setLineInput}
|
||||||
station={{
|
station={{
|
||||||
Station_JP: trainPositionText(currentTrainData),
|
Station_JP: currentTrainData?.Pos,
|
||||||
StationNumber: currentPosition[0],
|
StationNumber: currentPosition[0],
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -100,6 +112,7 @@ export const TrainDataView = ({
|
|||||||
getStationID(currentTrainData?.Pos, stationList)
|
getStationID(currentTrainData?.Pos, stationList)
|
||||||
);
|
);
|
||||||
setPosInput(platformNumber?.toString() || "");
|
setPosInput(platformNumber?.toString() || "");
|
||||||
|
setLineInput(lineNumber?.toString() || "");
|
||||||
setDeleteDialog(true);
|
setDeleteDialog(true);
|
||||||
} else {
|
} else {
|
||||||
setStationInput(Pos.Pos);
|
setStationInput(Pos.Pos);
|
||||||
@ -108,6 +121,7 @@ export const TrainDataView = ({
|
|||||||
);
|
);
|
||||||
setDescInput(platformDescription || "");
|
setDescInput(platformDescription || "");
|
||||||
setPosInput(platformNumber?.toString() || "");
|
setPosInput(platformNumber?.toString() || "");
|
||||||
|
setLineInput(lineNumber?.toString() || "");
|
||||||
setDialog(true);
|
setDialog(true);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -50,45 +50,62 @@ export const HeaderText: FC<Props> = ({
|
|||||||
const { expoPushToken } = useNotification();
|
const { expoPushToken } = useNotification();
|
||||||
|
|
||||||
// 列車名、種別、フォントの取得
|
// 列車名、種別、フォントの取得
|
||||||
const [typeName, trainName, fontAvailable, isOneMan, infogram, isEdit] =
|
const [
|
||||||
useMemo(() => {
|
typeName,
|
||||||
const { type, trainName, trainNumDistance, infogram, isEdit } =
|
trainName,
|
||||||
customTrainDataDetector(trainNum, allCustomTrainData);
|
fontAvailable,
|
||||||
const [typeString, fontAvailable, isOneMan] = getStringConfig(
|
isOneMan,
|
||||||
type,
|
infogram,
|
||||||
trainNum
|
isEdit,
|
||||||
);
|
uwasa,
|
||||||
switch (true) {
|
] = useMemo(() => {
|
||||||
case trainName !== "":
|
const { type, trainName, trainNumDistance, infogram, isEdit, uwasa } =
|
||||||
// 特急の場合は、列車名を取得
|
customTrainDataDetector(trainNum, allCustomTrainData);
|
||||||
// 列番対称データがある場合はそれから列車番号を取得
|
const [typeString, fontAvailable, isOneMan] = getStringConfig(
|
||||||
return [
|
type,
|
||||||
typeString,
|
trainNum
|
||||||
trainName +
|
);
|
||||||
(trainNumDistance !== null
|
switch (true) {
|
||||||
? ` ${parseInt(trainNum) - trainNumDistance}号`
|
case trainName !== "":
|
||||||
: ""),
|
// 特急の場合は、列車名を取得
|
||||||
fontAvailable,
|
// 列番対称データがある場合はそれから列車番号を取得
|
||||||
isOneMan,
|
return [
|
||||||
infogram,
|
typeString,
|
||||||
isEdit,
|
trainName +
|
||||||
];
|
(trainNumDistance !== null
|
||||||
case trainData[trainData.length - 1] === undefined:
|
? ` ${parseInt(trainNum) - trainNumDistance}号`
|
||||||
return [typeString, "", fontAvailable, isOneMan, infogram, isEdit];
|
: ""),
|
||||||
default:
|
fontAvailable,
|
||||||
// 行先がある場合は、行先を取得
|
isOneMan,
|
||||||
return [
|
infogram,
|
||||||
typeString,
|
isEdit,
|
||||||
migrateTrainName(
|
uwasa,
|
||||||
trainData[trainData.length - 1].split(",")[0] + "行き"
|
];
|
||||||
),
|
case trainData[trainData.length - 1] === undefined:
|
||||||
fontAvailable,
|
return [
|
||||||
isOneMan,
|
typeString,
|
||||||
infogram,
|
"",
|
||||||
isEdit
|
fontAvailable,
|
||||||
];
|
isOneMan,
|
||||||
}
|
infogram,
|
||||||
}, [trainData]);
|
isEdit,
|
||||||
|
uwasa,
|
||||||
|
];
|
||||||
|
default:
|
||||||
|
// 行先がある場合は、行先を取得
|
||||||
|
return [
|
||||||
|
typeString,
|
||||||
|
migrateTrainName(
|
||||||
|
trainData[trainData.length - 1].split(",")[0] + "行き"
|
||||||
|
),
|
||||||
|
fontAvailable,
|
||||||
|
isOneMan,
|
||||||
|
infogram,
|
||||||
|
isEdit,
|
||||||
|
uwasa,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}, [trainData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
@ -121,7 +138,19 @@ export const HeaderText: FC<Props> = ({
|
|||||||
{isOneMan && <OneManText />}
|
{isOneMan && <OneManText />}
|
||||||
<Text style={textConfig}>{trainName}</Text>
|
<Text style={textConfig}>{trainName}</Text>
|
||||||
<InfogramText infogram={infogram} />
|
<InfogramText infogram={infogram} />
|
||||||
{isEdit &&<FontAwesome name="commenting-o" size={20} color="white" style={{ marginLeft: 5 }} onPress={()=>alert("このアイコン、列車データはコミュニティによってリアルタイム追加されています。")} />}
|
{isEdit && (
|
||||||
|
<FontAwesome
|
||||||
|
name="commenting-o"
|
||||||
|
size={20}
|
||||||
|
color="white"
|
||||||
|
style={{ marginLeft: 5 }}
|
||||||
|
onPress={() =>
|
||||||
|
alert(
|
||||||
|
`[このアイコン、列車データはコミュニティによってリアルタイム追加されています。]\n↓投稿者メモ↓\n${uwasa}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
|
@ -121,6 +121,7 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
const [dialog, setDialog] = useState(false);
|
const [dialog, setDialog] = useState(false);
|
||||||
const [deleteDialog, setDeleteDialog] = useState(false);
|
const [deleteDialog, setDeleteDialog] = useState(false);
|
||||||
const [posInput, setPosInput] = useState("");
|
const [posInput, setPosInput] = useState("");
|
||||||
|
const [lineInput, setLineInput] = useState("");
|
||||||
const [descInput, setDescInput] = useState("");
|
const [descInput, setDescInput] = useState("");
|
||||||
const [stationInput, setStationInput] = useState("");
|
const [stationInput, setStationInput] = useState("");
|
||||||
const [stationNumberInput, setStationNumberInput] = useState("");
|
const [stationNumberInput, setStationNumberInput] = useState("");
|
||||||
@ -164,6 +165,8 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
setPosInput,
|
setPosInput,
|
||||||
setDescInput,
|
setDescInput,
|
||||||
station,
|
station,
|
||||||
|
lineInput,
|
||||||
|
setLineInput,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
@ -49,7 +49,7 @@ export const TrainPosition: FC<Props> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(
|
fetch(
|
||||||
`https://n8n.haruk.in/webhook/JR-shikoku-PosID?PosNum=${currentTrainData?.PosNum}&Line=${currentTrainData?.Line}`
|
`https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3?PosId=${currentTrainData?.PosNum}&lineName=${currentTrainData?.Line}&StationName=${currentTrainData?.Pos}`
|
||||||
)
|
)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data: { type: string; platform: number; description: string }) => {
|
.then((data: { type: string; platform: number; description: string }) => {
|
||||||
|
@ -17,7 +17,7 @@ export const TrainPositionDataDelete: FC<Props> = ({
|
|||||||
stationNumberInput,
|
stationNumberInput,
|
||||||
}) => {
|
}) => {
|
||||||
const sendPlatformData = () => {
|
const sendPlatformData = () => {
|
||||||
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID`, {
|
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
@ -11,8 +11,10 @@ type Props = {
|
|||||||
stationNumberInput: string;
|
stationNumberInput: string;
|
||||||
posInput: string;
|
posInput: string;
|
||||||
descInput: string;
|
descInput: string;
|
||||||
|
lineInput: string;
|
||||||
setPosInput: (pos: string) => void;
|
setPosInput: (pos: string) => void;
|
||||||
setDescInput: (desc: string) => void;
|
setDescInput: (desc: string) => void;
|
||||||
|
setLineInput: (line: string) => void;
|
||||||
station: {
|
station: {
|
||||||
Station_JP: string;
|
Station_JP: string;
|
||||||
StationNumber: string;
|
StationNumber: string;
|
||||||
@ -24,6 +26,8 @@ export const TrainPositionDataPush: FC<Props> = ({
|
|||||||
currentTrainData,
|
currentTrainData,
|
||||||
stationInput,
|
stationInput,
|
||||||
stationNumberInput,
|
stationNumberInput,
|
||||||
|
lineInput,
|
||||||
|
setLineInput,
|
||||||
posInput,
|
posInput,
|
||||||
descInput,
|
descInput,
|
||||||
setPosInput,
|
setPosInput,
|
||||||
@ -31,16 +35,17 @@ export const TrainPositionDataPush: FC<Props> = ({
|
|||||||
station,
|
station,
|
||||||
}) => {
|
}) => {
|
||||||
const sendPlatformData = () => {
|
const sendPlatformData = () => {
|
||||||
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID`, {
|
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
PosId: currentTrainData?.PosNum,
|
PosId: currentTrainData?.PosNum,//自動:位置情報ID
|
||||||
lineName: currentTrainData?.Line,
|
StationId: station.StationNumber,//自動:駅ID
|
||||||
PlatformNum: parseInt(posInput),
|
StationName: station.Station_JP,//自動:駅名、漢字
|
||||||
Description: descInput,
|
lineName: currentTrainData?.Line,//自動:位置情報路線ID(koutoku/yosan)
|
||||||
StationName: station.Station_JP,
|
Description: descInput,//手動入力、参考情報
|
||||||
StationId: station.StationNumber,
|
platformNumber: parseInt(posInput),//手動入力、乗り場表記
|
||||||
|
lineNumber: parseInt(lineInput),//手動入力、番線表記
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -60,11 +65,17 @@ export const TrainPositionDataPush: FC<Props> = ({
|
|||||||
<Text>駅名: {stationInput}</Text>
|
<Text>駅名: {stationInput}</Text>
|
||||||
<Text>駅ナンバー: {stationNumberInput}</Text>
|
<Text>駅ナンバー: {stationNumberInput}</Text>
|
||||||
<Input
|
<Input
|
||||||
label="番線"
|
label="乗り場"
|
||||||
inputMode="numeric"
|
inputMode="numeric"
|
||||||
value={posInput}
|
value={posInput}
|
||||||
onChangeText={setPosInput}
|
onChangeText={setPosInput}
|
||||||
/>
|
/>
|
||||||
|
<Input
|
||||||
|
label="番線"
|
||||||
|
inputMode="numeric"
|
||||||
|
value={lineInput}
|
||||||
|
onChangeText={setLineInput}
|
||||||
|
/>
|
||||||
<Input
|
<Input
|
||||||
label="参考情報"
|
label="参考情報"
|
||||||
inputMode="text"
|
inputMode="text"
|
||||||
|
Loading…
Reference in New Issue
Block a user