2dbc73c75b
* [CAL-1517] fix all Typescript warnings * solve conflicts * Update stripeCheckoutSession.handler.ts Parse is a guard, so even though the variable is unused the parse itself is needed. * Update ToolbarPlugin.tsx Don't change dependency tree --------- Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>
21 lines
595 B
TypeScript
21 lines
595 B
TypeScript
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
export function DynamicComponent<T extends Record<string, React.ComponentType<any>>>(props: {
|
|
componentMap: T;
|
|
slug: string;
|
|
wrapperClassName?: string;
|
|
}) {
|
|
const { componentMap, slug, wrapperClassName, ...rest } = props;
|
|
const dirName = slug === "stripe" ? "stripepayment" : slug;
|
|
|
|
// There can be apps with no matching component
|
|
if (!componentMap[slug]) return null;
|
|
|
|
const Component = componentMap[dirName];
|
|
|
|
return (
|
|
<div className={wrapperClassName || ""}>
|
|
<Component {...rest} />
|
|
</div>
|
|
);
|
|
}
|