暫定的に投稿機能新型を実装

This commit is contained in:
harukin-expo-dev-env 2025-08-12 16:47:35 +00:00
parent 5d97ab2f87
commit d412941635
6 changed files with 114 additions and 57 deletions

View File

@ -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);
} }
}} }}

View File

@ -50,9 +50,16 @@ 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,
fontAvailable,
isOneMan,
infogram,
isEdit,
uwasa,
] = useMemo(() => {
const { type, trainName, trainNumDistance, infogram, isEdit, uwasa } =
customTrainDataDetector(trainNum, allCustomTrainData); customTrainDataDetector(trainNum, allCustomTrainData);
const [typeString, fontAvailable, isOneMan] = getStringConfig( const [typeString, fontAvailable, isOneMan] = getStringConfig(
type, type,
@ -72,9 +79,18 @@ export const HeaderText: FC<Props> = ({
isOneMan, isOneMan,
infogram, infogram,
isEdit, isEdit,
uwasa,
]; ];
case trainData[trainData.length - 1] === undefined: case trainData[trainData.length - 1] === undefined:
return [typeString, "", fontAvailable, isOneMan, infogram, isEdit]; return [
typeString,
"",
fontAvailable,
isOneMan,
infogram,
isEdit,
uwasa,
];
default: default:
// 行先がある場合は、行先を取得 // 行先がある場合は、行先を取得
return [ return [
@ -85,7 +101,8 @@ export const HeaderText: FC<Props> = ({
fontAvailable, fontAvailable,
isOneMan, isOneMan,
infogram, infogram,
isEdit isEdit,
uwasa,
]; ];
} }
}, [trainData]); }, [trainData]);
@ -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 }} />

View File

@ -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

View File

@ -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 }) => {

View File

@ -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({

View File

@ -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"