-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: loader to pick up stock by store * deno check
- Loading branch information
1 parent
f640cf7
commit 4176a56
Showing
2 changed files
with
68 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { AppContext } from "../../mod.ts"; | ||
import type { ProductBalance } from "../../utils/types.ts"; | ||
|
||
interface Props { | ||
/** | ||
* @description Product SKU | ||
*/ | ||
skuId: number; | ||
} | ||
|
||
export default async function loader( | ||
props: Props, | ||
_req: Request, | ||
ctx: AppContext, | ||
): Promise<ProductBalance[]> { | ||
const { skuId } = props; | ||
const { vcs } = ctx; | ||
|
||
try { | ||
const stockByStore = await vcs | ||
["GET /api/logistics/pvt/inventory/skus/:skuId"]({ skuId }) | ||
.then((r) => r.json()) as { | ||
skuId?: string; | ||
balance?: ProductBalance[]; | ||
}; | ||
|
||
return stockByStore.balance || []; | ||
} catch (error) { | ||
console.log(error); | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters