@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,82 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Body, Column, Container, Head, Heading, Hr, Html, Img, Link, Preview, Row, Section, Tailwind, Text, } from "@react-email/components";
|
|
3
|
-
import { format } from "date-fns";
|
|
4
|
-
const ReservationConfirmationEmail = ({ user, organization, reservation, }) => {
|
|
5
|
-
var _a, _b, _c, _d, _e;
|
|
6
|
-
const previewText = `This is your reservation confirmation from ${organization.name}`;
|
|
7
|
-
const formattedDate = format(new Date(reservation.date), "dd.MM.yyyy 'at' HH:mm");
|
|
8
|
-
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: (_a = organization.logoFile) === null || _a === void 0 ? void 0 : _a.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 reservation has been confirmed." })] })] }), _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: "Reservation details" }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: [reservation.firstname, " ", reservation.lastname] }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: ["Reference: ", reservation.referenceId] }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: ["Date and Time: ", formattedDate] }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: ["Number of Guests: ", reservation.guests] }), _jsx(Text, { className: "text-gray-500 mb-0", children: "Phone" }), _jsx(Text, { className: "font-semibold text-gray-800 my-0", children: reservation.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: format(new Date(), "dd.MM.yyyy") }) })] }) }), _jsx(Hr, { className: "border-gray-200 mt-4" }), _jsxs(Section, { className: "mb-6", children: [_jsxs(Text, { className: "text-gray-700", children: ["We're looking forward to welcoming you at ", organization.name, ". If you need to make any changes to your reservation, please contact us directly at ", organization.phone, "."] }), _jsx(Text, { className: "text-gray-700", children: "Please note that we hold your table for 15 minutes from your reservation time." })] })] }), _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: ((_b = organization.logoFile) === null || _b === void 0 ? void 0 : _b.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: [(_c = organization.address) === null || _c === void 0 ? void 0 : _c.addressLineOne, ",", " ", (_d = organization.address) === null || _d === void 0 ? void 0 : _d.zipCode, " ", (_e = organization.address) === null || _e === void 0 ? void 0 : _e.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" }) }) })] }) }) })] }) })] }) })] }));
|
|
9
|
-
};
|
|
10
|
-
const previewProps = {
|
|
11
|
-
user: {
|
|
12
|
-
id: "VD0OJ52f0mdAnm5YePP6BAW6hdbaCjAJ",
|
|
13
|
-
name: "Abhishek Shaji",
|
|
14
|
-
email: "kontakt@abhishek.pl",
|
|
15
|
-
emailVerified: true,
|
|
16
|
-
image: "https://lh3.googleusercontent.com/a/ACg8ocKbkCAMTNvMizjXNxcm1aYtBiWnYpCYmU-7aE2Ft_M_uiHheZ5f=s96-c",
|
|
17
|
-
createdAt: "2025-03-22T22:54:40.260Z",
|
|
18
|
-
updatedAt: "2025-03-22T22:54:40.260Z",
|
|
19
|
-
firstname: "Abhishek",
|
|
20
|
-
lastname: "Shaji",
|
|
21
|
-
},
|
|
22
|
-
reservation: {
|
|
23
|
-
id: "cm94wbpbm0000itx1iv9k2mqr",
|
|
24
|
-
referenceId: "PH6LD6",
|
|
25
|
-
firstname: "Abhishek",
|
|
26
|
-
lastname: "Shaji",
|
|
27
|
-
phone: "+48570135862",
|
|
28
|
-
guests: 4,
|
|
29
|
-
date: new Date("2025-04-07T19:30:00.000Z"),
|
|
30
|
-
createdAt: "2025-03-22T22:54:40.260Z",
|
|
31
|
-
acceptedAt: "2025-03-22T23:00:23.456Z",
|
|
32
|
-
cancelledAt: null,
|
|
33
|
-
},
|
|
34
|
-
organization: {
|
|
35
|
-
id: "cm8kthfdq0001lg03b59mdy7b",
|
|
36
|
-
name: "Madras Bistro",
|
|
37
|
-
phone: "+48570135862",
|
|
38
|
-
email: "contact@madrasbistro.pl",
|
|
39
|
-
createdAt: "2025-03-22T23:05:14.271Z",
|
|
40
|
-
legalEntityId: null,
|
|
41
|
-
address: {
|
|
42
|
-
id: "cm8kthfdr0002lg0350ijialt",
|
|
43
|
-
firstname: null,
|
|
44
|
-
lastname: null,
|
|
45
|
-
phone: null,
|
|
46
|
-
addressLineOne: "Plac Bohaterów Getta 2",
|
|
47
|
-
doorNumber: null,
|
|
48
|
-
addressLineTwo: "3",
|
|
49
|
-
zipCode: "33-332",
|
|
50
|
-
city: "Kraków",
|
|
51
|
-
country: "PL",
|
|
52
|
-
placeId: "ChIJf-nsRkRbFkcR21gtObFSSSA",
|
|
53
|
-
deliveryInstructions: null,
|
|
54
|
-
},
|
|
55
|
-
configuration: {
|
|
56
|
-
id: "cm8kthfdr0003lg03ghgs262n",
|
|
57
|
-
hostname: "madrasbistro.pl",
|
|
58
|
-
countriesShipping: ["us"],
|
|
59
|
-
stripeAccountId: "null",
|
|
60
|
-
enableHostCheckout: false,
|
|
61
|
-
enableHostTracking: false,
|
|
62
|
-
isAcceptingOrders: false,
|
|
63
|
-
defaultLocale: "en",
|
|
64
|
-
supportedLocales: ["en", "pl"],
|
|
65
|
-
defaultCurrency: "PLN",
|
|
66
|
-
createdAt: "2025-03-22T23:05:14.271Z",
|
|
67
|
-
},
|
|
68
|
-
logo: "https://z3liuyatqnepss3d.public.blob.vercel-storage.com/logo-zeJymFRMFCIKPlvjxYm2af3SAWvBOj.png",
|
|
69
|
-
logoFile: {
|
|
70
|
-
id: "cm8ktmu890005lg0356gwclfk",
|
|
71
|
-
url: "https://z3liuyatqnepss3d.public.blob.vercel-storage.com/logo-zeJymFRMFCIKPlvjxYm2af3SAWvBOj.png",
|
|
72
|
-
mimeType: "image/png",
|
|
73
|
-
size: 1652289,
|
|
74
|
-
filename: "logo.png",
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
// Fixed the TypeScript error by using proper type assertion
|
|
79
|
-
ReservationConfirmationEmail.PreviewProps = previewProps;
|
|
80
|
-
export default ReservationConfirmationEmail;
|
|
81
|
-
export { ReservationConfirmationEmail };
|
|
82
|
-
//# sourceMappingURL=reservation-confirmation.email.js.map
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Body as N,Column as s,Container as b,Head as k,Heading as v,Hr as A,Html as T,Img as i,Link as n,Preview as j,Row as d,Section as c,Tailwind as C,Text as t}from"@react-email/components";import{format as f}from"date-fns";const u=({user:x,organization:l,reservation:r})=>{var m,o,h,g,p;const y=`This is your reservation confirmation from ${l.name}`,w=f(new Date(r.date),"dd.MM.yyyy 'at' HH:mm");return a(T,{children:[e(k,{}),e(j,{children:y}),e(C,{children:a(N,{className:"bg-gray-50 font-sans",children:[a(b,{className:"bg-gray-50 p-6 max-w-[600px]",children:[e(c,{className:"mb-6",children:a(d,{children:[e(s,{className:"w-[80%]",children:e(i,{alt:`${l.name} logo`,height:"100",src:(m=l.logoFile)===null||m===void 0?void 0:m.url,className:"rounded-lg"})}),e(s,{align:"right",children:a(d,{align:"right",children:[e(s,{children:e(n,{href:"https://www.instagram.com/madrasbistro/",children:e(i,{alt:"Instagram",className:"mx-[4px]",height:"36",src:"https://react.email/static/instagram-logo.png",width:"36"})})}),e(s,{children:e(n,{href:"https://www.facebook.com/madrasBistro/",children:e(i,{alt:"Facebook",className:"mx-[4px]",height:"36",src:"https://react.email/static/facebook-logo.png",width:"36"})})})]})})]})}),a(c,{children:[a(v,{className:"text-3xl font-bold text-gray-800 mb-0",children:["Hi ",x.firstname,","]}),e(t,{className:"text-gray-600 mb-2 text-lg",children:"Your reservation has been confirmed."})]})]}),a(b,{className:"mx-auto max-w-[600px] rounded-xl bg-white px-6",children:[e(c,{className:"mb-6",children:a(d,{children:[a(s,{className:"w-[60%]",children:[e(t,{className:"text-gray-500 mb-0",children:"Reservation details"}),a(t,{className:"font-semibold text-gray-800 my-0",children:[r.firstname," ",r.lastname]}),a(t,{className:"font-semibold text-gray-800 my-0",children:["Reference: ",r.referenceId]}),a(t,{className:"font-semibold text-gray-800 my-0",children:["Date and Time: ",w]}),a(t,{className:"font-semibold text-gray-800 my-0",children:["Number of Guests: ",r.guests]}),e(t,{className:"text-gray-500 mb-0",children:"Phone"}),e(t,{className:"font-semibold text-gray-800 my-0",children:r.phone})]}),e(s,{className:"w-[40%] p-0 mt-0",align:"right",valign:"top",children:e(t,{className:"text-gray-500 mb-0 pt-1",children:f(new Date,"dd.MM.yyyy")})})]})}),e(A,{className:"border-gray-200 mt-4"}),a(c,{className:"mb-6",children:[a(t,{className:"text-gray-700",children:["We're looking forward to welcoming you at ",l.name,". If you need to make any changes to your reservation, please contact us directly at ",l.phone,"."]}),e(t,{className:"text-gray-700",children:"Please note that we hold your table for 15 minutes from your reservation time."})]})]}),e(c,{className:"text-center bg-gray-50 py-5",children:a("table",{className:"w-full",children:[e("tr",{className:"w-full",children:e("td",{align:"center",children:((o=l.logoFile)===null||o===void 0?void 0:o.url)&&e(i,{alt:`${l.name} logo`,height:"100",src:l.logoFile.url,className:"rounded-lg"})})}),e("tr",{className:"w-full",children:a("td",{align:"center",children:[e(t,{className:"my-[8px] text-[16px] font-semibold text-xl pt-2 text-gray-900",children:l.name}),a(t,{className:"my-[8px] text-[16px] leading-[24px] text-gray-500",children:[(h=l.address)===null||h===void 0?void 0:h.addressLineOne,","," ",(g=l.address)===null||g===void 0?void 0:g.zipCode," ",(p=l.address)===null||p===void 0?void 0:p.city]}),e(t,{className:"mb-0 mt-[4px] text-[16px] leading-[24px] text-gray-500",children:l.phone})]})}),e("tr",{children:e("td",{align:"center",children:a(d,{className:"table-cell h-[44px] w-[56px] align-bottom pt-5",children:[e(s,{className:"pr-[8px]",children:e(n,{href:"https://www.facebook.com/madrasBistro/",children:e(i,{alt:"Facebook",height:"36",src:"https://react.email/static/facebook-logo.png",width:"36"})})}),e(s,{children:e(n,{href:"https://www.instagram.com/madrasbistro/",children:e(i,{alt:"Instagram",height:"36",src:"https://react.email/static/instagram-logo.png",width:"36"})})})]})})})]})})]})})]})},P={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"},reservation:{id:"cm94wbpbm0000itx1iv9k2mqr",referenceId:"PH6LD6",firstname:"Abhishek",lastname:"Shaji",phone:"+48570135862",guests:4,date:new Date("2025-04-07T19:30:00.000Z"),createdAt:"2025-03-22T22:54:40.260Z",acceptedAt:"2025-03-22T23:00:23.456Z",cancelledAt:null},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:"madrasbistro.pl",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"}}};u.PreviewProps=P;export default u;export{u as ReservationConfirmationEmail};
|
|
@@ -1,93 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Body, Button, Column, Container, Head, Heading, Hr, Html, Img, Link, Preview, Row, Section, Tailwind, Text, } from "@react-email/components";
|
|
3
|
-
import { format } from "date-fns";
|
|
4
|
-
const ReservationNotificationEmail = ({ user, member, organization, reservation, }) => {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6
|
-
const previewText = `New reservation request for ${organization.name}`;
|
|
7
|
-
const formattedDate = format(new Date(reservation.date), "dd.MM.yyyy 'at' HH:mm");
|
|
8
|
-
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: (_a = organization.logoFile) === null || _a === void 0 ? void 0 : _a.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 ", member.firstname, ","] }), _jsx(Text, { className: "text-gray-600 mb-2 text-lg", children: "You have received a new reservation request." })] })] }), _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: "Reservation details" }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: [reservation.firstname, " ", reservation.lastname] }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: ["Reference: ", reservation.referenceId] }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: ["Date and Time: ", formattedDate] }), _jsxs(Text, { className: "font-semibold text-gray-800 my-0", children: ["Number of Guests: ", reservation.guests] }), _jsx(Text, { className: "text-gray-500 mb-0", children: "Phone" }), _jsx(Text, { className: "font-semibold text-gray-800 my-0", children: reservation.phone }), _jsx(Text, { className: "text-gray-500 mb-0", children: "Email" }), _jsx(Text, { className: "font-semibold text-gray-800 my-0", children: user.email })] }), _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: format(new Date(), "dd.MM.yyyy") }) })] }) }), _jsx(Hr, { className: "border-gray-200 mt-4" }), _jsxs(Section, { className: "mb-6", children: [_jsx(Text, { className: "text-gray-700", children: "Please review and respond to this reservation request as soon as possible." }), _jsx(Button, { href: `https://admin.${(_b = organization.configuration) === null || _b === void 0 ? void 0 : _b.hostname}/admin/reservations/${reservation.id}`, className: "bg-blue-600 rounded py-3 px-5 text-white text-center block mt-4", children: "View Reservation Details" })] })] }), _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: ((_c = organization.logoFile) === null || _c === void 0 ? void 0 : _c.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: [(_d = organization.address) === null || _d === void 0 ? void 0 : _d.addressLineOne, ",", " ", (_e = organization.address) === null || _e === void 0 ? void 0 : _e.zipCode, " ", (_f = organization.address) === null || _f === void 0 ? void 0 : _f.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" }) }) })] }) }) })] }) })] }) })] }));
|
|
9
|
-
};
|
|
10
|
-
const previewProps = {
|
|
11
|
-
user: {
|
|
12
|
-
id: "VD0OJ52f0mdAnm5YePP6BAW6hdbaCjAJ",
|
|
13
|
-
name: "Abhishek Shaji",
|
|
14
|
-
email: "kontakt@abhishek.pl",
|
|
15
|
-
emailVerified: true,
|
|
16
|
-
image: "https://lh3.googleusercontent.com/a/ACg8ocKbkCAMTNvMizjXNxcm1aYtBiWnYpCYmU-7aE2Ft_M_uiHheZ5f=s96-c",
|
|
17
|
-
createdAt: "2025-03-22T22:54:40.260Z",
|
|
18
|
-
updatedAt: "2025-03-22T22:54:40.260Z",
|
|
19
|
-
firstname: "Abhishek",
|
|
20
|
-
lastname: "Shaji",
|
|
21
|
-
},
|
|
22
|
-
member: {
|
|
23
|
-
id: "KL9MN52f0mdOnp8YeQR7CAX5hdbdDkBP",
|
|
24
|
-
name: "John Doe",
|
|
25
|
-
email: "john@madrasbistro.pl",
|
|
26
|
-
emailVerified: true,
|
|
27
|
-
image: null,
|
|
28
|
-
createdAt: "2025-03-20T10:30:15.123Z",
|
|
29
|
-
updatedAt: "2025-03-20T10:30:15.123Z",
|
|
30
|
-
firstname: "John",
|
|
31
|
-
lastname: "Doe",
|
|
32
|
-
},
|
|
33
|
-
reservation: {
|
|
34
|
-
id: "cm94wbpbm0000itx1iv9k2mqr",
|
|
35
|
-
referenceId: "PH6LD6",
|
|
36
|
-
firstname: "Abhishek",
|
|
37
|
-
lastname: "Shaji",
|
|
38
|
-
phone: "+48570135862",
|
|
39
|
-
guests: 4,
|
|
40
|
-
date: new Date("2025-04-07T19:30:00.000Z"),
|
|
41
|
-
createdAt: "2025-03-22T22:54:40.260Z",
|
|
42
|
-
acceptedAt: null,
|
|
43
|
-
cancelledAt: null,
|
|
44
|
-
},
|
|
45
|
-
organization: {
|
|
46
|
-
id: "cm8kthfdq0001lg03b59mdy7b",
|
|
47
|
-
name: "Madras Bistro",
|
|
48
|
-
phone: "+48570135862",
|
|
49
|
-
email: "contact@madrasbistro.pl",
|
|
50
|
-
createdAt: "2025-03-22T23:05:14.271Z",
|
|
51
|
-
legalEntityId: null,
|
|
52
|
-
address: {
|
|
53
|
-
id: "cm8kthfdr0002lg0350ijialt",
|
|
54
|
-
firstname: null,
|
|
55
|
-
lastname: null,
|
|
56
|
-
phone: null,
|
|
57
|
-
addressLineOne: "Plac Bohaterów Getta 2",
|
|
58
|
-
doorNumber: null,
|
|
59
|
-
addressLineTwo: "3",
|
|
60
|
-
zipCode: "33-332",
|
|
61
|
-
city: "Kraków",
|
|
62
|
-
country: "PL",
|
|
63
|
-
placeId: "ChIJf-nsRkRbFkcR21gtObFSSSA",
|
|
64
|
-
deliveryInstructions: null,
|
|
65
|
-
},
|
|
66
|
-
configuration: {
|
|
67
|
-
id: "cm8kthfdr0003lg03ghgs262n",
|
|
68
|
-
hostname: "madrasbistro.pl",
|
|
69
|
-
countriesShipping: ["us"],
|
|
70
|
-
stripeAccountId: "null",
|
|
71
|
-
enableHostCheckout: false,
|
|
72
|
-
enableHostTracking: false,
|
|
73
|
-
isAcceptingOrders: false,
|
|
74
|
-
defaultLocale: "en",
|
|
75
|
-
supportedLocales: ["en", "pl"],
|
|
76
|
-
defaultCurrency: "PLN",
|
|
77
|
-
createdAt: "2025-03-22T23:05:14.271Z",
|
|
78
|
-
},
|
|
79
|
-
logo: "https://z3liuyatqnepss3d.public.blob.vercel-storage.com/logo-zeJymFRMFCIKPlvjxYm2af3SAWvBOj.png",
|
|
80
|
-
logoFile: {
|
|
81
|
-
id: "cm8ktmu890005lg0356gwclfk",
|
|
82
|
-
url: "https://z3liuyatqnepss3d.public.blob.vercel-storage.com/logo-zeJymFRMFCIKPlvjxYm2af3SAWvBOj.png",
|
|
83
|
-
mimeType: "image/png",
|
|
84
|
-
size: 1652289,
|
|
85
|
-
filename: "logo.png",
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
// Fixed the TypeScript error by using proper type assertion
|
|
90
|
-
ReservationNotificationEmail.PreviewProps = previewProps;
|
|
91
|
-
export default ReservationNotificationEmail;
|
|
92
|
-
export { ReservationNotificationEmail };
|
|
93
|
-
//# sourceMappingURL=reservation-notification.email.js.map
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Body as k,Button as A,Column as s,Container as x,Head as T,Heading as j,Hr as P,Html as C,Img as i,Link as c,Preview as F,Row as d,Section as n,Tailwind as I,Text as t}from"@react-email/components";import{format as f}from"date-fns";const u=({user:y,member:w,organization:l,reservation:r})=>{var m,o,h,g,p,b;const N=`New reservation request for ${l.name}`,v=f(new Date(r.date),"dd.MM.yyyy 'at' HH:mm");return a(C,{children:[e(T,{}),e(F,{children:N}),e(I,{children:a(k,{className:"bg-gray-50 font-sans",children:[a(x,{className:"bg-gray-50 p-6 max-w-[600px]",children:[e(n,{className:"mb-6",children:a(d,{children:[e(s,{className:"w-[80%]",children:e(i,{alt:`${l.name} logo`,height:"100",src:(m=l.logoFile)===null||m===void 0?void 0:m.url,className:"rounded-lg"})}),e(s,{align:"right",children:a(d,{align:"right",children:[e(s,{children:e(c,{href:"https://www.instagram.com/madrasbistro/",children:e(i,{alt:"Instagram",className:"mx-[4px]",height:"36",src:"https://react.email/static/instagram-logo.png",width:"36"})})}),e(s,{children:e(c,{href:"https://www.facebook.com/madrasBistro/",children:e(i,{alt:"Facebook",className:"mx-[4px]",height:"36",src:"https://react.email/static/facebook-logo.png",width:"36"})})})]})})]})}),a(n,{children:[a(j,{className:"text-3xl font-bold text-gray-800 mb-0",children:["Hi ",w.firstname,","]}),e(t,{className:"text-gray-600 mb-2 text-lg",children:"You have received a new reservation request."})]})]}),a(x,{className:"mx-auto max-w-[600px] rounded-xl bg-white px-6",children:[e(n,{className:"mb-6",children:a(d,{children:[a(s,{className:"w-[60%]",children:[e(t,{className:"text-gray-500 mb-0",children:"Reservation details"}),a(t,{className:"font-semibold text-gray-800 my-0",children:[r.firstname," ",r.lastname]}),a(t,{className:"font-semibold text-gray-800 my-0",children:["Reference: ",r.referenceId]}),a(t,{className:"font-semibold text-gray-800 my-0",children:["Date and Time: ",v]}),a(t,{className:"font-semibold text-gray-800 my-0",children:["Number of Guests: ",r.guests]}),e(t,{className:"text-gray-500 mb-0",children:"Phone"}),e(t,{className:"font-semibold text-gray-800 my-0",children:r.phone}),e(t,{className:"text-gray-500 mb-0",children:"Email"}),e(t,{className:"font-semibold text-gray-800 my-0",children:y.email})]}),e(s,{className:"w-[40%] p-0 mt-0",align:"right",valign:"top",children:e(t,{className:"text-gray-500 mb-0 pt-1",children:f(new Date,"dd.MM.yyyy")})})]})}),e(P,{className:"border-gray-200 mt-4"}),a(n,{className:"mb-6",children:[e(t,{className:"text-gray-700",children:"Please review and respond to this reservation request as soon as possible."}),e(A,{href:`https://admin.${(o=l.configuration)===null||o===void 0?void 0:o.hostname}/admin/reservations/${r.id}`,className:"bg-blue-600 rounded py-3 px-5 text-white text-center block mt-4",children:"View Reservation Details"})]})]}),e(n,{className:"text-center bg-gray-50 py-5",children:a("table",{className:"w-full",children:[e("tr",{className:"w-full",children:e("td",{align:"center",children:((h=l.logoFile)===null||h===void 0?void 0:h.url)&&e(i,{alt:`${l.name} logo`,height:"100",src:l.logoFile.url,className:"rounded-lg"})})}),e("tr",{className:"w-full",children:a("td",{align:"center",children:[e(t,{className:"my-[8px] text-[16px] font-semibold text-xl pt-2 text-gray-900",children:l.name}),a(t,{className:"my-[8px] text-[16px] leading-[24px] text-gray-500",children:[(g=l.address)===null||g===void 0?void 0:g.addressLineOne,","," ",(p=l.address)===null||p===void 0?void 0:p.zipCode," ",(b=l.address)===null||b===void 0?void 0:b.city]}),e(t,{className:"mb-0 mt-[4px] text-[16px] leading-[24px] text-gray-500",children:l.phone})]})}),e("tr",{children:e("td",{align:"center",children:a(d,{className:"table-cell h-[44px] w-[56px] align-bottom pt-5",children:[e(s,{className:"pr-[8px]",children:e(c,{href:"https://www.facebook.com/madrasBistro/",children:e(i,{alt:"Facebook",height:"36",src:"https://react.email/static/facebook-logo.png",width:"36"})})}),e(s,{children:e(c,{href:"https://www.instagram.com/madrasbistro/",children:e(i,{alt:"Instagram",height:"36",src:"https://react.email/static/instagram-logo.png",width:"36"})})})]})})})]})})]})})]})},B={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"},member:{id:"KL9MN52f0mdOnp8YeQR7CAX5hdbdDkBP",name:"John Doe",email:"john@madrasbistro.pl",emailVerified:!0,image:null,createdAt:"2025-03-20T10:30:15.123Z",updatedAt:"2025-03-20T10:30:15.123Z",firstname:"John",lastname:"Doe"},reservation:{id:"cm94wbpbm0000itx1iv9k2mqr",referenceId:"PH6LD6",firstname:"Abhishek",lastname:"Shaji",phone:"+48570135862",guests:4,date:new Date("2025-04-07T19:30:00.000Z"),createdAt:"2025-03-22T22:54:40.260Z",acceptedAt:null,cancelledAt:null},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:"madrasbistro.pl",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"}}};u.PreviewProps=B;export default u;export{u as ReservationNotificationEmail};
|
|
@@ -1,65 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createApiRouter } from "../../core/hono/hono";
|
|
3
|
-
import { reservationRoute } from "./reservation.route";
|
|
4
|
-
import { ReservationService } from "./reservation.service";
|
|
5
|
-
export const buildReservationHandler = (prisma, resendApiKey) => {
|
|
6
|
-
const app = createApiRouter();
|
|
7
|
-
app.openapi(reservationRoute.createReservation, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
-
const auth = c.get("auth");
|
|
9
|
-
const body = c.req.valid("json");
|
|
10
|
-
const params = c.req.valid("param");
|
|
11
|
-
let user = null;
|
|
12
|
-
try {
|
|
13
|
-
user = yield auth.getCurrentUser();
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
// User is not logged in but can still create reservations as a guest
|
|
17
|
-
}
|
|
18
|
-
const service = new ReservationService(prisma, resendApiKey);
|
|
19
|
-
const reservation = yield service.createReservation(params.organizationId, user, body);
|
|
20
|
-
return c.json(reservation, 201);
|
|
21
|
-
}));
|
|
22
|
-
app.openapi(reservationRoute.getReservation, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const auth = c.get("auth");
|
|
24
|
-
const params = c.req.valid("param");
|
|
25
|
-
const user = yield auth.getCurrentUser();
|
|
26
|
-
const service = new ReservationService(prisma, resendApiKey);
|
|
27
|
-
const reservation = yield service.getReservation(user, params.organizationId, params.reservationId);
|
|
28
|
-
return c.json(reservation, 200);
|
|
29
|
-
}));
|
|
30
|
-
app.openapi(reservationRoute.getReservations, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
const auth = c.get("auth");
|
|
32
|
-
const params = c.req.valid("param");
|
|
33
|
-
const query = c.req.valid("query");
|
|
34
|
-
yield auth.isGranted("read");
|
|
35
|
-
const service = new ReservationService(prisma, resendApiKey);
|
|
36
|
-
const reservations = yield service.getReservations(params.organizationId, query);
|
|
37
|
-
return c.json(reservations, 200);
|
|
38
|
-
}));
|
|
39
|
-
app.openapi(reservationRoute.getUserReservations, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
const auth = c.get("auth");
|
|
41
|
-
const params = c.req.valid("param");
|
|
42
|
-
yield auth.isGranted("read");
|
|
43
|
-
const service = new ReservationService(prisma, resendApiKey);
|
|
44
|
-
const reservations = yield service.getUserReservations(params.userId, params.organizationId);
|
|
45
|
-
return c.json(reservations, 200);
|
|
46
|
-
}));
|
|
47
|
-
app.openapi(reservationRoute.updateReservationStatus, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
const auth = c.get("auth");
|
|
49
|
-
const params = c.req.valid("param");
|
|
50
|
-
yield auth.isGranted("update");
|
|
51
|
-
const service = new ReservationService(prisma, resendApiKey);
|
|
52
|
-
const reservation = yield service.updateStatus(params.organizationId, params.reservationId, params.operation);
|
|
53
|
-
return c.json(reservation, 200);
|
|
54
|
-
}));
|
|
55
|
-
app.openapi(reservationRoute.deleteReservation, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
const auth = c.get("auth");
|
|
57
|
-
const params = c.req.valid("param");
|
|
58
|
-
yield auth.isGranted("delete");
|
|
59
|
-
const service = new ReservationService(prisma, resendApiKey);
|
|
60
|
-
yield service.deleteReservation(params.organizationId, params.reservationId);
|
|
61
|
-
return c.body(null, 204);
|
|
62
|
-
}));
|
|
63
|
-
return app;
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=reservation.handler.js.map
|
|
1
|
+
import{__awaiter as v}from"tslib";import{createApiRouter as p}from"../../core/hono/hono";import{reservationRoute as d}from"./reservation.route";import{ReservationService as u}from"./reservation.service";export const buildReservationHandler=(i,s)=>{const a=p();return a.openapi(d.createReservation,e=>v(void 0,void 0,void 0,function*(){const o=e.get("auth"),t=e.req.valid("json"),r=e.req.valid("param");let n=null;try{n=yield o.getCurrentUser()}catch{}const l=yield new u(i,s).createReservation(r.organizationId,n,t);return e.json(l,201)})),a.openapi(d.getReservation,e=>v(void 0,void 0,void 0,function*(){const o=e.get("auth"),t=e.req.valid("param"),r=yield o.getCurrentUser(),c=yield new u(i,s).getReservation(r,t.organizationId,t.reservationId);return e.json(c,200)})),a.openapi(d.getReservations,e=>v(void 0,void 0,void 0,function*(){const o=e.get("auth"),t=e.req.valid("param"),r=e.req.valid("query");yield o.isGranted("read");const c=yield new u(i,s).getReservations(t.organizationId,r);return e.json(c,200)})),a.openapi(d.getUserReservations,e=>v(void 0,void 0,void 0,function*(){const o=e.get("auth"),t=e.req.valid("param");yield o.isGranted("read");const n=yield new u(i,s).getUserReservations(t.userId,t.organizationId);return e.json(n,200)})),a.openapi(d.updateReservationStatus,e=>v(void 0,void 0,void 0,function*(){const o=e.get("auth"),t=e.req.valid("param");yield o.isGranted("update");const n=yield new u(i,s).updateStatus(t.organizationId,t.reservationId,t.operation);return e.json(n,200)})),a.openapi(d.deleteReservation,e=>v(void 0,void 0,void 0,function*(){const o=e.get("auth"),t=e.req.valid("param");return yield o.isGranted("delete"),yield new u(i,s).deleteReservation(t.organizationId,t.reservationId),e.body(null,204)})),a};
|
|
@@ -1,167 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createApiRoute } from "../../core/hono/hono";
|
|
3
|
-
import { CreateReservationSchema, ErrorSchema, HeaderSchema, OrganizationParams, PaginationMetaSchema, PaginationQuerySchema, ReservationSchema, } from "../../schemas";
|
|
4
|
-
const reservationParams = z.object({
|
|
5
|
-
organizationId: z.string().openapi({
|
|
6
|
-
description: "Organization ID",
|
|
7
|
-
example: "clj1234567890abcdef",
|
|
8
|
-
param: {
|
|
9
|
-
in: "path",
|
|
10
|
-
name: "organizationId",
|
|
11
|
-
},
|
|
12
|
-
}),
|
|
13
|
-
reservationId: z.string().openapi({
|
|
14
|
-
description: "Reservation ID",
|
|
15
|
-
example: "clj1234567890abcdef",
|
|
16
|
-
param: {
|
|
17
|
-
in: "path",
|
|
18
|
-
name: "reservationId",
|
|
19
|
-
},
|
|
20
|
-
}),
|
|
21
|
-
});
|
|
22
|
-
const userReservationParams = z.object({
|
|
23
|
-
organizationId: z.string().openapi({
|
|
24
|
-
description: "Organization ID",
|
|
25
|
-
example: "clj1234567890abcdef",
|
|
26
|
-
param: {
|
|
27
|
-
in: "path",
|
|
28
|
-
name: "organizationId",
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
userId: z.string().openapi({
|
|
32
|
-
description: "User ID",
|
|
33
|
-
example: "clj1234567890abcdef",
|
|
34
|
-
param: {
|
|
35
|
-
in: "path",
|
|
36
|
-
name: "userId",
|
|
37
|
-
},
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
const updateReservationStatusParams = reservationParams.extend({
|
|
41
|
-
operation: z.enum(["accept", "cancel"]).openapi({
|
|
42
|
-
description: "Operation",
|
|
43
|
-
example: "accept",
|
|
44
|
-
param: {
|
|
45
|
-
in: "path",
|
|
46
|
-
name: "operation",
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
});
|
|
50
|
-
const createReservationRoute = createApiRoute({
|
|
51
|
-
body: CreateReservationSchema,
|
|
52
|
-
description: "Create a new reservation",
|
|
53
|
-
headers: HeaderSchema,
|
|
54
|
-
method: "POST",
|
|
55
|
-
operationId: "createReservation",
|
|
56
|
-
path: "/:organizationId/reservations",
|
|
57
|
-
pathParams: OrganizationParams,
|
|
58
|
-
responses: {
|
|
59
|
-
201: ReservationSchema,
|
|
60
|
-
400: ErrorSchema,
|
|
61
|
-
401: ErrorSchema,
|
|
62
|
-
500: ErrorSchema,
|
|
63
|
-
},
|
|
64
|
-
summary: "Create Reservation",
|
|
65
|
-
tags: ["Reservation"],
|
|
66
|
-
});
|
|
67
|
-
const getReservationRoute = createApiRoute({
|
|
68
|
-
description: "Get a specific reservation by ID",
|
|
69
|
-
headers: HeaderSchema,
|
|
70
|
-
method: "GET",
|
|
71
|
-
operationId: "getReservation",
|
|
72
|
-
path: "/:organizationId/reservations/:reservationId",
|
|
73
|
-
pathParams: reservationParams,
|
|
74
|
-
responses: {
|
|
75
|
-
200: ReservationSchema,
|
|
76
|
-
400: ErrorSchema,
|
|
77
|
-
401: ErrorSchema,
|
|
78
|
-
404: ErrorSchema,
|
|
79
|
-
500: ErrorSchema,
|
|
80
|
-
},
|
|
81
|
-
summary: "Get Reservation",
|
|
82
|
-
tags: ["Reservation"],
|
|
83
|
-
});
|
|
84
|
-
const getReservationsRoute = createApiRoute({
|
|
85
|
-
description: "Get all reservations for an organization",
|
|
86
|
-
headers: HeaderSchema,
|
|
87
|
-
method: "GET",
|
|
88
|
-
operationId: "getReservations",
|
|
89
|
-
path: "/:organizationId/reservations",
|
|
90
|
-
pathParams: OrganizationParams,
|
|
91
|
-
query: PaginationQuerySchema,
|
|
92
|
-
responses: {
|
|
93
|
-
200: z.object({
|
|
94
|
-
list: z.array(ReservationSchema),
|
|
95
|
-
meta: PaginationMetaSchema,
|
|
96
|
-
}),
|
|
97
|
-
400: ErrorSchema,
|
|
98
|
-
401: ErrorSchema,
|
|
99
|
-
500: ErrorSchema,
|
|
100
|
-
},
|
|
101
|
-
summary: "Get Reservations",
|
|
102
|
-
tags: ["Reservation"],
|
|
103
|
-
});
|
|
104
|
-
const getUserReservationsRoute = createApiRoute({
|
|
105
|
-
description: "Get all reservations for a user",
|
|
106
|
-
headers: HeaderSchema,
|
|
107
|
-
method: "GET",
|
|
108
|
-
operationId: "getUserReservations",
|
|
109
|
-
path: "/:organizationId/reservations/user/:userId",
|
|
110
|
-
pathParams: userReservationParams,
|
|
111
|
-
responses: {
|
|
112
|
-
200: z.array(ReservationSchema),
|
|
113
|
-
400: ErrorSchema,
|
|
114
|
-
401: ErrorSchema,
|
|
115
|
-
404: ErrorSchema,
|
|
116
|
-
500: ErrorSchema,
|
|
117
|
-
},
|
|
118
|
-
summary: "Get User Reservations",
|
|
119
|
-
tags: ["Reservation"],
|
|
120
|
-
});
|
|
121
|
-
const updateReservationStatusRoute = createApiRoute({
|
|
122
|
-
body: z.object({}).optional(),
|
|
123
|
-
bodyRequired: false,
|
|
124
|
-
description: "Update the status of a reservation",
|
|
125
|
-
headers: HeaderSchema,
|
|
126
|
-
method: "PATCH",
|
|
127
|
-
operationId: "updateReservationStatus",
|
|
128
|
-
path: "/:organizationId/reservations/:reservationId/:operation",
|
|
129
|
-
pathParams: updateReservationStatusParams,
|
|
130
|
-
responses: {
|
|
131
|
-
200: ReservationSchema,
|
|
132
|
-
400: ErrorSchema,
|
|
133
|
-
401: ErrorSchema,
|
|
134
|
-
404: ErrorSchema,
|
|
135
|
-
500: ErrorSchema,
|
|
136
|
-
},
|
|
137
|
-
summary: "Update Reservation Status",
|
|
138
|
-
tags: ["Reservation"],
|
|
139
|
-
});
|
|
140
|
-
const deleteReservationRoute = createApiRoute({
|
|
141
|
-
body: z.object({}).optional(),
|
|
142
|
-
bodyRequired: false,
|
|
143
|
-
description: "Delete a reservation",
|
|
144
|
-
headers: HeaderSchema,
|
|
145
|
-
method: "DELETE",
|
|
146
|
-
operationId: "deleteReservation",
|
|
147
|
-
path: "/:organizationId/reservations/:reservationId",
|
|
148
|
-
pathParams: reservationParams,
|
|
149
|
-
responses: {
|
|
150
|
-
204: null,
|
|
151
|
-
400: ErrorSchema,
|
|
152
|
-
401: ErrorSchema,
|
|
153
|
-
404: ErrorSchema,
|
|
154
|
-
500: ErrorSchema,
|
|
155
|
-
},
|
|
156
|
-
summary: "Delete Reservation",
|
|
157
|
-
tags: ["Reservation"],
|
|
158
|
-
});
|
|
159
|
-
export const reservationRoute = {
|
|
160
|
-
createReservation: createReservationRoute,
|
|
161
|
-
getReservation: getReservationRoute,
|
|
162
|
-
getReservations: getReservationsRoute,
|
|
163
|
-
getUserReservations: getUserReservationsRoute,
|
|
164
|
-
updateReservationStatus: updateReservationStatusRoute,
|
|
165
|
-
deleteReservation: deleteReservationRoute,
|
|
166
|
-
};
|
|
167
|
-
//# sourceMappingURL=reservation.route.js.map
|
|
1
|
+
import{z as a}from"@hono/zod-openapi";import{createApiRoute as t}from"../../core/hono/hono";import{CreateReservationSchema as i,ErrorSchema as e,HeaderSchema as r,OrganizationParams as n,PaginationMetaSchema as p,PaginationQuerySchema as d,ReservationSchema as o}from"../../schemas";const s=a.object({organizationId:a.string().openapi({description:"Organization ID",example:"clj1234567890abcdef",param:{in:"path",name:"organizationId"}}),reservationId:a.string().openapi({description:"Reservation ID",example:"clj1234567890abcdef",param:{in:"path",name:"reservationId"}})}),m=a.object({organizationId:a.string().openapi({description:"Organization ID",example:"clj1234567890abcdef",param:{in:"path",name:"organizationId"}}),userId:a.string().openapi({description:"User ID",example:"clj1234567890abcdef",param:{in:"path",name:"userId"}})}),v=s.extend({operation:a.enum(["accept","cancel"]).openapi({description:"Operation",example:"accept",param:{in:"path",name:"operation"}})}),c=t({body:i,description:"Create a new reservation",headers:r,method:"POST",operationId:"createReservation",path:"/:organizationId/reservations",pathParams:n,responses:{201:o,400:e,401:e,500:e},summary:"Create Reservation",tags:["Reservation"]}),R=t({description:"Get a specific reservation by ID",headers:r,method:"GET",operationId:"getReservation",path:"/:organizationId/reservations/:reservationId",pathParams:s,responses:{200:o,400:e,401:e,404:e,500:e},summary:"Get Reservation",tags:["Reservation"]}),h=t({description:"Get all reservations for an organization",headers:r,method:"GET",operationId:"getReservations",path:"/:organizationId/reservations",pathParams:n,query:d,responses:{200:a.object({list:a.array(o),meta:p}),400:e,401:e,500:e},summary:"Get Reservations",tags:["Reservation"]}),u=t({description:"Get all reservations for a user",headers:r,method:"GET",operationId:"getUserReservations",path:"/:organizationId/reservations/user/:userId",pathParams:m,responses:{200:a.array(o),400:e,401:e,404:e,500:e},summary:"Get User Reservations",tags:["Reservation"]}),g=t({body:a.object({}).optional(),bodyRequired:!1,description:"Update the status of a reservation",headers:r,method:"PATCH",operationId:"updateReservationStatus",path:"/:organizationId/reservations/:reservationId/:operation",pathParams:v,responses:{200:o,400:e,401:e,404:e,500:e},summary:"Update Reservation Status",tags:["Reservation"]}),I=t({body:a.object({}).optional(),bodyRequired:!1,description:"Delete a reservation",headers:r,method:"DELETE",operationId:"deleteReservation",path:"/:organizationId/reservations/:reservationId",pathParams:s,responses:{204:null,400:e,401:e,404:e,500:e},summary:"Delete Reservation",tags:["Reservation"]});export const reservationRoute={createReservation:c,getReservation:R,getReservations:h,getUserReservations:u,updateReservationStatus:g,deleteReservation:I};
|
|
@@ -1,51 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { requiredNumber } from "../../schemas/number.schema";
|
|
3
|
-
export const ReservationSchema = z
|
|
4
|
-
.object({
|
|
5
|
-
id: z.string().openapi({
|
|
6
|
-
description: "Unique identifier for the order",
|
|
7
|
-
example: "clj1234567890abcdef",
|
|
8
|
-
}),
|
|
9
|
-
firstname: z.string().openapi({
|
|
10
|
-
description: "Customer's first name",
|
|
11
|
-
example: "John",
|
|
12
|
-
}),
|
|
13
|
-
lastname: z.string().openapi({
|
|
14
|
-
description: "Customer's last name",
|
|
15
|
-
example: "Doe",
|
|
16
|
-
}),
|
|
17
|
-
guests: requiredNumber,
|
|
18
|
-
phone: z.string().openapi({
|
|
19
|
-
description: "Customer's phone number",
|
|
20
|
-
example: "+1234567890",
|
|
21
|
-
}),
|
|
22
|
-
date: z.coerce.date().openapi({
|
|
23
|
-
description: "Reservation date and time",
|
|
24
|
-
example: "2023-06-14T16:20:00Z",
|
|
25
|
-
}),
|
|
26
|
-
referenceId: z.string().openapi({
|
|
27
|
-
description: "External reference ID for the order",
|
|
28
|
-
example: "ORD-12345",
|
|
29
|
-
}),
|
|
30
|
-
acceptedAt: z.date().nullable().optional().openapi({
|
|
31
|
-
description: "Date when the order was accepted",
|
|
32
|
-
example: "2023-06-15T14:30:00Z",
|
|
33
|
-
}),
|
|
34
|
-
cancelledAt: z.date().nullable().optional().openapi({
|
|
35
|
-
description: "Date when the order was cancelled",
|
|
36
|
-
example: "2023-06-14T16:20:00Z",
|
|
37
|
-
}),
|
|
38
|
-
createdAt: z.date().nullable().optional().openapi({
|
|
39
|
-
description: "Date when the order was created",
|
|
40
|
-
example: "2023-06-14T16:20:00Z",
|
|
41
|
-
}),
|
|
42
|
-
})
|
|
43
|
-
.openapi("Reservation");
|
|
44
|
-
export const CreateReservationSchema = ReservationSchema.pick({
|
|
45
|
-
firstname: true,
|
|
46
|
-
lastname: true,
|
|
47
|
-
guests: true,
|
|
48
|
-
phone: true,
|
|
49
|
-
date: true,
|
|
50
|
-
}).openapi("CreateReservation");
|
|
51
|
-
//# sourceMappingURL=reservation.schema.js.map
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";import{requiredNumber as t}from"../../schemas/number.schema";export const ReservationSchema=e.object({id:e.string().openapi({description:"Unique identifier for the order",example:"clj1234567890abcdef"}),firstname:e.string().openapi({description:"Customer's first name",example:"John"}),lastname:e.string().openapi({description:"Customer's last name",example:"Doe"}),guests:t,phone:e.string().openapi({description:"Customer's phone number",example:"+1234567890"}),date:e.coerce.date().openapi({description:"Reservation date and time",example:"2023-06-14T16:20:00Z"}),referenceId:e.string().openapi({description:"External reference ID for the order",example:"ORD-12345"}),acceptedAt:e.date().nullable().optional().openapi({description:"Date when the order was accepted",example:"2023-06-15T14:30:00Z"}),cancelledAt:e.date().nullable().optional().openapi({description:"Date when the order was cancelled",example:"2023-06-14T16:20:00Z"}),createdAt:e.date().nullable().optional().openapi({description:"Date when the order was created",example:"2023-06-14T16:20:00Z"})}).openapi("Reservation"),CreateReservationSchema=ReservationSchema.pick({firstname:!0,lastname:!0,guests:!0,phone:!0,date:!0}).openapi("CreateReservation");
|