Fixed recipe bug n inventory page.
This commit is contained in:
@@ -13,9 +13,8 @@ from pydantic import BaseModel
|
||||
|
||||
from .database import get_session
|
||||
|
||||
# Map craft names -> table names in Postgres
|
||||
ALLOWED_CRAFTS = {
|
||||
"desynthesis": "recipes_desynthesis",
|
||||
# Map craft names to their corresponding recipe tables in Postgres.
|
||||
ALLOWED_CRAFTS: dict[str, str] = {
|
||||
"woodworking": "recipes_woodworking",
|
||||
"smithing": "recipes_smithing",
|
||||
"alchemy": "recipes_alchemy",
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { api } from "../api";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import { craftColors } from "../constants/colors";
|
||||
import { reverseSubstitutions } from "../utils/nameSubstitutions";
|
||||
|
||||
export interface ItemSummary {
|
||||
id: number;
|
||||
@@ -47,7 +48,8 @@ export default function ItemDetailPanel({ open, item, onClose }: Props) {
|
||||
queryFn: async () => {
|
||||
if (!item) return null;
|
||||
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;
|
||||
} catch {
|
||||
return null;
|
||||
@@ -79,7 +81,7 @@ export default function ItemDetailPanel({ open, item, onClose }: Props) {
|
||||
<IconButton
|
||||
size="small"
|
||||
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"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
|
||||
@@ -18,12 +18,15 @@ export const SUBSTITUTE_MAP: Array<[string, string]> = [
|
||||
["Fishing Rod","Fish. Rod"],
|
||||
["Black Bolt Heads","Blk. Bolt HeadsBlk. Bolt Heads"],
|
||||
["Ethereal Oak Lumber","Ether. Oak Lbr."],
|
||||
["Windurstian Tea Leaves","Win. Tea Leaves"],
|
||||
["Forgotten Thought", "Frgtn. Thought"]
|
||||
|
||||
|
||||
// add more substitutions here
|
||||
];
|
||||
|
||||
export function applySubstitutions(name: string): string {
|
||||
|
||||
let result = name;
|
||||
for (const [from, to] of SUBSTITUTE_MAP) {
|
||||
if (result.includes(from)) {
|
||||
@@ -32,3 +35,14 @@ export function applySubstitutions(name: string): string {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user