mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
Attempt to fix shop loading bug
This commit is contained in:
parent
9cc3109fed
commit
7704bbe497
1 changed files with 2 additions and 15 deletions
|
|
@ -18,21 +18,8 @@ export const shopParts = async () => {
|
|||
const fields = record.fields;
|
||||
let stock = fields["Stock"]
|
||||
|
||||
if (stock && fields["Orders"]) {
|
||||
const orderIds = fields["Orders"]
|
||||
const ordersFilter = orderIds.map(id => `RECORD_ID() = "${id}"`).join(", ")
|
||||
const data = await ordersTable.read({
|
||||
filterByFormula: `
|
||||
AND(
|
||||
OR(${ordersFilter}),
|
||||
OR(
|
||||
{Status} = "Fulfilled",
|
||||
{Status} = "Awaiting Fulfillment"
|
||||
)
|
||||
)`
|
||||
})
|
||||
|
||||
stock -= data.length;
|
||||
if (stock && fields["Count of Orders Fulfilled"]) {
|
||||
fields["Stock"] -= fields["Count of Orders Fulfilled"]
|
||||
}
|
||||
return { id: record.id, ...record.fields, "Stock": (stock == null)? null : (stock >= 0 ? stock : 0) }
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue