feat(MED-48): improvements
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { MontonioOrderToken } from "@/app/home/(user)/_components/cart/types";
|
||||
import { loadCurrentUserAccount } from "@/app/home/(user)/_lib/server/load-user-account";
|
||||
import { placeOrder } from "@lib/data/cart";
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { z } from "zod";
|
||||
import { MontonioOrderToken } from "@/app/home/(user)/_components/cart/types";
|
||||
import { loadCurrentUserAccount } from "@/app/home/(user)/_lib/server/load-user-account";
|
||||
import { listProductTypes } from "@lib/data/products";
|
||||
import { placeOrder } from "@lib/data/cart";
|
||||
import { createI18nServerInstance } from "~/lib/i18n/i18n.server";
|
||||
|
||||
const emailSender = process.env.EMAIL_SENDER;
|
||||
@@ -70,11 +71,13 @@ const handleOrderToken = async (orderToken: string) => {
|
||||
if (!cartId) {
|
||||
throw new Error("Cart ID not found");
|
||||
}
|
||||
const { productTypes } = await listProductTypes();
|
||||
const analysisPackagesType = productTypes.find(({ metadata }) => metadata?.handle === 'analysis-packages');
|
||||
const { order } = await placeOrder(cartId, { revalidateCacheTags: true });
|
||||
return {
|
||||
email: order.email,
|
||||
partnerLocationName: order.metadata?.partner_location_name as string ?? '',
|
||||
analysisPackageName: order.items?.[0]?.title ?? '',
|
||||
analysisPackageName: order.items?.find(item => item.product_type_id === analysisPackagesType?.id)?.title ?? '',
|
||||
};
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to place order, message=${error}`);
|
||||
@@ -102,7 +105,7 @@ export async function GET(request: Request) {
|
||||
|
||||
const { email, partnerLocationName, analysisPackageName } = orderResult;
|
||||
const personName = account.name;
|
||||
if (email) {
|
||||
if (email && analysisPackageName && partnerLocationName) {
|
||||
await sendEmail({ email, analysisPackageName, personName, partnerLocationName, language });
|
||||
}
|
||||
return Response.redirect(new URL('/home/order', baseUrl))
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
"clsx": "^2.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"fast-xml-parser": "^5.2.5",
|
||||
"isikukood": "3.1.7",
|
||||
"jsonwebtoken": "9.0.2",
|
||||
"lodash": "^4.17.21",
|
||||
"lucide-react": "^0.510.0",
|
||||
|
||||
@@ -32,7 +32,9 @@ export async function renderSynlabAnalysisPackageEmail(props: Props) {
|
||||
});
|
||||
|
||||
const previewText = t(`${namespace}:previewText`);
|
||||
const subject = t(`${namespace}:subject`);
|
||||
const subject = t(`${namespace}:subject`, {
|
||||
analysisPackageName: props.analysisPackageName,
|
||||
});
|
||||
|
||||
const heading = t(`${namespace}:heading`, {
|
||||
analysisPackageName: props.analysisPackageName,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"subject": "Your Synlab order has been placed",
|
||||
"previewText": "Your Synlab order has been placed",
|
||||
"heading": "Your Synlab order has been placed",
|
||||
"subject": "Your Synlab order has been placed - {{analysisPackageName}}",
|
||||
"previewText": "Your Synlab order has been placed - {{analysisPackageName}}",
|
||||
"heading": "Your Synlab order has been placed - {{analysisPackageName}}",
|
||||
"hello": "Hello {{personName}},",
|
||||
"lines1": "The order for {{analysisPackageName}} analysis package has been sent to the lab. Please go to the lab to collect the sample: SYNLAB - {{partnerLocationName}}",
|
||||
"lines2": "<i>If you are unable to go to the lab to collect the sample, you can go to any other suitable collection point - <a href=\"https://medreport.ee/et/verevotupunktid\">view locations and opening hours</a>.</i>",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"subject": "Teie SYNLAB tellimus on kinnitatud",
|
||||
"subject": "Teie SYNLAB tellimus on kinnitatud - {{analysisPackageName}}",
|
||||
"previewText": "Teie SYNLAB tellimus on kinnitatud - {{analysisPackageName}}",
|
||||
"heading": "Teie SYNLAB tellimus on kinnitatud - {{analysisPackageName}}",
|
||||
"hello": "Tere {{personName}},",
|
||||
|
||||
1758
pnpm-lock.yaml
generated
1758
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user