* Start by moving what we have to _templates * WIP * WIP * Add create/edit/delete template commands * Type fixes cli Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: zomars <zomars@me.com>
20 lines
499 B
TypeScript
20 lines
499 B
TypeScript
export function DynamicComponent<T extends Record<string, any>>(props: {
|
|
componentMap: T;
|
|
slug: string;
|
|
wrapperClassName?: string;
|
|
}) {
|
|
const { componentMap, slug, ...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={props.wrapperClassName || ""}>
|
|
<Component {...rest} />
|
|
</div>
|
|
);
|
|
}
|