forked from OpenWF/SpaceNinjaServer
fix(webui): properly handle renaming of pets (#2204)
Reviewed-on: OpenWF/SpaceNinjaServer#2204 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
4ca4990f89
commit
d78ca91d6c
@ -1,6 +1,7 @@
|
|||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
|
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
|
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
export const renamePetController: RequestHandler = async (req, res) => {
|
export const renamePetController: RequestHandler = async (req, res) => {
|
||||||
@ -8,12 +9,18 @@ export const renamePetController: RequestHandler = async (req, res) => {
|
|||||||
const inventory = await getInventory(accountId, "KubrowPets PremiumCredits PremiumCreditsFree");
|
const inventory = await getInventory(accountId, "KubrowPets PremiumCredits PremiumCreditsFree");
|
||||||
const data = getJSONfromString<IRenamePetRequest>(String(req.body));
|
const data = getJSONfromString<IRenamePetRequest>(String(req.body));
|
||||||
const details = inventory.KubrowPets.id(data.petId)!.Details!;
|
const details = inventory.KubrowPets.id(data.petId)!.Details!;
|
||||||
|
|
||||||
details.Name = data.name;
|
details.Name = data.name;
|
||||||
const currencyChanges = updateCurrency(inventory, 15, true);
|
|
||||||
|
const inventoryChanges: IInventoryChanges = {};
|
||||||
|
if (!("webui" in req.query)) {
|
||||||
|
updateCurrency(inventory, 15, true, inventoryChanges);
|
||||||
|
}
|
||||||
|
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.json({
|
res.json({
|
||||||
...data,
|
...data,
|
||||||
inventoryChanges: currencyChanges
|
inventoryChanges: inventoryChanges
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -546,6 +546,9 @@ function updateInventory() {
|
|||||||
td.textContent = item.ItemName + " (" + td.textContent + ")";
|
td.textContent = item.ItemName + " (" + td.textContent + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (item.Details?.Name) {
|
||||||
|
td.textContent = item.Details.Name + " (" + td.textContent + ")";
|
||||||
|
}
|
||||||
if (item.ModularParts && item.ModularParts.length) {
|
if (item.ModularParts && item.ModularParts.length) {
|
||||||
td.textContent += " [";
|
td.textContent += " [";
|
||||||
item.ModularParts.forEach(part => {
|
item.ModularParts.forEach(part => {
|
||||||
@ -1506,15 +1509,28 @@ function sendBatchGearExp(data) {
|
|||||||
|
|
||||||
function renameGear(category, oid, name) {
|
function renameGear(category, oid, name) {
|
||||||
revalidateAuthz(() => {
|
revalidateAuthz(() => {
|
||||||
$.post({
|
if (category == "KubrowPets") {
|
||||||
url: "/api/nameWeapon.php?" + window.authz + "&Category=" + category + "&ItemId=" + oid + "&webui=1",
|
$.post({
|
||||||
contentType: "text/plain",
|
url: "/api/renamePet.php?" + window.authz + "&webui=1",
|
||||||
data: JSON.stringify({
|
contentType: "text/plain",
|
||||||
ItemName: name
|
data: JSON.stringify({
|
||||||
})
|
petId: oid,
|
||||||
}).done(function () {
|
name: name
|
||||||
updateInventory();
|
})
|
||||||
});
|
}).done(function () {
|
||||||
|
updateInventory();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$.post({
|
||||||
|
url: "/api/nameWeapon.php?" + window.authz + "&Category=" + category + "&ItemId=" + oid + "&webui=1",
|
||||||
|
contentType: "text/plain",
|
||||||
|
data: JSON.stringify({
|
||||||
|
ItemName: name
|
||||||
|
})
|
||||||
|
}).done(function () {
|
||||||
|
updateInventory();
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user