dynamic link description on availability page (#4323)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Syed Ali Shahbaz 2022-09-09 14:10:58 +05:30 committed by GitHub
parent 99f11dcc5c
commit 1c46370572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,13 @@
export type EventTypeDescriptionSafeProps = {
eventType: { description: string | null };
eventType: { description: string | null; isDynamic?: boolean };
};
export const EventTypeDescriptionSafeHTML = ({ eventType }: EventTypeDescriptionSafeProps) => {
const props: JSX.IntrinsicElements["div"] = { suppressHydrationWarning: true };
// @ts-expect-error: @see packages/prisma/middleware/eventTypeDescriptionParseAndSanitize.ts
if (eventType.description) props.dangerouslySetInnerHTML = { __html: eventType.descriptionAsSafeHTML };
// Dynamic link description is not set/pulled from the DB, hence we can allow it here as is
if (eventType.isDynamic) props.dangerouslySetInnerHTML = { __html: eventType.description || "" };
return <div {...props} />;
};