Skip to content

Commit

Permalink
Fix pr #390: Fix issue #389: Jutsu Level Transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Feb 21, 2025
1 parent 50c03ab commit 7984f68
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 96 deletions.
9 changes: 5 additions & 4 deletions app/src/components/jutsu/LevelTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Label } from "@/components/ui/label";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import { ArrowRightLeft } from "lucide-react";
import type { Jutsu } from "@/drizzle/schema";
import type { RouterOutputs } from "@/server/api/root";


interface LevelTransferProps {
jutsu: Jutsu;
Expand All @@ -21,14 +21,15 @@ export default function LevelTransfer({ jutsu, onTransfer }: LevelTransferProps)
const [open, setOpen] = useState(false);

// Get available jutsus for transfer (same rank and type)
const { data: availableJutsus } = api.jutsu.getAll.useQuery<RouterOutputs["jutsu"]["getAll"]>({
const { data: availableJutsus } = api.jutsu.getAll.useQuery({
rank: jutsu.jutsuRank,
type: jutsu.jutsuType,
excludeId: jutsu.id,
limit: 1000,
});

// Get transfer info
const { data: transferInfo } = api.jutsu.getTransferInfo.useQuery<RouterOutputs["jutsu"]["getTransferInfo"]>(undefined, {
const { data: transferInfo } = api.jutsu.getTransferInfo.useQuery(undefined, {
enabled: !!userData,
});

Expand Down Expand Up @@ -79,7 +80,7 @@ export default function LevelTransfer({ jutsu, onTransfer }: LevelTransferProps)
<SelectValue placeholder="Select a jutsu" />
</SelectTrigger>
<SelectContent>
{availableJutsus?.map((j) => (
{availableJutsus?.data?.map((j) => (
<SelectItem key={j.id} value={j.id}>
{j.name} (Level {j.level})
</SelectItem>
Expand Down
4 changes: 2 additions & 2 deletions app/src/libs/jutsu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ export const useJutsuEditForm = (data: Jutsu, refetch: () => void) => {
});

// Form submission
const handleJutsuSubmit = async (e?: React.BaseSyntheticEvent) => {
const handleJutsuSubmit = (e?: React.BaseSyntheticEvent) => {
if (e) {
e.preventDefault();
}
const values = form.getValues();
const newJutsu = { ...jutsu, ...values };
const diff = calculateContentDiff(jutsu, newJutsu);
if (diff.length > 0) {
await updateJutsu({ id: jutsu.id, data: newJutsu });
updateJutsu({ id: jutsu.id, data: newJutsu });
}
};

Expand Down
Loading

0 comments on commit 7984f68

Please sign in to comment.