Skip to content

Commit dceb791

Browse files
TinyKittenclaude
andcommitted
SavePresetNameModalのdefaultName組み立てを中間変数に分離して可読性を改善
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9667f9e commit dceb791

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/components/SelectBoundModal.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,15 @@ export const SelectBoundModal: React.FC<Props> = ({
548548
return options.filter((o) => o.fromStation.groupId !== o.toStation.groupId);
549549
}, [wantedDestination, line, stations, inboundStations, outboundStations]);
550550

551+
const presetDefaultName = useMemo(() => {
552+
const trainName = pendingTrainType
553+
? ((isJapanese ? pendingTrainType.name : pendingTrainType.nameRoman) ??
554+
'')
555+
: '';
556+
const lineName = line ? getLocalizedLineName(line, isJapanese) : '';
557+
return [trainName, lineName].filter(Boolean).join(' ');
558+
}, [pendingTrainType, line]);
559+
551560
const handlePresetNameSubmit = useCallback(
552561
async (name: string, direction: LineDirection | null) => {
553562
if (!line) return;
@@ -831,7 +840,7 @@ export const SelectBoundModal: React.FC<Props> = ({
831840
visible={isPresetNameModalVisible}
832841
onClose={() => setIsPresetNameModalVisible(false)}
833842
onSubmit={handlePresetNameSubmit}
834-
defaultName={`${pendingTrainType ? `${isJapanese ? (pendingTrainType.name ?? '') : (pendingTrainType.nameRoman ?? '')} ` : ''}${line ? getLocalizedLineName(line, isJapanese) : ''}`.trim()}
843+
defaultName={presetDefaultName}
835844
directionOptions={presetDirectionOptions}
836845
/>
837846
</CustomModal>

0 commit comments

Comments
 (0)