Fixed recipe bug n inventory page.

This commit is contained in:
Aodhan
2025-07-10 18:25:23 +01:00
parent ef9b64adfe
commit fd3752e38b
3 changed files with 20 additions and 5 deletions

View File

@@ -13,9 +13,8 @@ from pydantic import BaseModel
from .database import get_session from .database import get_session
# Map craft names -> table names in Postgres # Map craft names to their corresponding recipe tables in Postgres.
ALLOWED_CRAFTS = { ALLOWED_CRAFTS: dict[str, str] = {
"desynthesis": "recipes_desynthesis",
"woodworking": "recipes_woodworking", "woodworking": "recipes_woodworking",
"smithing": "recipes_smithing", "smithing": "recipes_smithing",
"alchemy": "recipes_alchemy", "alchemy": "recipes_alchemy",

View File

@@ -10,6 +10,7 @@ import { useQuery } from "@tanstack/react-query";
import { api } from "../api"; import { api } from "../api";
import CircularProgress from "@mui/material/CircularProgress"; import CircularProgress from "@mui/material/CircularProgress";
import { craftColors } from "../constants/colors"; import { craftColors } from "../constants/colors";
import { reverseSubstitutions } from "../utils/nameSubstitutions";
export interface ItemSummary { export interface ItemSummary {
id: number; id: number;
@@ -47,7 +48,8 @@ export default function ItemDetailPanel({ open, item, onClose }: Props) {
queryFn: async () => { queryFn: async () => {
if (!item) return null; if (!item) return null;
try { try {
const res = await api.get(`/recipes/usage/${encodeURIComponent(item.name)}`); const searchName = reverseSubstitutions(item.name);
const res = await api.get(`/recipes/usage/${encodeURIComponent(searchName)}`);
return res.data as Usage; return res.data as Usage;
} catch { } catch {
return null; return null;
@@ -79,7 +81,7 @@ export default function ItemDetailPanel({ open, item, onClose }: Props) {
<IconButton <IconButton
size="small" size="small"
component="a" component="a"
href={`https://ffxiclopedia.fandom.com/wiki/${encodeURIComponent((data?.name ?? '').replace(/ /g, '_'))}`} href={`https://www.bg-wiki.com/ffxi/${encodeURIComponent(data?.name ?? '')}`}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
> >

View File

@@ -18,12 +18,15 @@ export const SUBSTITUTE_MAP: Array<[string, string]> = [
["Fishing Rod","Fish. Rod"], ["Fishing Rod","Fish. Rod"],
["Black Bolt Heads","Blk. Bolt HeadsBlk. Bolt Heads"], ["Black Bolt Heads","Blk. Bolt HeadsBlk. Bolt Heads"],
["Ethereal Oak Lumber","Ether. Oak Lbr."], ["Ethereal Oak Lumber","Ether. Oak Lbr."],
["Windurstian Tea Leaves","Win. Tea Leaves"],
["Forgotten Thought", "Frgtn. Thought"]
// add more substitutions here // add more substitutions here
]; ];
export function applySubstitutions(name: string): string { export function applySubstitutions(name: string): string {
let result = name; let result = name;
for (const [from, to] of SUBSTITUTE_MAP) { for (const [from, to] of SUBSTITUTE_MAP) {
if (result.includes(from)) { if (result.includes(from)) {
@@ -32,3 +35,14 @@ export function applySubstitutions(name: string): string {
} }
return result; return result;
} }
// Reverse substitution: replace abbreviated form with full name.
export function reverseSubstitutions(name: string): string {
let result = name;
for (const [from, to] of SUBSTITUTE_MAP) {
if (result.includes(to)) {
result = result.replace(to, from);
}
}
return result;
}