mirror of
https://github.com/System-End/site.git
synced 2026-04-19 23:22:49 +00:00
Basic formula because everything is terrible
This commit is contained in:
parent
6b802206ef
commit
ed13ee4c76
1 changed files with 6 additions and 7 deletions
|
|
@ -18,13 +18,12 @@ export const shopParts = async () => {
|
|||
let stock = fields["Stock"]
|
||||
|
||||
if (stock) {
|
||||
const records = await ordersTable.read();
|
||||
const targetRecordId = record.id;
|
||||
const matchingRecords = records.filter(recordToFilter =>
|
||||
recordToFilter.id === targetRecordId &&
|
||||
(recordToFilter.fields["Status"] === "Fulfilled" || recordToFilter.fields["Status"] === "Awaiting Fulfillment")
|
||||
);
|
||||
stock -= matchingRecords.length;
|
||||
stock -= (await ordersTable.read({
|
||||
filterByFormula: `OR(
|
||||
{Status} = "Fulfilled",
|
||||
{Status} = "Awaiting Fulfillment"
|
||||
)`
|
||||
})).length;
|
||||
}
|
||||
return { id: record.id, ...record.fields, "Stock": stock ?? null }
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue