* feat: initial impl. of Unfulfilled section and create flow * feat: create fulfillment * feat: order <> fulfillment link, fulfillment section * feat: accept order_id when creating fulfillment * feat: finish create and cancel * fix: integration test * refactor: real Order<>Fulfillment link instead readonly, add link step to the workflow * fix: revert `order_id` definitions * chore: add changeset * fix: build * fix: address comments * fix: fetch inventory and location levels for fulfilled variant * fix: loading inventory details * add isList to order fulfillment link * fix: duplicate declaration * fix: type * refactor: link orders step, fix client * fix: move translations to the new file * fix: pass order id in test --------- Co-authored-by: olivermrbl <oliver@mrbltech.com>
33 lines
631 B
TypeScript
33 lines
631 B
TypeScript
/**
|
|
* Pick properties from an object and copy them to a new object
|
|
* @param obj
|
|
* @param keys
|
|
*/
|
|
export function pick(obj: Record<string, any>, keys: string[]) {
|
|
const ret: Record<string, any> = {}
|
|
|
|
keys.forEach((k) => {
|
|
if (k in obj) {
|
|
ret[k] = obj[k]
|
|
}
|
|
})
|
|
|
|
return ret
|
|
}
|
|
|
|
/**
|
|
* Remove properties that are `null` or `undefined` from the object.
|
|
* @param obj
|
|
*/
|
|
export function cleanNonValues(obj: Record<string, any>) {
|
|
const ret: Record<string, any> = {}
|
|
|
|
for (const key in obj) {
|
|
if (obj[key] !== null && typeof obj[key] !== "undefined") {
|
|
ret[key] = obj[key]
|
|
}
|
|
}
|
|
|
|
return ret
|
|
}
|