Add genlocke transfer UI with transfer selection modal and backend support
When advancing to the next genlocke leg, users can now select surviving Pokemon to transfer. Transferred Pokemon are bred down to their base evolutionary form and appear as level-1 egg encounters in the next leg. A GenlockeTransfer record links source and target encounters for lineage tracking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useState, useMemo, useEffect, useCallback } from 'react'
|
||||
import { useParams, Link, useNavigate } from 'react-router-dom'
|
||||
import { useRun, useUpdateRun } from '../hooks/useRuns'
|
||||
import { useAdvanceLeg } from '../hooks/useGenlockes'
|
||||
import { useAdvanceLeg, useLegSurvivors } from '../hooks/useGenlockes'
|
||||
import { useGameRoutes } from '../hooks/useGames'
|
||||
import { useCreateEncounter, useUpdateEncounter, useBulkRandomize } from '../hooks/useEncounters'
|
||||
import { usePokemonFamilies } from '../hooks/usePokemon'
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
EncounterModal,
|
||||
EncounterMethodBadge,
|
||||
HofTeamModal,
|
||||
TransferModal,
|
||||
StatCard,
|
||||
PokemonCard,
|
||||
StatusChangeModal,
|
||||
@@ -395,6 +396,11 @@ export function RunEncounters() {
|
||||
const runIdNum = Number(runId)
|
||||
const { data: run, isLoading, error } = useRun(runIdNum)
|
||||
const advanceLeg = useAdvanceLeg()
|
||||
const { data: survivors } = useLegSurvivors(
|
||||
run?.genlocke?.genlockeId ?? 0,
|
||||
run?.genlocke?.legOrder ?? 0,
|
||||
showTransferModal && !!run?.genlocke,
|
||||
)
|
||||
const { data: routes, isLoading: loadingRoutes } = useGameRoutes(
|
||||
run?.gameId ?? null,
|
||||
)
|
||||
@@ -417,6 +423,7 @@ export function RunEncounters() {
|
||||
const [showHofModal, setShowHofModal] = useState(false)
|
||||
const [showShinyModal, setShowShinyModal] = useState(false)
|
||||
const [showEggModal, setShowEggModal] = useState(false)
|
||||
const [showTransferModal, setShowTransferModal] = useState(false)
|
||||
const [expandedBosses, setExpandedBosses] = useState<Set<number>>(new Set())
|
||||
const [showTeam, setShowTeam] = useState(true)
|
||||
const [filter, setFilter] = useState<'all' | RouteStatus>('all')
|
||||
@@ -864,21 +871,7 @@ export function RunEncounters() {
|
||||
</div>
|
||||
{run.status === 'completed' && run.genlocke && !run.genlocke.isFinalLeg && (
|
||||
<button
|
||||
onClick={() => {
|
||||
advanceLeg.mutate(
|
||||
{ genlockeId: run.genlocke!.genlockeId, legOrder: run.genlocke!.legOrder },
|
||||
{
|
||||
onSuccess: (genlocke) => {
|
||||
const nextLeg = genlocke.legs.find(
|
||||
(l) => l.legOrder === run.genlocke!.legOrder + 1,
|
||||
)
|
||||
if (nextLeg?.runId) {
|
||||
navigate(`/runs/${nextLeg.runId}`)
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
}}
|
||||
onClick={() => setShowTransferModal(true)}
|
||||
disabled={advanceLeg.isPending}
|
||||
className="px-4 py-2 text-sm font-medium rounded-lg bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 transition-colors"
|
||||
>
|
||||
@@ -1454,6 +1447,53 @@ export function RunEncounters() {
|
||||
isPending={updateRun.isPending}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Transfer Modal */}
|
||||
{showTransferModal && survivors && (
|
||||
<TransferModal
|
||||
survivors={survivors}
|
||||
onSubmit={(encounterIds) => {
|
||||
advanceLeg.mutate(
|
||||
{
|
||||
genlockeId: run!.genlocke!.genlockeId,
|
||||
legOrder: run!.genlocke!.legOrder,
|
||||
transferEncounterIds: encounterIds,
|
||||
},
|
||||
{
|
||||
onSuccess: (genlocke) => {
|
||||
setShowTransferModal(false)
|
||||
const nextLeg = genlocke.legs.find(
|
||||
(l) => l.legOrder === run!.genlocke!.legOrder + 1,
|
||||
)
|
||||
if (nextLeg?.runId) {
|
||||
navigate(`/runs/${nextLeg.runId}`)
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
}}
|
||||
onSkip={() => {
|
||||
advanceLeg.mutate(
|
||||
{
|
||||
genlockeId: run!.genlocke!.genlockeId,
|
||||
legOrder: run!.genlocke!.legOrder,
|
||||
},
|
||||
{
|
||||
onSuccess: (genlocke) => {
|
||||
setShowTransferModal(false)
|
||||
const nextLeg = genlocke.legs.find(
|
||||
(l) => l.legOrder === run!.genlocke!.legOrder + 1,
|
||||
)
|
||||
if (nextLeg?.runId) {
|
||||
navigate(`/runs/${nextLeg.runId}`)
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
}}
|
||||
isPending={advanceLeg.isPending}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user