@shophost/rest-api 2.0.33 → 2.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/minify-dist.mjs +45 -0
- package/src/app.js +1 -53
- package/src/core/auth/auth.schema.js +1 -41
- package/src/core/auth/auth.util.js +1 -44
- package/src/core/auth/better-auth.lib.js +1 -100
- package/src/core/auth/generate-password-hash.util.js +1 -30
- package/src/core/auth/headers.schema.js +1 -22
- package/src/core/auth/user.schema.js +1 -30
- package/src/core/db/__generated__/client/browser.js +1 -18
- package/src/core/db/__generated__/client/client.js +1 -35
- package/src/core/db/__generated__/client/commonInputTypes.js +1 -11
- package/src/core/db/__generated__/client/enums.js +1 -200
- package/src/core/db/__generated__/client/internal/class.js +769 -55
- package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -541
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -512
- package/src/core/db/__generated__/client/models/Account.js +1 -2
- package/src/core/db/__generated__/client/models/Address.js +1 -2
- package/src/core/db/__generated__/client/models/Campaign.js +1 -2
- package/src/core/db/__generated__/client/models/ClosingTimes.js +1 -2
- package/src/core/db/__generated__/client/models/File.js +1 -2
- package/src/core/db/__generated__/client/models/Invitation.js +1 -2
- package/src/core/db/__generated__/client/models/LegalEntity.js +1 -2
- package/src/core/db/__generated__/client/models/Manufacturer.js +1 -2
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Member.js +1 -2
- package/src/core/db/__generated__/client/models/Modifier.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroup.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/OpeningTimes.js +1 -2
- package/src/core/db/__generated__/client/models/Order.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItem.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItemTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Organization.js +1 -2
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +1 -2
- package/src/core/db/__generated__/client/models/Payment.js +1 -2
- package/src/core/db/__generated__/client/models/PaymentSession.js +1 -2
- package/src/core/db/__generated__/client/models/Product.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategory.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/ProductSnapshot.js +1 -2
- package/src/core/db/__generated__/client/models/ProductTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Reservation.js +1 -2
- package/src/core/db/__generated__/client/models/Session.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingMethod.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingZone.js +1 -2
- package/src/core/db/__generated__/client/models/User.js +1 -2
- package/src/core/db/__generated__/client/models/Verification.js +1 -2
- package/src/core/db/__generated__/client/models.js +1 -2
- package/src/core/db/index.js +1 -2
- package/src/core/exceptions/http-exception.js +1 -9
- package/src/core/hono/hono.js +1 -123
- package/src/core/lib/prisma.js +1 -11
- package/src/core/logging/pino.js +1 -5
- package/src/core/notifications/email.service.js +1 -116
- package/src/core/openapi/openapi.lib.js +1 -26
- package/src/core/types/google-maps.types.js +1 -2
- package/src/core/utils/currency.util.js +1 -11
- package/src/core/utils/env.util.js +1 -8
- package/src/core/utils/object.util.js +1 -39
- package/src/core/utils/translations.util.js +0 -1
- package/src/core/utils/zod.util.js +1 -85
- package/src/db.js +1 -3
- package/src/features/access/access.handler.js +1 -91
- package/src/features/access/access.route.js +1 -220
- package/src/features/access/access.schema.js +1 -108
- package/src/features/access/access.service.js +1 -294
- package/src/features/cart/cart.handler.js +1 -17
- package/src/features/cart/cart.route.js +1 -32
- package/src/features/cart/cart.schema.js +1 -39
- package/src/features/cart/cart.service.js +1 -97
- package/src/features/cart/cart.util.js +1 -76
- package/src/features/file/file.handler.js +1 -23
- package/src/features/file/file.route.js +1 -34
- package/src/features/file/file.schema.js +1 -77
- package/src/features/file/file.service.js +1 -66
- package/src/features/health/health.handler.js +1 -10
- package/src/features/health/health.route.js +1 -25
- package/src/features/index.js +1 -16
- package/src/features/location/location.handler.js +1 -25
- package/src/features/location/location.route.js +1 -56
- package/src/features/location/location.schema.js +1 -50
- package/src/features/location/location.service.js +1 -141
- package/src/features/manufacturer/manufacturer.handler.js +1 -53
- package/src/features/manufacturer/manufacturer.route.js +1 -97
- package/src/features/manufacturer/manufacturer.schema.js +1 -125
- package/src/features/manufacturer/manufacturer.service.js +1 -190
- package/src/features/order/emails/order-confirmation.email.js +1 -229
- package/src/features/order/emails/order-notification.email.js +1 -229
- package/src/features/order/fulfilment.schema.js +1 -3
- package/src/features/order/order.handler.js +1 -54
- package/src/features/order/order.route.js +1 -111
- package/src/features/order/order.schema.js +1 -158
- package/src/features/order/order.service.js +1 -306
- package/src/features/order/recipient.schema.js +1 -38
- package/src/features/organization/legal-entity.schema.js +1 -83
- package/src/features/organization/organization-configuration.schema.js +1 -115
- package/src/features/organization/organization.handler.js +1 -48
- package/src/features/organization/organization.route.js +1 -84
- package/src/features/organization/organization.schema.js +1 -64
- package/src/features/organization/organization.service.js +1 -334
- package/src/features/payment/payment.handler.js +1 -16
- package/src/features/payment/payment.route.js +1 -22
- package/src/features/payment/payment.schema.js +1 -46
- package/src/features/payment/payment.service.js +1 -100
- package/src/features/payment/stripe.service.js +1 -164
- package/src/features/product/product-modifier.schema.js +1 -84
- package/src/features/product/product.handler.js +1 -87
- package/src/features/product/product.route.js +1 -179
- package/src/features/product/product.schema.js +1 -143
- package/src/features/product/product.service.js +1 -440
- package/src/features/product-category/product-category.handler.js +1 -59
- package/src/features/product-category/product-category.route.js +1 -139
- package/src/features/product-category/product-category.schema.js +1 -86
- package/src/features/product-category/product-category.service.js +1 -220
- package/src/features/reservation/emails/reservation-cancellation.email.js +1 -82
- package/src/features/reservation/emails/reservation-confirmation.email.js +1 -82
- package/src/features/reservation/emails/reservation-notification.email.js +1 -93
- package/src/features/reservation/reservation.handler.js +1 -65
- package/src/features/reservation/reservation.route.js +1 -167
- package/src/features/reservation/reservation.schema.js +1 -51
- package/src/features/reservation/reservation.service.js +1 -231
- package/src/features/shipping/shipping.handler.js +1 -32
- package/src/features/shipping/shipping.route.js +1 -51
- package/src/features/shipping/shipping.service.js +1 -96
- package/src/features/shipping-method/shipping-method.handler.js +1 -60
- package/src/features/shipping-method/shipping-method.route.js +1 -144
- package/src/features/shipping-method/shipping-method.schema.js +1 -48
- package/src/features/shipping-method/shipping-method.service.js +1 -229
- package/src/features/shipping-method/shipping-zone.schema.js +1 -31
- package/src/features/webhook/webhook.handler.js +1 -50
- package/src/features/webhook/webhook.route.js +1 -33
- package/src/index.js +1 -6
- package/src/integrations/next.js +1 -82
- package/src/schemas/address.schema.js +1 -112
- package/src/schemas/currency.schema.js +1 -118
- package/src/schemas/error.schema.js +1 -12
- package/src/schemas/index.js +1 -29
- package/src/schemas/locales.schema.js +1 -238
- package/src/schemas/number.schema.js +1 -29
- package/src/schemas/pagination.schema.js +1 -54
- package/src/schemas/params.schema.js +1 -20
- package/src/schemas/queries.schema.js +1 -6
- package/src/test/global-setup.js +1 -37
- package/src/test/integration/api-fixtures.js +1 -160
- package/src/test/integration/seed.js +1 -368
- package/src/test/integration/test-helpers.js +1 -154
- package/src/test/setup-test-env.js +1 -7
|
@@ -1,229 +1 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Body, Column, Container, Head, Heading, Hr, Html, Img, Link, Preview, Row, Section, Tailwind, Text, } from "@react-email/components";
|
|
3
|
-
const formatPrice = (price, currency = "PLN", locale = "en-US") => {
|
|
4
|
-
return new Intl.NumberFormat(locale, {
|
|
5
|
-
style: "currency",
|
|
6
|
-
currency,
|
|
7
|
-
}).format(price);
|
|
8
|
-
};
|
|
9
|
-
const OrderNotificationEmail = ({ user, organization, order, }) => {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
11
|
-
const previewText = `New order #${order.referenceId} received`;
|
|
12
|
-
const formattedDate = new Date().toLocaleDateString("en-GB", {
|
|
13
|
-
day: "2-digit",
|
|
14
|
-
month: "2-digit",
|
|
15
|
-
year: "numeric",
|
|
16
|
-
});
|
|
17
|
-
// Extract data from order.payment safely
|
|
18
|
-
const shippingCost = ((_a = order.payment) === null || _a === void 0 ? void 0 : _a.shipping) || 0;
|
|
19
|
-
const discount = ((_b = order.payment) === null || _b === void 0 ? void 0 : _b.discount) || 0;
|
|
20
|
-
const total = ((_c = order.payment) === null || _c === void 0 ? void 0 : _c.total) || 0;
|
|
21
|
-
const ordersUrl = `https://${organization.configuration.hostname}/admin/orders/${order.id}`;
|
|
22
|
-
return (_jsxs(Html, { children: [_jsx(Head, {}), _jsx(Preview, { children: previewText }), _jsx(Tailwind, { children: _jsxs(Body, { className: "bg-gray-50 font-sans", children: [_jsxs(Container, { className: "bg-gray-50 p-6 max-w-[600px]", children: [_jsx(Section, { className: "mb-6", children: _jsxs(Row, { children: [_jsx(Column, { className: "w-[80%]", children: _jsx(Img, { alt: `${organization.name} logo`, height: "100", src: (_d = organization.logoFile) === null || _d === void 0 ? void 0 : _d.url, className: "rounded-lg" }) }), _jsx(Column, { align: "right", children: _jsxs(Row, { align: "right", children: [_jsx(Column, { children: _jsx(Link, { href: "https://www.instagram.com/madrasbistro/", children: _jsx(Img, { alt: "Instagram", className: "mx-[4px]", height: "36", src: "https://react.email/static/instagram-logo.png", width: "36" }) }) }), _jsx(Column, { children: _jsx(Link, { href: "https://www.facebook.com/madrasBistro/", children: _jsx(Img, { alt: "Facebook", className: "mx-[4px]", height: "36", src: "https://react.email/static/facebook-logo.png", width: "36" }) }) })] }) })] }) }), _jsxs(Section, { children: [_jsx(Heading, { className: "text-3xl font-bold text-gray-800 mb-0", children: "You have received a new order" }), _jsxs(Text, { className: "text-gray-600 mb-2 text-lg", children: ["Order #", order.referenceId, " has been placed and is waiting for your action."] })] }), _jsx(Section, { className: "mb-0", children: _jsx(Link, { href: ordersUrl, className: "bg-gray-900 text-sm rounded-md text-white font-medium py-2 px-5 text-center inline-block my-4", children: "View Order Details" }) })] }), _jsxs(Container, { className: "mx-auto max-w-[600px] rounded-xl bg-white px-6", children: [_jsx(Section, { className: "mb-6", children: _jsxs(Row, { children: [_jsxs(Column, { className: "w-[60%]", children: [_jsx(Text, { className: "text-gray-500 mb-0", children: "Customer Information" }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: [user.firstname, " ", user.lastname] }), _jsx(Text, { className: "font-semibold text-gray-800 my-0", children: user.email }), _jsx(Hr, { className: "border-gray-200 mb-2 mt-2" }), _jsx(Text, { className: "text-gray-500 mb-0", children: "Delivery Address" }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: [(_e = order.shippingAddress) === null || _e === void 0 ? void 0 : _e.firstname, " ", (_f = order.shippingAddress) === null || _f === void 0 ? void 0 : _f.lastname] }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: [(_g = order.shippingAddress) === null || _g === void 0 ? void 0 : _g.addressLineOne, " ", ((_h = order.shippingAddress) === null || _h === void 0 ? void 0 : _h.doorNumber) &&
|
|
23
|
-
` / ${(_j = order.shippingAddress) === null || _j === void 0 ? void 0 : _j.doorNumber}`, _jsx("br", {}), (_k = order.shippingAddress) === null || _k === void 0 ? void 0 : _k.city, " ", (_l = order.shippingAddress) === null || _l === void 0 ? void 0 : _l.zipCode] }), _jsx(Text, { className: "text-gray-500 mb-0", children: "Phone" }), _jsx(Text, { className: "font-semibold text-gray-800 my-0", children: (_m = order.shippingAddress) === null || _m === void 0 ? void 0 : _m.phone }), ((_o = order.shippingAddress) === null || _o === void 0 ? void 0 : _o.deliveryInstructions) && (_jsxs(_Fragment, { children: [_jsx(Text, { className: "text-gray-500 mb-0", children: "Delivery Instructions" }), _jsx(Text, { className: "font-semibold text-gray-800 my-0", children: order.shippingAddress.deliveryInstructions })] }))] }), _jsxs(Column, { className: "w-[40%] p-0 mt-0", align: "right", valign: "top", children: [_jsxs(Text, { className: "text-gray-500 mb-0 pt-1", children: ["Order Date: ", formattedDate] }), _jsxs(Text, { className: "text-gray-500 mb-0 pt-1", children: ["Order ID: ", order.referenceId] }), _jsxs(Text, { className: "text-gray-500 mb-0 pt-1", children: ["Payment: ", (_p = order.payment) === null || _p === void 0 ? void 0 : _p.status] })] })] }) }), _jsx(Text, { className: "text-gray-500 mb-0", children: "Order Items" }), _jsx(Hr, { className: "border-gray-200 mb-0" }), _jsx(Section, { children: order.items.map((item, index) => {
|
|
24
|
-
var _a, _b;
|
|
25
|
-
// Safely cast item to include our extended fields
|
|
26
|
-
const extendedItem = item;
|
|
27
|
-
return (_jsx("table", { width: "100%", cellPadding: 0, cellSpacing: 0, border: 0, className: index === order.items.length - 1 ? "mb-0" : "mb-4", children: _jsxs("tr", { children: [_jsxs("td", { valign: "top", children: [_jsxs(Text, { className: "font-semibold mb-0", children: [((_a = extendedItem.translations[0]) === null || _a === void 0 ? void 0 : _a.title) || "Product", " (", ((_b = extendedItem.translations[0]) === null || _b === void 0 ? void 0 : _b.subtitle) || "", ")"] }), _jsxs(Text, { className: "text-gray-600 mb-0 mt-0", children: ["Quantity: ", extendedItem.quantity] })] }), _jsx("td", { align: "right", valign: "top", children: _jsx(Text, { className: "font-semibold", children: formatPrice(extendedItem.unitPrice * extendedItem.quantity, organization.configuration.defaultCurrency, organization.configuration.defaultLocale) }) })] }) }, index));
|
|
28
|
-
}) }), _jsx(Hr, { className: "border-gray-200 mt-4" }), _jsx(Section, { children: _jsxs("table", { width: "100%", cellPadding: 0, cellSpacing: 0, border: 0, children: [_jsxs("tr", { children: [_jsx("td", { children: _jsx(Text, { className: "text-gray-700", children: "Delivery fee" }) }), _jsx("td", { align: "right", children: _jsx(Text, { className: "text-gray-700", children: formatPrice(shippingCost, organization.configuration.defaultCurrency, organization.configuration.defaultLocale) }) })] }), discount > 0 && (_jsxs("tr", { children: [_jsx("td", { children: _jsx(Text, { className: "text-gray-700", children: "Campaign" }) }), _jsx("td", { align: "right", children: _jsxs(Text, { className: "text-gray-700", children: ["-", formatPrice(discount, organization.configuration.defaultCurrency, organization.configuration.defaultLocale)] }) })] }))] }) }), _jsx(Hr, { className: "border-gray-200" }), _jsx(Section, { className: "mb-6", children: _jsx("table", { width: "100%", cellPadding: 0, cellSpacing: 0, border: 0, children: _jsxs("tr", { children: [_jsx("td", { children: _jsx(Text, { className: "text-xl font-bold mb-0", children: "Total:" }) }), _jsx("td", { align: "right", children: _jsx(Text, { className: "text-xl font-bold mb-0", children: formatPrice(total, organization.configuration.defaultCurrency, organization.configuration.defaultLocale) }) })] }) }) })] }), _jsx(Section, { className: "text-center bg-gray-50 py-5", children: _jsxs("table", { className: "w-full", children: [_jsx("tr", { className: "w-full", children: _jsx("td", { align: "center", children: ((_q = organization.logoFile) === null || _q === void 0 ? void 0 : _q.url) && (_jsx(Img, { alt: `${organization.name} logo`, height: "100", src: organization.logoFile.url, className: "rounded-lg" })) }) }), _jsx("tr", { className: "w-full", children: _jsxs("td", { align: "center", children: [_jsx(Text, { className: "my-[8px] text-[16px] font-semibold text-xl pt-2 text-gray-900", children: organization.name }), _jsxs(Text, { className: "my-[8px] text-[16px] leading-[24px] text-gray-500", children: [(_r = organization.address) === null || _r === void 0 ? void 0 : _r.addressLineOne, ",", " ", (_s = organization.address) === null || _s === void 0 ? void 0 : _s.zipCode, " ", (_t = organization.address) === null || _t === void 0 ? void 0 : _t.city] }), _jsx(Text, { className: "mb-0 mt-[4px] text-[16px] leading-[24px] text-gray-500", children: organization.phone })] }) }), _jsx("tr", { children: _jsx("td", { align: "center", children: _jsxs(Row, { className: "table-cell h-[44px] w-[56px] align-bottom pt-5", children: [_jsx(Column, { className: "pr-[8px]", children: _jsx(Link, { href: "https://www.facebook.com/madrasBistro/", children: _jsx(Img, { alt: "Facebook", height: "36", src: "https://react.email/static/facebook-logo.png", width: "36" }) }) }), _jsx(Column, { children: _jsx(Link, { href: "https://www.instagram.com/madrasbistro/", children: _jsx(Img, { alt: "Instagram", height: "36", src: "https://react.email/static/instagram-logo.png", width: "36" }) }) })] }) }) })] }) })] }) })] }));
|
|
29
|
-
};
|
|
30
|
-
const previewProps = {
|
|
31
|
-
user: {
|
|
32
|
-
id: "VD0OJ52f0mdAnm5YePP6BAW6hdbaCjAJ",
|
|
33
|
-
name: "Abhishek Shaji",
|
|
34
|
-
email: "kontakt@abhishek.pl",
|
|
35
|
-
emailVerified: true,
|
|
36
|
-
image: "https://lh3.googleusercontent.com/a/ACg8ocKbkCAMTNvMizjXNxcm1aYtBiWnYpCYmU-7aE2Ft_M_uiHheZ5f=s96-c",
|
|
37
|
-
createdAt: "2025-03-22T22:54:40.260Z",
|
|
38
|
-
updatedAt: "2025-03-22T22:54:40.260Z",
|
|
39
|
-
firstname: "Abhishek",
|
|
40
|
-
lastname: "Shaji",
|
|
41
|
-
},
|
|
42
|
-
order: {
|
|
43
|
-
id: "cm94wbpbm0000itx1iv9k2mqr",
|
|
44
|
-
referenceId: "PH6LD6",
|
|
45
|
-
token: "VAE9TX",
|
|
46
|
-
expiresAt: "2025-04-07T00:20:09.689Z",
|
|
47
|
-
items: [
|
|
48
|
-
{
|
|
49
|
-
translations: [
|
|
50
|
-
{
|
|
51
|
-
locale: "en",
|
|
52
|
-
title: "Masala Dosa",
|
|
53
|
-
subtitle: "Spice Level: Medium",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
locale: "pl",
|
|
57
|
-
title: "null",
|
|
58
|
-
subtitle: "Spice Level: Medium",
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
rawData: {
|
|
62
|
-
productId: "cm8kudyqq0006ityduhq0yveu",
|
|
63
|
-
quantity: 6,
|
|
64
|
-
modifierGroups: [
|
|
65
|
-
{
|
|
66
|
-
id: "cm8kuonhv0002ji032ji4bzmc",
|
|
67
|
-
modifiers: [
|
|
68
|
-
{
|
|
69
|
-
id: "cm8kudyqq000ditydq25s2n2e",
|
|
70
|
-
quantity: 1,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
unitPrice: 39,
|
|
77
|
-
image: {
|
|
78
|
-
id: "cm8kuee0m0000l703ocs7snfb",
|
|
79
|
-
url: "https://z3liuyatqnepss3d.public.blob.vercel-storage.com/Masala%20Dosa-b0tr9uWZqmBTPMUx4x0fzqkM6z5eCw.png",
|
|
80
|
-
mimeType: "image/png",
|
|
81
|
-
size: 1429845,
|
|
82
|
-
filename: "Masala Dosa.png",
|
|
83
|
-
},
|
|
84
|
-
totalPrice: 234,
|
|
85
|
-
quantity: 6,
|
|
86
|
-
productSnapshotId: "cm8kuopty0006ji035n7w5iby",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
translations: [
|
|
90
|
-
{
|
|
91
|
-
locale: "en",
|
|
92
|
-
title: "Masala Dosa",
|
|
93
|
-
subtitle: "Spice Level: Medium",
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
locale: "pl",
|
|
97
|
-
title: "null",
|
|
98
|
-
subtitle: "Spice Level: Medium",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
rawData: {
|
|
102
|
-
productId: "cm8kudyqq0006ityduhq0yveu",
|
|
103
|
-
quantity: 6,
|
|
104
|
-
modifierGroups: [
|
|
105
|
-
{
|
|
106
|
-
id: "cm8kuonhv0002ji032ji4bzmc",
|
|
107
|
-
modifiers: [
|
|
108
|
-
{
|
|
109
|
-
id: "cm8kudyqq000ditydq25s2n2e",
|
|
110
|
-
quantity: 1,
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
unitPrice: 39,
|
|
117
|
-
image: {
|
|
118
|
-
id: "cm8kuee0m0000l703ocs7snfb",
|
|
119
|
-
url: "https://z3liuyatqnepss3d.public.blob.vercel-storage.com/Masala%20Dosa-b0tr9uWZqmBTPMUx4x0fzqkM6z5eCw.png",
|
|
120
|
-
mimeType: "image/png",
|
|
121
|
-
size: 1429845,
|
|
122
|
-
filename: "Masala Dosa.png",
|
|
123
|
-
},
|
|
124
|
-
totalPrice: 234,
|
|
125
|
-
quantity: 6,
|
|
126
|
-
productSnapshotId: "cm8kuopty0006ji035n7w5iby",
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
shippingMethod: {
|
|
130
|
-
id: "cm8kuqmkd000iitydar4a1poy",
|
|
131
|
-
title: "Express Delivery",
|
|
132
|
-
providerName: "Wolt Courier",
|
|
133
|
-
requireDateOfDelivery: true,
|
|
134
|
-
shippingZones: [
|
|
135
|
-
{
|
|
136
|
-
id: "cm8kuqmkd000jitydpdvck2th",
|
|
137
|
-
title: "Zone 1",
|
|
138
|
-
distanceUpto: 7,
|
|
139
|
-
price: 1,
|
|
140
|
-
minimumOrderAmount: 60,
|
|
141
|
-
eta: "90min",
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
createdAt: "2025-03-22T23:40:23.101Z",
|
|
145
|
-
updatedAt: "2025-03-22T23:40:35.319Z",
|
|
146
|
-
},
|
|
147
|
-
acceptedAt: null,
|
|
148
|
-
dispatchedAt: null,
|
|
149
|
-
readyForDispatchAt: null,
|
|
150
|
-
completedAt: null,
|
|
151
|
-
cancelledAt: null,
|
|
152
|
-
shippingAddress: {
|
|
153
|
-
id: "cm94wbpbm0007itx1akuqh77n",
|
|
154
|
-
firstname: "Klaudia",
|
|
155
|
-
lastname: "Smoter",
|
|
156
|
-
phone: "+48570135862",
|
|
157
|
-
addressLineOne: "Stanisława Lema 28",
|
|
158
|
-
doorNumber: "54",
|
|
159
|
-
addressLineTwo: null,
|
|
160
|
-
zipCode: "31-571",
|
|
161
|
-
city: "Kraków",
|
|
162
|
-
country: "PL",
|
|
163
|
-
placeId: "ChIJrQfdh9VaFkcRIvg8O2PqnWM",
|
|
164
|
-
deliveryInstructions: "4th floor - Maho",
|
|
165
|
-
},
|
|
166
|
-
fulfilmentMethod: "delivery",
|
|
167
|
-
currency: "PLN",
|
|
168
|
-
payment: {
|
|
169
|
-
id: "cm94wbpbm0008itx1thsnj7ui",
|
|
170
|
-
method: "blik",
|
|
171
|
-
provider: "stripe",
|
|
172
|
-
status: "succeeded",
|
|
173
|
-
shipping: 1,
|
|
174
|
-
subtotal: 234,
|
|
175
|
-
total: 235,
|
|
176
|
-
discount: 0,
|
|
177
|
-
currency: "PLN",
|
|
178
|
-
},
|
|
179
|
-
status: "pending",
|
|
180
|
-
},
|
|
181
|
-
organization: {
|
|
182
|
-
id: "cm8kthfdq0001lg03b59mdy7b",
|
|
183
|
-
name: "Madras Bistro",
|
|
184
|
-
phone: "+48570135862",
|
|
185
|
-
email: "contact@madrasbistro.pl",
|
|
186
|
-
createdAt: "2025-03-22T23:05:14.271Z",
|
|
187
|
-
legalEntityId: null,
|
|
188
|
-
address: {
|
|
189
|
-
id: "cm8kthfdr0002lg0350ijialt",
|
|
190
|
-
firstname: null,
|
|
191
|
-
lastname: null,
|
|
192
|
-
phone: null,
|
|
193
|
-
addressLineOne: "Plac Bohaterów Getta 2",
|
|
194
|
-
doorNumber: null,
|
|
195
|
-
addressLineTwo: "3",
|
|
196
|
-
zipCode: "33-332",
|
|
197
|
-
city: "Kraków",
|
|
198
|
-
country: "PL",
|
|
199
|
-
placeId: "ChIJf-nsRkRbFkcR21gtObFSSSA",
|
|
200
|
-
deliveryInstructions: null,
|
|
201
|
-
},
|
|
202
|
-
configuration: {
|
|
203
|
-
id: "cm8kthfdr0003lg03ghgs262n",
|
|
204
|
-
hostname: "null",
|
|
205
|
-
countriesShipping: ["us"],
|
|
206
|
-
stripeAccountId: "null",
|
|
207
|
-
enableHostCheckout: false,
|
|
208
|
-
enableHostTracking: false,
|
|
209
|
-
isAcceptingOrders: false,
|
|
210
|
-
defaultLocale: "en",
|
|
211
|
-
supportedLocales: ["en", "pl"],
|
|
212
|
-
defaultCurrency: "PLN",
|
|
213
|
-
createdAt: "2025-03-22T23:05:14.271Z",
|
|
214
|
-
},
|
|
215
|
-
logo: "https://z3liuyatqnepss3d.public.blob.vercel-storage.com/logo-zeJymFRMFCIKPlvjxYm2af3SAWvBOj.png",
|
|
216
|
-
logoFile: {
|
|
217
|
-
id: "cm8ktmu890005lg0356gwclfk",
|
|
218
|
-
url: "https://z3liuyatqnepss3d.public.blob.vercel-storage.com/logo-zeJymFRMFCIKPlvjxYm2af3SAWvBOj.png",
|
|
219
|
-
mimeType: "image/png",
|
|
220
|
-
size: 1652289,
|
|
221
|
-
filename: "logo.png",
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
// Fixed the TypeScript error by using proper type assertion
|
|
226
|
-
OrderNotificationEmail.PreviewProps = previewProps;
|
|
227
|
-
export default OrderNotificationEmail;
|
|
228
|
-
export { OrderNotificationEmail };
|
|
229
|
-
//# sourceMappingURL=order-notification.email.js.map
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as J}from"react/jsx-runtime";import{Body as K,Column as s,Container as O,Head as U,Heading as $,Hr as m,Html as E,Img as d,Link as o,Preview as V,Row as h,Section as n,Tailwind as G,Text as l}from"@react-email/components";const u=(r,a="PLN",i="en-US")=>new Intl.NumberFormat(i,{style:"currency",currency:a}).format(r),S=({user:r,organization:a,order:i})=>{var p,g,b,y,f,v,x,N,w,k,A,q,P,I,C,L,_,M;const B=`New order #${i.referenceId} received`,Z=new Date().toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}),H=((p=i.payment)===null||p===void 0?void 0:p.shipping)||0,T=((g=i.payment)===null||g===void 0?void 0:g.discount)||0,W=((b=i.payment)===null||b===void 0?void 0:b.total)||0,R=`https://${a.configuration.hostname}/admin/orders/${i.id}`;return t(E,{children:[e(U,{}),e(V,{children:B}),e(G,{children:t(K,{className:"bg-gray-50 font-sans",children:[t(O,{className:"bg-gray-50 p-6 max-w-[600px]",children:[e(n,{className:"mb-6",children:t(h,{children:[e(s,{className:"w-[80%]",children:e(d,{alt:`${a.name} logo`,height:"100",src:(y=a.logoFile)===null||y===void 0?void 0:y.url,className:"rounded-lg"})}),e(s,{align:"right",children:t(h,{align:"right",children:[e(s,{children:e(o,{href:"https://www.instagram.com/madrasbistro/",children:e(d,{alt:"Instagram",className:"mx-[4px]",height:"36",src:"https://react.email/static/instagram-logo.png",width:"36"})})}),e(s,{children:e(o,{href:"https://www.facebook.com/madrasBistro/",children:e(d,{alt:"Facebook",className:"mx-[4px]",height:"36",src:"https://react.email/static/facebook-logo.png",width:"36"})})})]})})]})}),t(n,{children:[e($,{className:"text-3xl font-bold text-gray-800 mb-0",children:"You have received a new order"}),t(l,{className:"text-gray-600 mb-2 text-lg",children:["Order #",i.referenceId," has been placed and is waiting for your action."]})]}),e(n,{className:"mb-0",children:e(o,{href:R,className:"bg-gray-900 text-sm rounded-md text-white font-medium py-2 px-5 text-center inline-block my-4",children:"View Order Details"})})]}),t(O,{className:"mx-auto max-w-[600px] rounded-xl bg-white px-6",children:[e(n,{className:"mb-6",children:t(h,{children:[t(s,{className:"w-[60%]",children:[e(l,{className:"text-gray-500 mb-0",children:"Customer Information"}),t(l,{className:"font-semibold text-gray-800 my-0",children:[r.firstname," ",r.lastname]}),e(l,{className:"font-semibold text-gray-800 my-0",children:r.email}),e(m,{className:"border-gray-200 mb-2 mt-2"}),e(l,{className:"text-gray-500 mb-0",children:"Delivery Address"}),t(l,{className:"font-semibold text-gray-800 my-0",children:[(f=i.shippingAddress)===null||f===void 0?void 0:f.firstname," ",(v=i.shippingAddress)===null||v===void 0?void 0:v.lastname]}),t(l,{className:"font-semibold text-gray-800 my-0",children:[(x=i.shippingAddress)===null||x===void 0?void 0:x.addressLineOne," ",((N=i.shippingAddress)===null||N===void 0?void 0:N.doorNumber)&&` / ${(w=i.shippingAddress)===null||w===void 0?void 0:w.doorNumber}`,e("br",{}),(k=i.shippingAddress)===null||k===void 0?void 0:k.city," ",(A=i.shippingAddress)===null||A===void 0?void 0:A.zipCode]}),e(l,{className:"text-gray-500 mb-0",children:"Phone"}),e(l,{className:"font-semibold text-gray-800 my-0",children:(q=i.shippingAddress)===null||q===void 0?void 0:q.phone}),((P=i.shippingAddress)===null||P===void 0?void 0:P.deliveryInstructions)&&t(J,{children:[e(l,{className:"text-gray-500 mb-0",children:"Delivery Instructions"}),e(l,{className:"font-semibold text-gray-800 my-0",children:i.shippingAddress.deliveryInstructions})]})]}),t(s,{className:"w-[40%] p-0 mt-0",align:"right",valign:"top",children:[t(l,{className:"text-gray-500 mb-0 pt-1",children:["Order Date: ",Z]}),t(l,{className:"text-gray-500 mb-0 pt-1",children:["Order ID: ",i.referenceId]}),t(l,{className:"text-gray-500 mb-0 pt-1",children:["Payment: ",(I=i.payment)===null||I===void 0?void 0:I.status]})]})]})}),e(l,{className:"text-gray-500 mb-0",children:"Order Items"}),e(m,{className:"border-gray-200 mb-0"}),e(n,{children:i.items.map((Y,F)=>{var D,j;const c=Y;return e("table",{width:"100%",cellPadding:0,cellSpacing:0,border:0,className:F===i.items.length-1?"mb-0":"mb-4",children:t("tr",{children:[t("td",{valign:"top",children:[t(l,{className:"font-semibold mb-0",children:[((D=c.translations[0])===null||D===void 0?void 0:D.title)||"Product"," (",((j=c.translations[0])===null||j===void 0?void 0:j.subtitle)||"",")"]}),t(l,{className:"text-gray-600 mb-0 mt-0",children:["Quantity: ",c.quantity]})]}),e("td",{align:"right",valign:"top",children:e(l,{className:"font-semibold",children:u(c.unitPrice*c.quantity,a.configuration.defaultCurrency,a.configuration.defaultLocale)})})]})},F)})}),e(m,{className:"border-gray-200 mt-4"}),e(n,{children:t("table",{width:"100%",cellPadding:0,cellSpacing:0,border:0,children:[t("tr",{children:[e("td",{children:e(l,{className:"text-gray-700",children:"Delivery fee"})}),e("td",{align:"right",children:e(l,{className:"text-gray-700",children:u(H,a.configuration.defaultCurrency,a.configuration.defaultLocale)})})]}),T>0&&t("tr",{children:[e("td",{children:e(l,{className:"text-gray-700",children:"Campaign"})}),e("td",{align:"right",children:t(l,{className:"text-gray-700",children:["-",u(T,a.configuration.defaultCurrency,a.configuration.defaultLocale)]})})]})]})}),e(m,{className:"border-gray-200"}),e(n,{className:"mb-6",children:e("table",{width:"100%",cellPadding:0,cellSpacing:0,border:0,children:t("tr",{children:[e("td",{children:e(l,{className:"text-xl font-bold mb-0",children:"Total:"})}),e("td",{align:"right",children:e(l,{className:"text-xl font-bold mb-0",children:u(W,a.configuration.defaultCurrency,a.configuration.defaultLocale)})})]})})})]}),e(n,{className:"text-center bg-gray-50 py-5",children:t("table",{className:"w-full",children:[e("tr",{className:"w-full",children:e("td",{align:"center",children:((C=a.logoFile)===null||C===void 0?void 0:C.url)&&e(d,{alt:`${a.name} logo`,height:"100",src:a.logoFile.url,className:"rounded-lg"})})}),e("tr",{className:"w-full",children:t("td",{align:"center",children:[e(l,{className:"my-[8px] text-[16px] font-semibold text-xl pt-2 text-gray-900",children:a.name}),t(l,{className:"my-[8px] text-[16px] leading-[24px] text-gray-500",children:[(L=a.address)===null||L===void 0?void 0:L.addressLineOne,","," ",(_=a.address)===null||_===void 0?void 0:_.zipCode," ",(M=a.address)===null||M===void 0?void 0:M.city]}),e(l,{className:"mb-0 mt-[4px] text-[16px] leading-[24px] text-gray-500",children:a.phone})]})}),e("tr",{children:e("td",{align:"center",children:t(h,{className:"table-cell h-[44px] w-[56px] align-bottom pt-5",children:[e(s,{className:"pr-[8px]",children:e(o,{href:"https://www.facebook.com/madrasBistro/",children:e(d,{alt:"Facebook",height:"36",src:"https://react.email/static/facebook-logo.png",width:"36"})})}),e(s,{children:e(o,{href:"https://www.instagram.com/madrasbistro/",children:e(d,{alt:"Instagram",height:"36",src:"https://react.email/static/instagram-logo.png",width:"36"})})})]})})})]})})]})})]})},z={user:{id:"VD0OJ52f0mdAnm5YePP6BAW6hdbaCjAJ",name:"Abhishek Shaji",email:"kontakt@abhishek.pl",emailVerified:!0,image:"https://lh3.googleusercontent.com/a/ACg8ocKbkCAMTNvMizjXNxcm1aYtBiWnYpCYmU-7aE2Ft_M_uiHheZ5f=s96-c",createdAt:"2025-03-22T22:54:40.260Z",updatedAt:"2025-03-22T22:54:40.260Z",firstname:"Abhishek",lastname:"Shaji"},order:{id:"cm94wbpbm0000itx1iv9k2mqr",referenceId:"PH6LD6",token:"VAE9TX",expiresAt:"2025-04-07T00:20:09.689Z",items:[{translations:[{locale:"en",title:"Masala Dosa",subtitle:"Spice Level: Medium"},{locale:"pl",title:"null",subtitle:"Spice Level: Medium"}],rawData:{productId:"cm8kudyqq0006ityduhq0yveu",quantity:6,modifierGroups:[{id:"cm8kuonhv0002ji032ji4bzmc",modifiers:[{id:"cm8kudyqq000ditydq25s2n2e",quantity:1}]}]},unitPrice:39,image:{id:"cm8kuee0m0000l703ocs7snfb",url:"https://z3liuyatqnepss3d.public.blob.vercel-storage.com/Masala%20Dosa-b0tr9uWZqmBTPMUx4x0fzqkM6z5eCw.png",mimeType:"image/png",size:1429845,filename:"Masala Dosa.png"},totalPrice:234,quantity:6,productSnapshotId:"cm8kuopty0006ji035n7w5iby"},{translations:[{locale:"en",title:"Masala Dosa",subtitle:"Spice Level: Medium"},{locale:"pl",title:"null",subtitle:"Spice Level: Medium"}],rawData:{productId:"cm8kudyqq0006ityduhq0yveu",quantity:6,modifierGroups:[{id:"cm8kuonhv0002ji032ji4bzmc",modifiers:[{id:"cm8kudyqq000ditydq25s2n2e",quantity:1}]}]},unitPrice:39,image:{id:"cm8kuee0m0000l703ocs7snfb",url:"https://z3liuyatqnepss3d.public.blob.vercel-storage.com/Masala%20Dosa-b0tr9uWZqmBTPMUx4x0fzqkM6z5eCw.png",mimeType:"image/png",size:1429845,filename:"Masala Dosa.png"},totalPrice:234,quantity:6,productSnapshotId:"cm8kuopty0006ji035n7w5iby"}],shippingMethod:{id:"cm8kuqmkd000iitydar4a1poy",title:"Express Delivery",providerName:"Wolt Courier",requireDateOfDelivery:!0,shippingZones:[{id:"cm8kuqmkd000jitydpdvck2th",title:"Zone 1",distanceUpto:7,price:1,minimumOrderAmount:60,eta:"90min"}],createdAt:"2025-03-22T23:40:23.101Z",updatedAt:"2025-03-22T23:40:35.319Z"},acceptedAt:null,dispatchedAt:null,readyForDispatchAt:null,completedAt:null,cancelledAt:null,shippingAddress:{id:"cm94wbpbm0007itx1akuqh77n",firstname:"Klaudia",lastname:"Smoter",phone:"+48570135862",addressLineOne:"Stanis\u0142awa Lema 28",doorNumber:"54",addressLineTwo:null,zipCode:"31-571",city:"Krak\xF3w",country:"PL",placeId:"ChIJrQfdh9VaFkcRIvg8O2PqnWM",deliveryInstructions:"4th floor - Maho"},fulfilmentMethod:"delivery",currency:"PLN",payment:{id:"cm94wbpbm0008itx1thsnj7ui",method:"blik",provider:"stripe",status:"succeeded",shipping:1,subtotal:234,total:235,discount:0,currency:"PLN"},status:"pending"},organization:{id:"cm8kthfdq0001lg03b59mdy7b",name:"Madras Bistro",phone:"+48570135862",email:"contact@madrasbistro.pl",createdAt:"2025-03-22T23:05:14.271Z",legalEntityId:null,address:{id:"cm8kthfdr0002lg0350ijialt",firstname:null,lastname:null,phone:null,addressLineOne:"Plac Bohater\xF3w Getta 2",doorNumber:null,addressLineTwo:"3",zipCode:"33-332",city:"Krak\xF3w",country:"PL",placeId:"ChIJf-nsRkRbFkcR21gtObFSSSA",deliveryInstructions:null},configuration:{id:"cm8kthfdr0003lg03ghgs262n",hostname:"null",countriesShipping:["us"],stripeAccountId:"null",enableHostCheckout:!1,enableHostTracking:!1,isAcceptingOrders:!1,defaultLocale:"en",supportedLocales:["en","pl"],defaultCurrency:"PLN",createdAt:"2025-03-22T23:05:14.271Z"},logo:"https://z3liuyatqnepss3d.public.blob.vercel-storage.com/logo-zeJymFRMFCIKPlvjxYm2af3SAWvBOj.png",logoFile:{id:"cm8ktmu890005lg0356gwclfk",url:"https://z3liuyatqnepss3d.public.blob.vercel-storage.com/logo-zeJymFRMFCIKPlvjxYm2af3SAWvBOj.png",mimeType:"image/png",size:1652289,filename:"logo.png"}}};S.PreviewProps=z;export default S;export{S as OrderNotificationEmail};
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createApiRouter } from "../../core/hono/hono";
|
|
3
|
-
import { orderRoute } from "./order.route";
|
|
4
|
-
import { OrderService } from "./order.service";
|
|
5
|
-
export const buildOrderHandler = (prisma, options) => {
|
|
6
|
-
const app = createApiRouter();
|
|
7
|
-
app.openapi(orderRoute.createOrder, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
-
const auth = c.get("auth");
|
|
9
|
-
const params = c.req.valid("param");
|
|
10
|
-
const body = c.req.valid("json");
|
|
11
|
-
const user = yield auth.getCurrentUser();
|
|
12
|
-
const service = new OrderService(prisma, options);
|
|
13
|
-
const { order, redirectUrl } = yield service.createOrder(params.organizationId, user, body);
|
|
14
|
-
return c.json({
|
|
15
|
-
order,
|
|
16
|
-
redirectUrl,
|
|
17
|
-
}, 201);
|
|
18
|
-
}));
|
|
19
|
-
app.openapi(orderRoute.getOrder, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
const auth = c.get("auth");
|
|
21
|
-
const params = c.req.valid("param");
|
|
22
|
-
const user = yield auth.getCurrentUser();
|
|
23
|
-
const service = new OrderService(prisma, options);
|
|
24
|
-
const order = yield service.getOrder(user, params.organizationId, params.id);
|
|
25
|
-
return c.json(order, 200);
|
|
26
|
-
}));
|
|
27
|
-
app.openapi(orderRoute.getOrders, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
const auth = c.get("auth");
|
|
29
|
-
const params = c.req.valid("param");
|
|
30
|
-
const query = c.req.valid("query");
|
|
31
|
-
yield auth.isGranted("read");
|
|
32
|
-
const service = new OrderService(prisma, options);
|
|
33
|
-
const result = yield service.getOrders(params.organizationId, query);
|
|
34
|
-
return c.json(result, 200);
|
|
35
|
-
}));
|
|
36
|
-
app.openapi(orderRoute.updateStatus, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
const auth = c.get("auth");
|
|
38
|
-
const params = c.req.valid("param");
|
|
39
|
-
yield auth.isGranted("update");
|
|
40
|
-
const service = new OrderService(prisma, options);
|
|
41
|
-
const order = yield service.updateStatus(params.organizationId, params.id, params.operation);
|
|
42
|
-
return c.json(order, 200);
|
|
43
|
-
}));
|
|
44
|
-
app.openapi(orderRoute.deleteOrder, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
const auth = c.get("auth");
|
|
46
|
-
const params = c.req.valid("param");
|
|
47
|
-
const user = yield auth.isGranted("delete");
|
|
48
|
-
const service = new OrderService(prisma, options);
|
|
49
|
-
yield service.deleteOrder(params.organizationId, params.id, user.id);
|
|
50
|
-
return c.body(null, 204);
|
|
51
|
-
}));
|
|
52
|
-
return app;
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=order.handler.js.map
|
|
1
|
+
import{__awaiter as u}from"tslib";import{createApiRouter as g}from"../../core/hono/hono";import{orderRoute as c}from"./order.route";import{OrderService as v}from"./order.service";export const buildOrderHandler=(i,a)=>{const n=g();return n.openapi(c.createOrder,e=>u(void 0,void 0,void 0,function*(){const t=e.get("auth"),r=e.req.valid("param"),o=e.req.valid("json"),d=yield t.getCurrentUser(),s=new v(i,a),{order:l,redirectUrl:p}=yield s.createOrder(r.organizationId,d,o);return e.json({order:l,redirectUrl:p},201)})),n.openapi(c.getOrder,e=>u(void 0,void 0,void 0,function*(){const t=e.get("auth"),r=e.req.valid("param"),o=yield t.getCurrentUser(),s=yield new v(i,a).getOrder(o,r.organizationId,r.id);return e.json(s,200)})),n.openapi(c.getOrders,e=>u(void 0,void 0,void 0,function*(){const t=e.get("auth"),r=e.req.valid("param"),o=e.req.valid("query");yield t.isGranted("read");const s=yield new v(i,a).getOrders(r.organizationId,o);return e.json(s,200)})),n.openapi(c.updateStatus,e=>u(void 0,void 0,void 0,function*(){const t=e.get("auth"),r=e.req.valid("param");yield t.isGranted("update");const d=yield new v(i,a).updateStatus(r.organizationId,r.id,r.operation);return e.json(d,200)})),n.openapi(c.deleteOrder,e=>u(void 0,void 0,void 0,function*(){const t=e.get("auth"),r=e.req.valid("param"),o=yield t.isGranted("delete");return yield new v(i,a).deleteOrder(r.organizationId,r.id,o.id),e.body(null,204)})),n};
|
|
@@ -1,111 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createApiRoute } from "../../core/hono/hono";
|
|
3
|
-
import { CreateOrderSchema, ErrorSchema, HeaderSchema, OrderSchema, OrderStatusSchema, OrganizationParams, OrganizationWithIdParams, PaginationMetaSchema, PaginationQuerySchema, } from "../../schemas";
|
|
4
|
-
const getOrdersRoute = createApiRoute({
|
|
5
|
-
description: "Fetches paginated list of orders",
|
|
6
|
-
headers: HeaderSchema,
|
|
7
|
-
method: "GET",
|
|
8
|
-
operationId: "getOrders",
|
|
9
|
-
path: "/:organizationId/orders",
|
|
10
|
-
pathParams: OrganizationParams,
|
|
11
|
-
query: PaginationQuerySchema,
|
|
12
|
-
responses: {
|
|
13
|
-
200: z.object({
|
|
14
|
-
list: z.array(OrderSchema),
|
|
15
|
-
meta: PaginationMetaSchema,
|
|
16
|
-
}),
|
|
17
|
-
400: ErrorSchema,
|
|
18
|
-
401: ErrorSchema,
|
|
19
|
-
},
|
|
20
|
-
summary: "Get Orders",
|
|
21
|
-
tags: ["Order"],
|
|
22
|
-
});
|
|
23
|
-
const createOrderRoute = createApiRoute({
|
|
24
|
-
body: CreateOrderSchema,
|
|
25
|
-
description: "Creates a new order",
|
|
26
|
-
headers: HeaderSchema,
|
|
27
|
-
method: "POST",
|
|
28
|
-
operationId: "createOrder",
|
|
29
|
-
path: "/:organizationId/orders",
|
|
30
|
-
pathParams: z.object({
|
|
31
|
-
organizationId: z
|
|
32
|
-
.string()
|
|
33
|
-
.cuid()
|
|
34
|
-
.min(1)
|
|
35
|
-
.openapi({
|
|
36
|
-
description: "The organization ID",
|
|
37
|
-
example: "ckel0e8qw00004n5p5w6fznym",
|
|
38
|
-
param: {
|
|
39
|
-
in: "path",
|
|
40
|
-
name: "organizationId",
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
}),
|
|
44
|
-
responses: {
|
|
45
|
-
201: z.object({
|
|
46
|
-
order: OrderSchema,
|
|
47
|
-
redirectUrl: z.string().url().optional(),
|
|
48
|
-
}),
|
|
49
|
-
400: ErrorSchema,
|
|
50
|
-
401: ErrorSchema,
|
|
51
|
-
404: ErrorSchema,
|
|
52
|
-
},
|
|
53
|
-
summary: "Create Order",
|
|
54
|
-
tags: ["Order"],
|
|
55
|
-
});
|
|
56
|
-
const getOrderRoute = createApiRoute({
|
|
57
|
-
headers: HeaderSchema,
|
|
58
|
-
method: "GET",
|
|
59
|
-
operationId: "getOrder",
|
|
60
|
-
path: "/:organizationId/orders/:id",
|
|
61
|
-
pathParams: OrganizationWithIdParams,
|
|
62
|
-
responses: {
|
|
63
|
-
200: OrderSchema,
|
|
64
|
-
401: ErrorSchema,
|
|
65
|
-
404: ErrorSchema,
|
|
66
|
-
},
|
|
67
|
-
summary: "Get Order",
|
|
68
|
-
tags: ["Order"],
|
|
69
|
-
});
|
|
70
|
-
const updateStatusRoute = createApiRoute({
|
|
71
|
-
description: "Changes the status of an existing order based on the operation",
|
|
72
|
-
headers: HeaderSchema,
|
|
73
|
-
method: "POST",
|
|
74
|
-
operationId: "updateOrderStatus",
|
|
75
|
-
path: "/:organizationId/orders/:id/status/:operation",
|
|
76
|
-
pathParams: OrganizationWithIdParams.extend({
|
|
77
|
-
operation: OrderStatusSchema,
|
|
78
|
-
}),
|
|
79
|
-
responses: {
|
|
80
|
-
200: OrderSchema,
|
|
81
|
-
400: ErrorSchema,
|
|
82
|
-
401: ErrorSchema,
|
|
83
|
-
404: ErrorSchema,
|
|
84
|
-
},
|
|
85
|
-
summary: "Change Order Status",
|
|
86
|
-
tags: ["Order"],
|
|
87
|
-
});
|
|
88
|
-
const deleteOrderRoute = createApiRoute({
|
|
89
|
-
description: "Soft deletes order",
|
|
90
|
-
headers: HeaderSchema,
|
|
91
|
-
method: "DELETE",
|
|
92
|
-
operationId: "deleteOrder",
|
|
93
|
-
path: "/:organizationId/orders/:id",
|
|
94
|
-
pathParams: OrganizationWithIdParams,
|
|
95
|
-
responses: {
|
|
96
|
-
204: null,
|
|
97
|
-
400: ErrorSchema,
|
|
98
|
-
401: ErrorSchema,
|
|
99
|
-
404: ErrorSchema,
|
|
100
|
-
},
|
|
101
|
-
summary: "Delete Order",
|
|
102
|
-
tags: ["Order"],
|
|
103
|
-
});
|
|
104
|
-
export const orderRoute = {
|
|
105
|
-
getOrders: getOrdersRoute,
|
|
106
|
-
createOrder: createOrderRoute,
|
|
107
|
-
getOrder: getOrderRoute,
|
|
108
|
-
updateStatus: updateStatusRoute,
|
|
109
|
-
deleteOrder: deleteOrderRoute,
|
|
110
|
-
};
|
|
111
|
-
//# sourceMappingURL=order.route.js.map
|
|
1
|
+
import{z as r}from"@hono/zod-openapi";import{createApiRoute as t}from"../../core/hono/hono";import{CreateOrderSchema as s,ErrorSchema as e,HeaderSchema as a,OrderSchema as o,OrderStatusSchema as n,OrganizationParams as i,OrganizationWithIdParams as d,PaginationMetaSchema as p,PaginationQuerySchema as m}from"../../schemas";const h=t({description:"Fetches paginated list of orders",headers:a,method:"GET",operationId:"getOrders",path:"/:organizationId/orders",pathParams:i,query:m,responses:{200:r.object({list:r.array(o),meta:p}),400:e,401:e},summary:"Get Orders",tags:["Order"]}),O=t({body:s,description:"Creates a new order",headers:a,method:"POST",operationId:"createOrder",path:"/:organizationId/orders",pathParams:r.object({organizationId:r.string().cuid().min(1).openapi({description:"The organization ID",example:"ckel0e8qw00004n5p5w6fznym",param:{in:"path",name:"organizationId"}})}),responses:{201:r.object({order:o,redirectUrl:r.string().url().optional()}),400:e,401:e,404:e},summary:"Create Order",tags:["Order"]}),c=t({headers:a,method:"GET",operationId:"getOrder",path:"/:organizationId/orders/:id",pathParams:d,responses:{200:o,401:e,404:e},summary:"Get Order",tags:["Order"]}),g=t({description:"Changes the status of an existing order based on the operation",headers:a,method:"POST",operationId:"updateOrderStatus",path:"/:organizationId/orders/:id/status/:operation",pathParams:d.extend({operation:n}),responses:{200:o,400:e,401:e,404:e},summary:"Change Order Status",tags:["Order"]}),u=t({description:"Soft deletes order",headers:a,method:"DELETE",operationId:"deleteOrder",path:"/:organizationId/orders/:id",pathParams:d,responses:{204:null,400:e,401:e,404:e},summary:"Delete Order",tags:["Order"]});export const orderRoute={getOrders:h,createOrder:O,getOrder:c,updateStatus:g,deleteOrder:u};
|
|
@@ -1,158 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AddressSchema } from "../../schemas/address.schema";
|
|
3
|
-
import { currency } from "../../schemas/currency.schema";
|
|
4
|
-
import { locale } from "../../schemas/locales.schema";
|
|
5
|
-
import { CartItemSchema, CartSchema } from "../cart/cart.schema";
|
|
6
|
-
import { FileSchema } from "../file/file.schema";
|
|
7
|
-
import { PaymentMethodSchema, PaymentProviderSchema, PaymentSchema, } from "../payment/payment.schema";
|
|
8
|
-
import { ShippingMethodSchema } from "../shipping-method/shipping-method.schema";
|
|
9
|
-
import { fulfilmentMethod } from "./fulfilment.schema";
|
|
10
|
-
export const OrderStatusSchema = z
|
|
11
|
-
.enum([
|
|
12
|
-
"draft",
|
|
13
|
-
"pending",
|
|
14
|
-
"accepted",
|
|
15
|
-
"ready-for-dispatch",
|
|
16
|
-
"dispatched",
|
|
17
|
-
"completed",
|
|
18
|
-
"cancelled",
|
|
19
|
-
])
|
|
20
|
-
.openapi({
|
|
21
|
-
description: "Status of the order",
|
|
22
|
-
example: "accepted",
|
|
23
|
-
});
|
|
24
|
-
export const OrderItemSchema = z
|
|
25
|
-
.object({
|
|
26
|
-
translations: z
|
|
27
|
-
.array(z.object({
|
|
28
|
-
locale: locale.openapi({
|
|
29
|
-
description: "Locale of the translation",
|
|
30
|
-
example: "en-US",
|
|
31
|
-
}),
|
|
32
|
-
title: z.string().openapi({
|
|
33
|
-
description: "Title of the ordered product",
|
|
34
|
-
example: "Premium Watch",
|
|
35
|
-
}),
|
|
36
|
-
subtitle: z.string().openapi({
|
|
37
|
-
description: "Additional details about the ordered item, including modifiers",
|
|
38
|
-
example: "Color: Silver, Size: Large",
|
|
39
|
-
}),
|
|
40
|
-
}))
|
|
41
|
-
.openapi({
|
|
42
|
-
description: "Translations for the order item",
|
|
43
|
-
}),
|
|
44
|
-
rawData: CartItemSchema,
|
|
45
|
-
unitPrice: z.number().min(0).openapi({
|
|
46
|
-
description: "Price per unit of the item",
|
|
47
|
-
example: 299.99,
|
|
48
|
-
}),
|
|
49
|
-
image: FileSchema.nullable().optional(),
|
|
50
|
-
totalPrice: z.number().min(0).openapi({
|
|
51
|
-
description: "Total price for this item (unitPrice × quantity)",
|
|
52
|
-
example: 599.98,
|
|
53
|
-
}),
|
|
54
|
-
quantity: z.number().min(1).openapi({
|
|
55
|
-
description: "Number of units ordered",
|
|
56
|
-
example: 2,
|
|
57
|
-
}),
|
|
58
|
-
productSnapshotId: z.string().cuid(),
|
|
59
|
-
})
|
|
60
|
-
.openapi("OrderItem");
|
|
61
|
-
export const OrderSchema = z
|
|
62
|
-
.object({
|
|
63
|
-
id: z.string().openapi({
|
|
64
|
-
description: "Unique identifier for the order",
|
|
65
|
-
example: "clj1234567890abcdef",
|
|
66
|
-
}),
|
|
67
|
-
referenceId: z.string().openapi({
|
|
68
|
-
description: "External reference ID for the order",
|
|
69
|
-
example: "ORD-12345",
|
|
70
|
-
}),
|
|
71
|
-
status: OrderStatusSchema.optional(),
|
|
72
|
-
token: z.string().openapi({
|
|
73
|
-
description: "Security token for order verification",
|
|
74
|
-
example: "a1b2c3d4e5f6g7h8i9j0",
|
|
75
|
-
}),
|
|
76
|
-
expiresAt: z.date().openapi({
|
|
77
|
-
description: "Expiration date for the order",
|
|
78
|
-
example: "2023-12-31T23:59:59Z",
|
|
79
|
-
}),
|
|
80
|
-
items: z.array(OrderItemSchema).min(1).openapi({
|
|
81
|
-
description: "Array of items in the order",
|
|
82
|
-
}),
|
|
83
|
-
shippingMethod: ShippingMethodSchema.nullable().openapi({
|
|
84
|
-
description: "Shipping method selected for the order",
|
|
85
|
-
}),
|
|
86
|
-
acceptedAt: z.date().nullable().optional().openapi({
|
|
87
|
-
description: "Date when the order was accepted",
|
|
88
|
-
example: "2023-06-15T14:30:00Z",
|
|
89
|
-
}),
|
|
90
|
-
dispatchedAt: z.date().nullable().optional().openapi({
|
|
91
|
-
description: "Date when the order was dispatched",
|
|
92
|
-
example: "2023-06-16T09:15:00Z",
|
|
93
|
-
}),
|
|
94
|
-
readyForDispatchAt: z.date().nullable().optional().openapi({
|
|
95
|
-
description: "Date when the order was ready for dispatch",
|
|
96
|
-
example: "2023-06-16T09:15:00Z",
|
|
97
|
-
}),
|
|
98
|
-
createdAt: z.date().openapi({
|
|
99
|
-
description: "Date when the order was created",
|
|
100
|
-
example: "2023-06-15T14:30:00Z",
|
|
101
|
-
}),
|
|
102
|
-
completedAt: z.date().nullable().optional().openapi({
|
|
103
|
-
description: "Date when the order was completed",
|
|
104
|
-
example: "2023-06-18T11:45:00Z",
|
|
105
|
-
}),
|
|
106
|
-
cancelledAt: z.date().nullable().optional().openapi({
|
|
107
|
-
description: "Date when the order was cancelled",
|
|
108
|
-
example: "2023-06-14T16:20:00Z",
|
|
109
|
-
}),
|
|
110
|
-
shippingAddress: AddressSchema.nullable().optional(),
|
|
111
|
-
fulfilmentMethod: fulfilmentMethod.openapi({
|
|
112
|
-
description: "Method of order fulfilment (pickup or delivery)",
|
|
113
|
-
example: "delivery",
|
|
114
|
-
}),
|
|
115
|
-
currency: currency.openapi({
|
|
116
|
-
description: "Currency used for the order",
|
|
117
|
-
example: "USD",
|
|
118
|
-
}),
|
|
119
|
-
payment: PaymentSchema,
|
|
120
|
-
})
|
|
121
|
-
.transform((order) => {
|
|
122
|
-
let status;
|
|
123
|
-
if (order.cancelledAt) {
|
|
124
|
-
status = "cancelled";
|
|
125
|
-
}
|
|
126
|
-
else if (order.completedAt) {
|
|
127
|
-
status = "completed";
|
|
128
|
-
}
|
|
129
|
-
else if (order.dispatchedAt) {
|
|
130
|
-
status = "dispatched";
|
|
131
|
-
}
|
|
132
|
-
else if (order.readyForDispatchAt) {
|
|
133
|
-
status = "ready-for-dispatch";
|
|
134
|
-
}
|
|
135
|
-
else if (order.acceptedAt) {
|
|
136
|
-
status = "accepted";
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
status = "pending";
|
|
140
|
-
}
|
|
141
|
-
return Object.assign(Object.assign({}, order), { status });
|
|
142
|
-
})
|
|
143
|
-
.openapi("Order");
|
|
144
|
-
export const CreateOrderSchema = CartSchema.extend({
|
|
145
|
-
fulfilmentMethod: fulfilmentMethod.default("delivery"),
|
|
146
|
-
payment: z.object({
|
|
147
|
-
provider: PaymentProviderSchema,
|
|
148
|
-
method: PaymentMethodSchema,
|
|
149
|
-
}),
|
|
150
|
-
checkoutBaseUrl: z.string().url(),
|
|
151
|
-
})
|
|
152
|
-
.refine((data) => data.fulfilmentMethod !== "delivery" ||
|
|
153
|
-
data.shippingMethodId !== undefined, {
|
|
154
|
-
message: "shippingMethodId is required when fulfilmentMethod is 'delivery'",
|
|
155
|
-
path: ["shippingMethodId"],
|
|
156
|
-
})
|
|
157
|
-
.openapi("CreateOrder");
|
|
158
|
-
//# sourceMappingURL=order.schema.js.map
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";import{AddressSchema as a}from"../../schemas/address.schema";import{currency as o}from"../../schemas/currency.schema";import{locale as p}from"../../schemas/locales.schema";import{CartItemSchema as n,CartSchema as d}from"../cart/cart.schema";import{FileSchema as l}from"../file/file.schema";import{PaymentMethodSchema as c,PaymentProviderSchema as s,PaymentSchema as m}from"../payment/payment.schema";import{ShippingMethodSchema as h}from"../shipping-method/shipping-method.schema";import{fulfilmentMethod as r}from"./fulfilment.schema";export const OrderStatusSchema=e.enum(["draft","pending","accepted","ready-for-dispatch","dispatched","completed","cancelled"]).openapi({description:"Status of the order",example:"accepted"}),OrderItemSchema=e.object({translations:e.array(e.object({locale:p.openapi({description:"Locale of the translation",example:"en-US"}),title:e.string().openapi({description:"Title of the ordered product",example:"Premium Watch"}),subtitle:e.string().openapi({description:"Additional details about the ordered item, including modifiers",example:"Color: Silver, Size: Large"})})).openapi({description:"Translations for the order item"}),rawData:n,unitPrice:e.number().min(0).openapi({description:"Price per unit of the item",example:299.99}),image:l.nullable().optional(),totalPrice:e.number().min(0).openapi({description:"Total price for this item (unitPrice \xD7 quantity)",example:599.98}),quantity:e.number().min(1).openapi({description:"Number of units ordered",example:2}),productSnapshotId:e.string().cuid()}).openapi("OrderItem"),OrderSchema=e.object({id:e.string().openapi({description:"Unique identifier for the order",example:"clj1234567890abcdef"}),referenceId:e.string().openapi({description:"External reference ID for the order",example:"ORD-12345"}),status:OrderStatusSchema.optional(),token:e.string().openapi({description:"Security token for order verification",example:"a1b2c3d4e5f6g7h8i9j0"}),expiresAt:e.date().openapi({description:"Expiration date for the order",example:"2023-12-31T23:59:59Z"}),items:e.array(OrderItemSchema).min(1).openapi({description:"Array of items in the order"}),shippingMethod:h.nullable().openapi({description:"Shipping method selected for the order"}),acceptedAt:e.date().nullable().optional().openapi({description:"Date when the order was accepted",example:"2023-06-15T14:30:00Z"}),dispatchedAt:e.date().nullable().optional().openapi({description:"Date when the order was dispatched",example:"2023-06-16T09:15:00Z"}),readyForDispatchAt:e.date().nullable().optional().openapi({description:"Date when the order was ready for dispatch",example:"2023-06-16T09:15:00Z"}),createdAt:e.date().openapi({description:"Date when the order was created",example:"2023-06-15T14:30:00Z"}),completedAt:e.date().nullable().optional().openapi({description:"Date when the order was completed",example:"2023-06-18T11:45:00Z"}),cancelledAt:e.date().nullable().optional().openapi({description:"Date when the order was cancelled",example:"2023-06-14T16:20:00Z"}),shippingAddress:a.nullable().optional(),fulfilmentMethod:r.openapi({description:"Method of order fulfilment (pickup or delivery)",example:"delivery"}),currency:o.openapi({description:"Currency used for the order",example:"USD"}),payment:m}).transform(t=>{let i;return t.cancelledAt?i="cancelled":t.completedAt?i="completed":t.dispatchedAt?i="dispatched":t.readyForDispatchAt?i="ready-for-dispatch":t.acceptedAt?i="accepted":i="pending",Object.assign(Object.assign({},t),{status:i})}).openapi("Order"),CreateOrderSchema=d.extend({fulfilmentMethod:r.default("delivery"),payment:e.object({provider:s,method:c}),checkoutBaseUrl:e.string().url()}).refine(t=>t.fulfilmentMethod!=="delivery"||t.shippingMethodId!==void 0,{message:"shippingMethodId is required when fulfilmentMethod is 'delivery'",path:["shippingMethodId"]}).openapi("CreateOrder");
|