mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 08:08:49 +01:00
[MIRROR] fixes order vendor loading screens [MDB IGNORE] (#19553)
fixes order vendor loading screens Co-authored-by: SMOSMOSMOSMOSMO <95004236+SmoSmoSmoSmok@users.noreply.github.com>
This commit is contained in:
co-authored by
SMOSMOSMOSMOSMO
parent
4e9a254b35
commit
7b06e7b7df
@@ -81,6 +81,13 @@ GLOBAL_LIST_EMPTY(order_console_products)
|
||||
var/obj/item/card/id/id_card = living_user.get_idcard(TRUE)
|
||||
if(id_card)
|
||||
data["points"] = id_card.registered_account?.account_balance
|
||||
for(var/datum/orderable_item/item as anything in GLOB.order_console_products)
|
||||
if(!(item.category_index in order_categories))
|
||||
continue
|
||||
data["item_amts"] += list(list(
|
||||
"name" = item.name,
|
||||
"amt" = grocery_list[item],
|
||||
))
|
||||
|
||||
return data
|
||||
|
||||
@@ -101,7 +108,6 @@ GLOBAL_LIST_EMPTY(order_console_products)
|
||||
"cat" = item.category_index,
|
||||
"ref" = REF(item),
|
||||
"cost" = item.cost_per_order,
|
||||
"amt" = grocery_list[item],
|
||||
"product_icon" = icon2base64(getFlatIcon(image(icon = initial(item.item_path.icon), icon_state = initial(item.item_path.icon_state)), no_anim=TRUE))
|
||||
))
|
||||
return data
|
||||
@@ -117,7 +123,6 @@ GLOBAL_LIST_EMPTY(order_console_products)
|
||||
if("add_one")
|
||||
var/datum/orderable_item/wanted_item = locate(params["target"]) in GLOB.order_console_products
|
||||
grocery_list[wanted_item] += 1
|
||||
update_static_data(living_user)
|
||||
if("remove_one")
|
||||
var/datum/orderable_item/wanted_item = locate(params["target"]) in GLOB.order_console_products
|
||||
if(!grocery_list[wanted_item])
|
||||
@@ -125,14 +130,12 @@ GLOBAL_LIST_EMPTY(order_console_products)
|
||||
grocery_list[wanted_item] -= 1
|
||||
if(!grocery_list[wanted_item])
|
||||
grocery_list -= wanted_item
|
||||
update_static_data(living_user)
|
||||
if("cart_set")
|
||||
//this is null if the action doesn't need it (purchase, quickpurchase)
|
||||
var/datum/orderable_item/wanted_item = locate(params["target"]) in GLOB.order_console_products
|
||||
grocery_list[wanted_item] = clamp(params["amt"], 0, 20)
|
||||
if(!grocery_list[wanted_item])
|
||||
grocery_list -= wanted_item
|
||||
update_static_data(living_user)
|
||||
if("purchase", "ltsrbt_deliver")
|
||||
if(!grocery_list.len || !COOLDOWN_FINISHED(src, order_cooldown))
|
||||
return
|
||||
|
||||
@@ -14,14 +14,29 @@ const TAB2NAME = [
|
||||
},
|
||||
];
|
||||
|
||||
const findAmount = (item_amts, name) => {
|
||||
const amount = item_amts.find((item) => item.name === name);
|
||||
return amount.amt;
|
||||
};
|
||||
|
||||
const ShoppingTab = (props, context) => {
|
||||
const { data, act } = useBackend(context);
|
||||
const { credit_type, order_categories, order_datums } = data;
|
||||
const { credit_type, order_categories, order_datums, item_amts } = data;
|
||||
const [shopIndex, setShopIndex] = useLocalState(context, 'shop-index', 1);
|
||||
const [condensed, setCondensed] = useLocalState(context, 'condensed', false);
|
||||
<<<<<<< HEAD
|
||||
const mapped_food = order_datums.filter(
|
||||
(food) => food && food.cat === shopIndex
|
||||
);
|
||||
=======
|
||||
const [searchItem, setSearchItem] = useLocalState(context, 'searchItem', '');
|
||||
const search = createSearch(searchItem, (order_datums) => order_datums.name);
|
||||
let goods =
|
||||
searchItem.length > 0
|
||||
? data.order_datums.filter(search)
|
||||
: order_datums.filter((item) => item && item.cat === shopIndex);
|
||||
|
||||
>>>>>>> b97bc184022 (fixes order vendor loading screens (#73615))
|
||||
return (
|
||||
<Stack fill vertical>
|
||||
<Section mb={-0.9}>
|
||||
@@ -103,8 +118,7 @@ const ShoppingTab = (props, context) => {
|
||||
}
|
||||
/>
|
||||
<NumberInput
|
||||
animated
|
||||
value={item.amt || 0}
|
||||
value={findAmount(item_amts, item.name) || 0}
|
||||
width="41px"
|
||||
minValue={0}
|
||||
maxValue={20}
|
||||
@@ -136,8 +150,12 @@ const CheckoutTab = (props, context) => {
|
||||
forced_express,
|
||||
order_datums,
|
||||
total_cost,
|
||||
item_amts,
|
||||
} = data;
|
||||
const checkout_list = order_datums.filter((food) => food && (food.amt || 0));
|
||||
|
||||
const checkout_list = order_datums.filter(
|
||||
(food) => food && (findAmount(item_amts, food.name) || 0)
|
||||
);
|
||||
return (
|
||||
<Stack vertical fill>
|
||||
<Stack.Item grow>
|
||||
@@ -174,7 +192,7 @@ const CheckoutTab = (props, context) => {
|
||||
</Stack.Item>
|
||||
<Stack.Item mt={-0.5}>
|
||||
<NumberInput
|
||||
value={item.amt || 0}
|
||||
value={findAmount(item_amts, item.name) || 0}
|
||||
width="41px"
|
||||
minValue={0}
|
||||
maxValue={(item.cost > 10 && 50) || 10}
|
||||
|
||||
Reference in New Issue
Block a user