@shophost/rest-api 2.0.34 → 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.
Files changed (148) hide show
  1. package/package.json +1 -1
  2. package/scripts/minify-dist.mjs +45 -0
  3. package/src/app.js +1 -53
  4. package/src/core/auth/auth.schema.js +1 -41
  5. package/src/core/auth/auth.util.js +1 -44
  6. package/src/core/auth/better-auth.lib.js +1 -100
  7. package/src/core/auth/generate-password-hash.util.js +1 -30
  8. package/src/core/auth/headers.schema.js +1 -22
  9. package/src/core/auth/user.schema.js +1 -30
  10. package/src/core/db/__generated__/client/browser.js +1 -18
  11. package/src/core/db/__generated__/client/client.js +1 -35
  12. package/src/core/db/__generated__/client/commonInputTypes.js +1 -11
  13. package/src/core/db/__generated__/client/enums.js +1 -200
  14. package/src/core/db/__generated__/client/internal/class.js +769 -55
  15. package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -541
  16. package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -512
  17. package/src/core/db/__generated__/client/models/Account.js +1 -2
  18. package/src/core/db/__generated__/client/models/Address.js +1 -2
  19. package/src/core/db/__generated__/client/models/Campaign.js +1 -2
  20. package/src/core/db/__generated__/client/models/ClosingTimes.js +1 -2
  21. package/src/core/db/__generated__/client/models/File.js +1 -2
  22. package/src/core/db/__generated__/client/models/Invitation.js +1 -2
  23. package/src/core/db/__generated__/client/models/LegalEntity.js +1 -2
  24. package/src/core/db/__generated__/client/models/Manufacturer.js +1 -2
  25. package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +1 -2
  26. package/src/core/db/__generated__/client/models/Member.js +1 -2
  27. package/src/core/db/__generated__/client/models/Modifier.js +1 -2
  28. package/src/core/db/__generated__/client/models/ModifierGroup.js +1 -2
  29. package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +1 -2
  30. package/src/core/db/__generated__/client/models/OpeningTimes.js +1 -2
  31. package/src/core/db/__generated__/client/models/Order.js +1 -2
  32. package/src/core/db/__generated__/client/models/OrderItem.js +1 -2
  33. package/src/core/db/__generated__/client/models/OrderItemTranslation.js +1 -2
  34. package/src/core/db/__generated__/client/models/Organization.js +1 -2
  35. package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +1 -2
  36. package/src/core/db/__generated__/client/models/Payment.js +1 -2
  37. package/src/core/db/__generated__/client/models/PaymentSession.js +1 -2
  38. package/src/core/db/__generated__/client/models/Product.js +1 -2
  39. package/src/core/db/__generated__/client/models/ProductCategory.js +1 -2
  40. package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +1 -2
  41. package/src/core/db/__generated__/client/models/ProductSnapshot.js +1 -2
  42. package/src/core/db/__generated__/client/models/ProductTranslation.js +1 -2
  43. package/src/core/db/__generated__/client/models/Reservation.js +1 -2
  44. package/src/core/db/__generated__/client/models/Session.js +1 -2
  45. package/src/core/db/__generated__/client/models/ShippingMethod.js +1 -2
  46. package/src/core/db/__generated__/client/models/ShippingZone.js +1 -2
  47. package/src/core/db/__generated__/client/models/User.js +1 -2
  48. package/src/core/db/__generated__/client/models/Verification.js +1 -2
  49. package/src/core/db/__generated__/client/models.js +1 -2
  50. package/src/core/db/index.js +1 -2
  51. package/src/core/exceptions/http-exception.js +1 -9
  52. package/src/core/hono/hono.js +1 -123
  53. package/src/core/lib/prisma.js +1 -11
  54. package/src/core/logging/pino.js +1 -5
  55. package/src/core/notifications/email.service.js +1 -116
  56. package/src/core/openapi/openapi.lib.js +1 -26
  57. package/src/core/types/google-maps.types.js +1 -2
  58. package/src/core/utils/currency.util.js +1 -11
  59. package/src/core/utils/env.util.js +1 -8
  60. package/src/core/utils/object.util.js +1 -39
  61. package/src/core/utils/translations.util.js +0 -1
  62. package/src/core/utils/zod.util.js +1 -85
  63. package/src/db.js +1 -3
  64. package/src/features/access/access.handler.js +1 -91
  65. package/src/features/access/access.route.js +1 -220
  66. package/src/features/access/access.schema.js +1 -108
  67. package/src/features/access/access.service.js +1 -294
  68. package/src/features/cart/cart.handler.js +1 -17
  69. package/src/features/cart/cart.route.js +1 -32
  70. package/src/features/cart/cart.schema.js +1 -39
  71. package/src/features/cart/cart.service.js +1 -97
  72. package/src/features/cart/cart.util.js +1 -76
  73. package/src/features/file/file.handler.js +1 -23
  74. package/src/features/file/file.route.js +1 -34
  75. package/src/features/file/file.schema.js +1 -77
  76. package/src/features/file/file.service.js +1 -66
  77. package/src/features/health/health.handler.js +1 -10
  78. package/src/features/health/health.route.js +1 -25
  79. package/src/features/index.js +1 -16
  80. package/src/features/location/location.handler.js +1 -25
  81. package/src/features/location/location.route.js +1 -56
  82. package/src/features/location/location.schema.js +1 -50
  83. package/src/features/location/location.service.js +1 -141
  84. package/src/features/manufacturer/manufacturer.handler.js +1 -53
  85. package/src/features/manufacturer/manufacturer.route.js +1 -97
  86. package/src/features/manufacturer/manufacturer.schema.js +1 -125
  87. package/src/features/manufacturer/manufacturer.service.js +1 -190
  88. package/src/features/order/emails/order-confirmation.email.js +1 -229
  89. package/src/features/order/emails/order-notification.email.js +1 -229
  90. package/src/features/order/fulfilment.schema.js +1 -3
  91. package/src/features/order/order.handler.js +1 -54
  92. package/src/features/order/order.route.js +1 -111
  93. package/src/features/order/order.schema.js +1 -158
  94. package/src/features/order/order.service.js +1 -306
  95. package/src/features/order/recipient.schema.js +1 -38
  96. package/src/features/organization/legal-entity.schema.js +1 -83
  97. package/src/features/organization/organization-configuration.schema.js +1 -115
  98. package/src/features/organization/organization.handler.js +1 -48
  99. package/src/features/organization/organization.route.js +1 -84
  100. package/src/features/organization/organization.schema.js +1 -64
  101. package/src/features/organization/organization.service.js +1 -334
  102. package/src/features/payment/payment.handler.js +1 -16
  103. package/src/features/payment/payment.route.js +1 -22
  104. package/src/features/payment/payment.schema.js +1 -46
  105. package/src/features/payment/payment.service.js +1 -100
  106. package/src/features/payment/stripe.service.js +1 -164
  107. package/src/features/product/product-modifier.schema.js +1 -84
  108. package/src/features/product/product.handler.js +1 -87
  109. package/src/features/product/product.route.js +1 -179
  110. package/src/features/product/product.schema.js +1 -143
  111. package/src/features/product/product.service.js +1 -440
  112. package/src/features/product-category/product-category.handler.js +1 -59
  113. package/src/features/product-category/product-category.route.js +1 -139
  114. package/src/features/product-category/product-category.schema.js +1 -86
  115. package/src/features/product-category/product-category.service.js +1 -220
  116. package/src/features/reservation/emails/reservation-cancellation.email.js +1 -82
  117. package/src/features/reservation/emails/reservation-confirmation.email.js +1 -82
  118. package/src/features/reservation/emails/reservation-notification.email.js +1 -93
  119. package/src/features/reservation/reservation.handler.js +1 -65
  120. package/src/features/reservation/reservation.route.js +1 -167
  121. package/src/features/reservation/reservation.schema.js +1 -51
  122. package/src/features/reservation/reservation.service.js +1 -231
  123. package/src/features/shipping/shipping.handler.js +1 -32
  124. package/src/features/shipping/shipping.route.js +1 -51
  125. package/src/features/shipping/shipping.service.js +1 -96
  126. package/src/features/shipping-method/shipping-method.handler.js +1 -60
  127. package/src/features/shipping-method/shipping-method.route.js +1 -144
  128. package/src/features/shipping-method/shipping-method.schema.js +1 -48
  129. package/src/features/shipping-method/shipping-method.service.js +1 -229
  130. package/src/features/shipping-method/shipping-zone.schema.js +1 -31
  131. package/src/features/webhook/webhook.handler.js +1 -50
  132. package/src/features/webhook/webhook.route.js +1 -33
  133. package/src/index.js +1 -6
  134. package/src/integrations/next.js +1 -82
  135. package/src/schemas/address.schema.js +1 -112
  136. package/src/schemas/currency.schema.js +1 -118
  137. package/src/schemas/error.schema.js +1 -12
  138. package/src/schemas/index.js +1 -29
  139. package/src/schemas/locales.schema.js +1 -238
  140. package/src/schemas/number.schema.js +1 -29
  141. package/src/schemas/pagination.schema.js +1 -54
  142. package/src/schemas/params.schema.js +1 -20
  143. package/src/schemas/queries.schema.js +1 -6
  144. package/src/test/global-setup.js +1 -37
  145. package/src/test/integration/api-fixtures.js +1 -160
  146. package/src/test/integration/seed.js +1 -368
  147. package/src/test/integration/test-helpers.js +1 -154
  148. package/src/test/setup-test-env.js +1 -7
