-
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.
Merge pull request #21 from deco-cx/feat/vnda-cart
feat: vnda httpclient
- Loading branch information
Showing
21 changed files
with
336 additions
and
450 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
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
This file was deleted.
Oops, something went wrong.
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 { HttpError } from "../../../utils/http.ts"; | ||
import cartLoader from "../../loaders/cart.ts"; | ||
import { AppContext } from "../../mod.ts"; | ||
import { getCartCookie } from "../../utils/cart.ts"; | ||
import type { Cart } from "../../utils/client/types.ts"; | ||
|
||
export interface Props { | ||
agent?: string; | ||
zip?: string; | ||
client_id?: number; | ||
coupon_code?: string; | ||
rebate_token?: string; | ||
} | ||
|
||
const action = async ( | ||
props: Props, | ||
req: Request, | ||
ctx: AppContext, | ||
): Promise<Cart> => { | ||
const { api } = ctx; | ||
const cartId = getCartCookie(req.headers); | ||
|
||
if (!cartId) { | ||
throw new HttpError(400, "Missing cart cookie"); | ||
} | ||
|
||
await api["PATCH /api/v2/carts/:cartId"]({ cartId }, { body: props }); | ||
|
||
return cartLoader({}, req, ctx); | ||
}; | ||
|
||
export default action; |
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
Oops, something went wrong.