* add analysis view with doctor summary * remove console.log, also return null if analysis data missing * replace orders table eye with button
93 lines
2.3 KiB
TypeScript
93 lines
2.3 KiB
TypeScript
import {
|
|
Body,
|
|
Head,
|
|
Html,
|
|
Preview,
|
|
Tailwind,
|
|
Text,
|
|
render,
|
|
} from '@react-email/components';
|
|
|
|
import { BodyStyle } from '../components/body-style';
|
|
import CommonFooter from '../components/common-footer';
|
|
import { EmailContent } from '../components/content';
|
|
import { EmailButton } from '../components/email-button';
|
|
import { EmailHeader } from '../components/header';
|
|
import { EmailHeading } from '../components/heading';
|
|
import { EmailWrapper } from '../components/wrapper';
|
|
import { initializeEmailI18n } from '../lib/i18n';
|
|
|
|
export async function renderDoctorSummaryReceivedEmail({
|
|
language,
|
|
recipientName,
|
|
orderNr,
|
|
analysisOrderId,
|
|
}: {
|
|
language?: string;
|
|
recipientName: string;
|
|
orderNr: string;
|
|
analysisOrderId: number;
|
|
}) {
|
|
const namespace = 'doctor-summary-received-email';
|
|
|
|
const { t } = await initializeEmailI18n({
|
|
language,
|
|
namespace: [namespace, 'common'],
|
|
});
|
|
|
|
const previewText = t(`${namespace}:previewText`, {
|
|
orderNr,
|
|
});
|
|
|
|
const subject = t(`${namespace}:subject`, {
|
|
orderNr,
|
|
});
|
|
|
|
const html = await render(
|
|
<Html>
|
|
<Head>
|
|
<BodyStyle />
|
|
</Head>
|
|
|
|
<Preview>{previewText}</Preview>
|
|
|
|
<Tailwind>
|
|
<Body>
|
|
<EmailWrapper>
|
|
<EmailHeader>
|
|
<EmailHeading>{previewText}</EmailHeading>
|
|
</EmailHeader>
|
|
|
|
<EmailContent>
|
|
<Text className="text-[16px] leading-[24px] text-[#242424]">
|
|
{t(`${namespace}:hello`, {
|
|
displayName: recipientName,
|
|
})}
|
|
</Text>
|
|
<Text className="text-[16px] leading-[24px] text-[#242424]">
|
|
{t(`${namespace}:summaryReceivedForOrder`, { orderNr })}
|
|
</Text>
|
|
|
|
<EmailButton
|
|
href={`${process.env.NEXT_PUBLIC_SITE_URL}/home/analysis-results/${analysisOrderId}`}
|
|
>
|
|
{t(`${namespace}:linkText`, { orderNr })}
|
|
</EmailButton>
|
|
<Text>
|
|
{t(`${namespace}:ifButtonDisabled`)}{' '}
|
|
{`${process.env.NEXT_PUBLIC_SITE_URL}/home/analysis-results/${analysisOrderId}`}
|
|
</Text>
|
|
<CommonFooter t={t} />
|
|
</EmailContent>
|
|
</EmailWrapper>
|
|
</Body>
|
|
</Tailwind>
|
|
</Html>,
|
|
);
|
|
|
|
return {
|
|
html,
|
|
subject,
|
|
};
|
|
}
|