@@ -1,190 +1 @@
1
- import { __awaiter } from "tslib";
2
- import { z } from "@hono/zod-openapi";
3
- import { HttpException } from "../../core/exceptions/http-exception";
4
- import { flattenTranslationData } from "../../core/utils/zod.util";
5
- import { LocalizedManufacturerSchema, ManufacturerSchema, PaginationMetaSchema, } from "../../schemas";
6
- class ManufacturerService {
7
- constructor(prisma) {
8
- this.prisma = prisma;
9
- }
10
- /**
11
- * Find a manufacturer by ID and organization ID
12
- * @throws HttpException with 404 status if manufacturer is not found
13
- */
14
- findManufacturer(id, organizationId, options) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const manufacturer = yield this.prisma.manufacturer.findUnique({
17
- where: {
18
- id,
19
- organizationId,
20
- deletedAt: null,
21
- },
22
- include: options === null || options === void 0 ? void 0 : options.include,
23
- });
24
- if (!manufacturer) {
25
- throw new HttpException(404, "Manufacturer not found");
26
- }
27
- return manufacturer;
28
- });
29
- }
30
- /**
31
- * Create a new manufacturer
32
- */
33
- createManufacturer(organizationId, userId, body) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- // Create new manufacturer
36
- const manufacturer = yield this.prisma.manufacturer.create({
37
- data: {
38
- name: body.name,
39
- organizationId,
40
- createdBy: userId,
41
- logoId: body.logoId,
42
- translations: {
43
- create: body.translations,
44
- },
45
- },
46
- include: {
47
- translations: true,
48
- logo: true,
49
- },
50
- });
51
- return ManufacturerSchema.parse(manufacturer);
52
- });
53
- }
54
- /**
55
- * Get a manufacturer by ID
56
- */
57
- getManufacturer(organizationId, id, query) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- // Extract locale from query parameter
60
- const { locale } = query;
61
- const manufacturer = yield this.findManufacturer(id, organizationId, {
62
- include: {
63
- logo: true,
64
- translations: locale
65
- ? {
66
- where: { locale },
67
- }
68
- : true,
69
- },
70
- });
71
- if (!locale) {
72
- return ManufacturerSchema.parse(manufacturer);
73
- }
74
- // If locale is provided, flatten the translations data and use LocalizedManufacturerSchema
75
- return LocalizedManufacturerSchema.parse(flattenTranslationData(manufacturer));
76
- });
77
- }
78
- /**
79
- * Get a paginated list of manufacturers
80
- */
81
- getManufacturers(organizationId, query) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const { page = 1, limit = 10, search, locale } = query;
84
- // Fetch manufacturers with pagination
85
- const [list, meta] = yield this.prisma.manufacturer
86
- .paginate({
87
- orderBy: {
88
- createdAt: "desc",
89
- },
90
- where: Object.assign({ organizationId, deletedAt: null }, (search && {
91
- name: {
92
- contains: search,
93
- mode: "insensitive",
94
- },
95
- })),
96
- include: {
97
- logo: true,
98
- translations: locale
99
- ? {
100
- where: { locale },
101
- }
102
- : true,
103
- },
104
- })
105
- .withPages({
106
- page,
107
- limit,
108
- });
109
- if (!locale) {
110
- // Return standard response with ManufacturerSchema
111
- return z
112
- .object({
113
- meta: PaginationMetaSchema,
114
- list: z.array(ManufacturerSchema),
115
- })
116
- .parse({
117
- meta,
118
- list,
119
- });
120
- }
121
- // Process the list for localization
122
- const localizedList = list.map((item) => flattenTranslationData(item));
123
- // Return localized response with LocalizedManufacturerSchema
124
- return z
125
- .object({
126
- meta: PaginationMetaSchema,
127
- list: z.array(LocalizedManufacturerSchema),
128
- })
129
- .parse({
130
- meta,
131
- list: localizedList,
132
- });
133
- });
134
- }
135
- /**
136
- * Update a manufacturer
137
- */
138
- updateManufacturer(organizationId, id, userId, body) {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- // Fetch manufacturer by id
141
- yield this.findManufacturer(id, organizationId);
142
- // Update manufacturer
143
- const updatedManufacturer = yield this.prisma.manufacturer.update({
144
- where: {
145
- id,
146
- organizationId,
147
- deletedAt: null,
148
- },
149
- data: {
150
- updatedBy: userId,
151
- name: body.name,
152
- translations: {
153
- deleteMany: {},
154
- create: body.translations || [],
155
- },
156
- logoId: body.logoId,
157
- },
158
- include: {
159
- logo: true,
160
- translations: true,
161
- },
162
- });
163
- return ManufacturerSchema.parse(updatedManufacturer);
164
- });
165
- }
166
- /**
167
- * Delete a manufacturer (soft delete)
168
- */
169
- deleteManufacturer(organizationId, id, userId) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- // Fetch manufacturer by id
172
- yield this.findManufacturer(id, organizationId);
173
- // Soft delete manufacturer
174
- yield this.prisma.manufacturer.update({
175
- where: {
176
- id,
177
- organizationId,
178
- deletedAt: null,
179
- },
180
- data: {
181
- deletedAt: new Date(),
182
- deletedBy: userId,
183
- },
184
- });
185
- return;
186
- });
187
- }
188
- }
189
- export { ManufacturerService };
190
- //# sourceMappingURL=manufacturer.service.js.map
1
+ import{__awaiter as i}from"tslib";import{z as u}from"@hono/zod-openapi";import{HttpException as v}from"../../core/exceptions/http-exception";import{flattenTranslationData as d}from"../../core/utils/zod.util";import{LocalizedManufacturerSchema as f,ManufacturerSchema as o,PaginationMetaSchema as m}from"../../schemas";class M{constructor(e){this.prisma=e}findManufacturer(e,a,t){return i(this,void 0,void 0,function*(){const r=yield this.prisma.manufacturer.findUnique({where:{id:e,organizationId:a,deletedAt:null},include:t?.include});if(!r)throw new v(404,"Manufacturer not found");return r})}createManufacturer(e,a,t){return i(this,void 0,void 0,function*(){const r=yield this.prisma.manufacturer.create({data:{name:t.name,organizationId:e,createdBy:a,logoId:t.logoId,translations:{create:t.translations}},include:{translations:!0,logo:!0}});return o.parse(r)})}getManufacturer(e,a,t){return i(this,void 0,void 0,function*(){const{locale:r}=t,n=yield this.findManufacturer(a,e,{include:{logo:!0,translations:r?{where:{locale:r}}:!0}});return r?f.parse(d(n)):o.parse(n)})}getManufacturers(e,a){return i(this,void 0,void 0,function*(){const{page:t=1,limit:r=10,search:n,locale:s}=a,[c,l]=yield this.prisma.manufacturer.paginate({orderBy:{createdAt:"desc"},where:Object.assign({organizationId:e,deletedAt:null},n&&{name:{contains:n,mode:"insensitive"}}),include:{logo:!0,translations:s?{where:{locale:s}}:!0}}).withPages({page:t,limit:r});if(!s)return u.object({meta:m,list:u.array(o)}).parse({meta:l,list:c});const h=c.map(p=>d(p));return u.object({meta:m,list:u.array(f)}).parse({meta:l,list:h})})}updateManufacturer(e,a,t,r){return i(this,void 0,void 0,function*(){yield this.findManufacturer(a,e);const n=yield this.prisma.manufacturer.update({where:{id:a,organizationId:e,deletedAt:null},data:{updatedBy:t,name:r.name,translations:{deleteMany:{},create:r.translations||[]},logoId:r.logoId},include:{logo:!0,translations:!0}});return o.parse(n)})}deleteManufacturer(e,a,t){return i(this,void 0,void 0,function*(){yield this.findManufacturer(a,e),yield this.prisma.manufacturer.update({where:{id:a,organizationId:e,deletedAt:null},data:{deletedAt:new Date,deletedBy:t}})})}}export{M as ManufacturerService};
@@ -1,229 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } 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 OrderConfirmationEmail = ({ user, organization, order, }) => {
10
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
11
- const previewText = `This is your receipt from ${organization.name}`;
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 trackingUrl = `https://${organization.configuration.hostname}/account/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: "React Email 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: [_jsxs(Heading, { className: "text-3xl font-bold text-gray-800 mb-0", children: ["Hi ", user.firstname, ","] }), _jsx(Text, { className: "text-gray-600 mb-2 text-lg", children: "Your order has been received and is being processed." })] }), _jsx(Section, { className: "mb-0", children: _jsx(Link, { href: trackingUrl, className: "bg-gray-900 text-sm rounded-md text-white font-medium py-2 px-5 text-center inline-block my-4", children: "Track Your Order" }) })] }), _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: "Shipping details" }), _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 })] }), _jsx(Column, { className: "w-[40%] p-0 mt-0", align: "right", valign: "top", children: _jsx(Text, { className: "text-gray-500 mb-0 pt-1", children: formattedDate }) })] }) }), _jsx(Text, { className: "text-gray-500 mb-0", children: "Order Summary" }), _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: ((_o = organization.logoFile) === null || _o === void 0 ? void 0 : _o.url) && (_jsx(Img, { alt: "React Email 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: [(_p = organization.address) === null || _p === void 0 ? void 0 : _p.addressLineOne, ",", " ", (_q = organization.address) === null || _q === void 0 ? void 0 : _q.zipCode, " ", (_r = organization.address) === null || _r === void 0 ? void 0 : _r.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
- OrderConfirmationEmail.PreviewProps = previewProps;
227
- export default OrderConfirmationEmail;
228
- export { OrderConfirmationEmail };
229
- //# sourceMappingURL=order-confirmation.email.js.map
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Body as W,Column as n,Container as D,Head as Y,Heading as E,Hr as T,Html as J,Img as r,Link as c,Preview as K,Row as o,Section as s,Tailwind as U,Text as i}from"@react-email/components";const m=(h,l="PLN",a="en-US")=>new Intl.NumberFormat(a,{style:"currency",currency:l}).format(h),j=({user:h,organization:l,order:a})=>{var u,p,g,b,y,f,x,v,N,w,k,q,A,P,C,L;const F=`This is your receipt from ${l.name}`,O=new Date().toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}),B=((u=a.payment)===null||u===void 0?void 0:u.shipping)||0,_=((p=a.payment)===null||p===void 0?void 0:p.discount)||0,Z=((g=a.payment)===null||g===void 0?void 0:g.total)||0,H=`https://${l.configuration.hostname}/account/orders/${a.id}`;return t(J,{children:[e(Y,{}),e(K,{children:F}),e(U,{children:t(W,{className:"bg-gray-50 font-sans",children:[t(D,{className:"bg-gray-50 p-6 max-w-[600px]",children:[e(s,{className:"mb-6",children:t(o,{children:[e(n,{className:"w-[80%]",children:e(r,{alt:"React Email logo",height:"100",src:(b=l.logoFile)===null||b===void 0?void 0:b.url,className:"rounded-lg"})}),e(n,{align:"right",children:t(o,{align:"right",children:[e(n,{children:e(c,{href:"https://www.instagram.com/madrasbistro/",children:e(r,{alt:"Instagram",className:"mx-[4px]",height:"36",src:"https://react.email/static/instagram-logo.png",width:"36"})})}),e(n,{children:e(c,{href:"https://www.facebook.com/madrasBistro/",children:e(r,{alt:"Facebook",className:"mx-[4px]",height:"36",src:"https://react.email/static/facebook-logo.png",width:"36"})})})]})})]})}),t(s,{children:[t(E,{className:"text-3xl font-bold text-gray-800 mb-0",children:["Hi ",h.firstname,","]}),e(i,{className:"text-gray-600 mb-2 text-lg",children:"Your order has been received and is being processed."})]}),e(s,{className:"mb-0",children:e(c,{href:H,className:"bg-gray-900 text-sm rounded-md text-white font-medium py-2 px-5 text-center inline-block my-4",children:"Track Your Order"})})]}),t(D,{className:"mx-auto max-w-[600px] rounded-xl bg-white px-6",children:[e(s,{className:"mb-6",children:t(o,{children:[t(n,{className:"w-[60%]",children:[e(i,{className:"text-gray-500 mb-0",children:"Shipping details"}),t(i,{className:"font-semibold text-gray-800 my-0",children:[(y=a.shippingAddress)===null||y===void 0?void 0:y.firstname," ",(f=a.shippingAddress)===null||f===void 0?void 0:f.lastname]}),t(i,{className:"font-semibold text-gray-800 my-0",children:[(x=a.shippingAddress)===null||x===void 0?void 0:x.addressLineOne," ",((v=a.shippingAddress)===null||v===void 0?void 0:v.doorNumber)&&` / ${(N=a.shippingAddress)===null||N===void 0?void 0:N.doorNumber}`,e("br",{}),(w=a.shippingAddress)===null||w===void 0?void 0:w.city," ",(k=a.shippingAddress)===null||k===void 0?void 0:k.zipCode]}),e(i,{className:"text-gray-500 mb-0",children:"Phone"}),e(i,{className:"font-semibold text-gray-800 my-0",children:(q=a.shippingAddress)===null||q===void 0?void 0:q.phone})]}),e(n,{className:"w-[40%] p-0 mt-0",align:"right",valign:"top",children:e(i,{className:"text-gray-500 mb-0 pt-1",children:O})})]})}),e(i,{className:"text-gray-500 mb-0",children:"Order Summary"}),e(T,{className:"border-gray-200 mb-0"}),e(s,{children:a.items.map((R,I)=>{var M,S;const d=R;return e("table",{width:"100%",cellPadding:0,cellSpacing:0,border:0,className:I===a.items.length-1?"mb-0":"mb-4",children:t("tr",{children:[t("td",{valign:"top",children:[t(i,{className:"font-semibold mb-0",children:[((M=d.translations[0])===null||M===void 0?void 0:M.title)||"Product"," (",((S=d.translations[0])===null||S===void 0?void 0:S.subtitle)||"",")"]}),t(i,{className:"text-gray-600 mb-0 mt-0",children:["Quantity: ",d.quantity]})]}),e("td",{align:"right",valign:"top",children:e(i,{className:"font-semibold",children:m(d.unitPrice*d.quantity,l.configuration.defaultCurrency,l.configuration.defaultLocale)})})]})},I)})}),e(T,{className:"border-gray-200 mt-4"}),e(s,{children:t("table",{width:"100%",cellPadding:0,cellSpacing:0,border:0,children:[t("tr",{children:[e("td",{children:e(i,{className:"text-gray-700",children:"Delivery fee"})}),e("td",{align:"right",children:e(i,{className:"text-gray-700",children:m(B,l.configuration.defaultCurrency,l.configuration.defaultLocale)})})]}),_>0&&t("tr",{children:[e("td",{children:e(i,{className:"text-gray-700",children:"Campaign"})}),e("td",{align:"right",children:t(i,{className:"text-gray-700",children:["-",m(_,l.configuration.defaultCurrency,l.configuration.defaultLocale)]})})]})]})}),e(T,{className:"border-gray-200"}),e(s,{className:"mb-6",children:e("table",{width:"100%",cellPadding:0,cellSpacing:0,border:0,children:t("tr",{children:[e("td",{children:e(i,{className:"text-xl font-bold mb-0",children:"Total:"})}),e("td",{align:"right",children:e(i,{className:"text-xl font-bold mb-0",children:m(Z,l.configuration.defaultCurrency,l.configuration.defaultLocale)})})]})})})]}),e(s,{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:((A=l.logoFile)===null||A===void 0?void 0:A.url)&&e(r,{alt:"React Email logo",height:"100",src:l.logoFile.url,className:"rounded-lg"})})}),e("tr",{className:"w-full",children:t("td",{align:"center",children:[e(i,{className:"my-[8px] text-[16px] font-semibold text-xl pt-2 text-gray-900",children:l.name}),t(i,{className:"my-[8px] text-[16px] leading-[24px] text-gray-500",children:[(P=l.address)===null||P===void 0?void 0:P.addressLineOne,","," ",(C=l.address)===null||C===void 0?void 0:C.zipCode," ",(L=l.address)===null||L===void 0?void 0:L.city]}),e(i,{className:"mb-0 mt-[4px] text-[16px] leading-[24px] text-gray-500",children:l.phone})]})}),e("tr",{children:e("td",{align:"center",children:t(o,{className:"table-cell h-[44px] w-[56px] align-bottom pt-5",children:[e(n,{className:"pr-[8px]",children:e(c,{href:"https://www.facebook.com/madrasBistro/",children:e(r,{alt:"Facebook",height:"36",src:"https://react.email/static/facebook-logo.png",width:"36"})})}),e(n,{children:e(c,{href:"https://www.instagram.com/madrasbistro/",children:e(r,{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"}}};j.PreviewProps=z;export default j;export{j as OrderConfirmationEmail};