Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - [VTEX] Feat: add new types and cancel order action #945

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
518d316
feat: make it possible to exclude routes from being proxied in vtex
soutofernando Sep 25, 2024
4c4daee
feat: add session loaders
vitoUwu Sep 26, 2024
4d14fd9
feat: some payments related loaders
vitoUwu Oct 3, 2024
cdfdaaa
feat: my account vtex profile (#899)
devartes Oct 3, 2024
c66022a
feat: add the unitary order loader and start creating its typing
marcoferreiradev Oct 3, 2024
53d1d2e
fix: props user.ts
devartes Oct 3, 2024
9f2cf75
feat: updateAddress action
soutofernando Oct 3, 2024
9e3bee2
chore: rebuild manifest
soutofernando Oct 3, 2024
677dc1c
deno check
soutofernando Oct 3, 2024
36064d7
add try catch
guitavano Oct 4, 2024
92ad19b
remov throw
guitavano Oct 4, 2024
50d3d4c
feat: adds address list loader
marcoferreiradev Oct 7, 2024
647f3e6
feat: add loader to check if the password has already been changed
marcoferreiradev Oct 9, 2024
b617008
fix: receive address update props
soutofernando Oct 11, 2024
d9c45c6
feat: create adress action
soutofernando Oct 11, 2024
4d783d1
chore: fixes typing error pointing by linter
marcoferreiradev Oct 14, 2024
036818e
chore: fixes typing error pointing by linter
marcoferreiradev Oct 14, 2024
febc6eb
feat: get address by postal code loader
soutofernando Oct 14, 2024
57824d4
feat: delete address action
soutofernando Oct 16, 2024
84af288
chore: merge it
yuriassuncx Oct 24, 2024
e295484
feat: add order cancellation action
yuriassuncx Oct 24, 2024
8b06106
feat(vtex): Package type added
yuriassuncx Oct 25, 2024
04b9be8
feat: type added to the return of the cancel order action
yuriassuncx Oct 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions vtex/actions/orders/cancel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { parseCookie } from "../../utils/vtexId.ts";
import { AppContext } from "../../mod.ts";
import { CanceledOrder } from "../../utils/types.ts";

interface Props {
orderId: string;
reason: string;
}

async function action(
props: Props,
req: Request,
ctx: AppContext,
): Promise<CanceledOrder | null> {
const { vcsDeprecated } = ctx;
const { cookie, payload } = parseCookie(req.headers, ctx.account);

if (!payload?.sub || !payload?.userId) {
return null;
}

const { orderId, reason } = props;

const response = await vcsDeprecated
["POST /api/oms/user/orders/:orderId/cancel"](
{ orderId },
{
body: { reason },
headers: {
cookie,
},
},
);

if (response.ok) {
const canceledOrder = await response.json();
return canceledOrder;
}

return null;
}

export default action;
34 changes: 18 additions & 16 deletions vtex/manifest.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import * as $$$$$$$$$19 from "./actions/cart/updateUser.ts";
import * as $$$$$$$$$20 from "./actions/masterdata/createDocument.ts";
import * as $$$$$$$$$21 from "./actions/newsletter/subscribe.ts";
import * as $$$$$$$$$22 from "./actions/notifyme.ts";
import * as $$$$$$$$$23 from "./actions/payments/delete.ts";
import * as $$$$$$$$$24 from "./actions/profile/newsletterProfile.ts";
import * as $$$$$$$$$25 from "./actions/profile/updateProfile.ts";
import * as $$$$$$$$$26 from "./actions/review/submit.ts";
import * as $$$$$$$$$27 from "./actions/sessions/delete.ts";
import * as $$$$$$$$$28 from "./actions/trigger.ts";
import * as $$$$$$$$$29 from "./actions/wishlist/addItem.ts";
import * as $$$$$$$$$30 from "./actions/wishlist/removeItem.ts";
import * as $$$$$$$$$23 from "./actions/orders/cancel.ts";
import * as $$$$$$$$$24 from "./actions/payments/delete.ts";
import * as $$$$$$$$$25 from "./actions/profile/newsletterProfile.ts";
import * as $$$$$$$$$26 from "./actions/profile/updateProfile.ts";
import * as $$$$$$$$$27 from "./actions/review/submit.ts";
import * as $$$$$$$$$28 from "./actions/sessions/delete.ts";
import * as $$$$$$$$$29 from "./actions/trigger.ts";
import * as $$$$$$$$$30 from "./actions/wishlist/addItem.ts";
import * as $$$$$$$$$31 from "./actions/wishlist/removeItem.ts";
import * as $$$$0 from "./handlers/sitemap.ts";
import * as $$$0 from "./loaders/address/getAddressByZIP.ts";
import * as $$$1 from "./loaders/address/list.ts";
Expand Down Expand Up @@ -159,14 +160,15 @@ const manifest = {
"vtex/actions/masterdata/createDocument.ts": $$$$$$$$$20,
"vtex/actions/newsletter/subscribe.ts": $$$$$$$$$21,
"vtex/actions/notifyme.ts": $$$$$$$$$22,
"vtex/actions/payments/delete.ts": $$$$$$$$$23,
"vtex/actions/profile/newsletterProfile.ts": $$$$$$$$$24,
"vtex/actions/profile/updateProfile.ts": $$$$$$$$$25,
"vtex/actions/review/submit.ts": $$$$$$$$$26,
"vtex/actions/sessions/delete.ts": $$$$$$$$$27,
"vtex/actions/trigger.ts": $$$$$$$$$28,
"vtex/actions/wishlist/addItem.ts": $$$$$$$$$29,
"vtex/actions/wishlist/removeItem.ts": $$$$$$$$$30,
"vtex/actions/orders/cancel.ts": $$$$$$$$$23,
"vtex/actions/payments/delete.ts": $$$$$$$$$24,
"vtex/actions/profile/newsletterProfile.ts": $$$$$$$$$25,
"vtex/actions/profile/updateProfile.ts": $$$$$$$$$26,
"vtex/actions/review/submit.ts": $$$$$$$$$27,
"vtex/actions/sessions/delete.ts": $$$$$$$$$28,
"vtex/actions/trigger.ts": $$$$$$$$$29,
"vtex/actions/wishlist/addItem.ts": $$$$$$$$$30,
"vtex/actions/wishlist/removeItem.ts": $$$$$$$$$31,
},
"workflows": {
"vtex/workflows/events.ts": $$$$$$$$$$0,
Expand Down
7 changes: 7 additions & 0 deletions vtex/utils/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Userorderslist } from "./openapi/vcs.openapi.gen.ts";
import {
Brand,
CanceledOrder,
Category,
CreateNewDocument,
FacetSearchResult,
Expand Down Expand Up @@ -252,6 +253,12 @@ export interface VTEXCommerceStable {
"GET /api/oms/user/orders/:orderId": {
response: OrderItem;
};
"POST /api/oms/user/orders/:orderId/cancel": {
response: CanceledOrder;
body: {
reason: string;
};
};
}

export interface SP {
Expand Down
27 changes: 27 additions & 0 deletions vtex/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,24 @@ export interface Order {
workflowInRetry: boolean;
}

export interface Package {
cfop: string | null;
invoiceNumber: string;
invoiceValue: number;
invoiceUrl: string | null;
issuanceDate: string;
trackingNumber: string | null;
invoiceKey: string;
trackingUrl: string | null;
embeddedInvoice: string;
courierStatus: {
status: string | null;
finished: boolean;
deliveredDate: string;
};
type: "Input" | "Output";
}

export interface OrderItem {
orderId: string;
sequence: string;
Expand All @@ -1377,6 +1395,9 @@ export interface OrderItem {
authorizedDate: string;
callCenterOperatorData: string;
cancelReason: string;
packageAttachment: {
packages: Package[];
} | null;
cancellationData: {
RequestedByUser: boolean;
RequestedBySystem: boolean;
Expand Down Expand Up @@ -1431,6 +1452,12 @@ export interface OrderItem {
openTextField: string | null;
}

export interface CanceledOrder {
date: string;
orderId: string;
receipt: string | null;
}

interface Marketplace {
baseURL: string;
// deno-lint-ignore no-explicit-any
Expand Down