2024-03-26 05:13:57 +08:00
|
|
|
import React from 'react';
|
2024-02-19 18:59:45 +08:00
|
|
|
import * as Styled from './styles';
|
|
|
|
import { GenericComponentProps } from './types';
|
|
|
|
import GenericComponentItem from './generic-component-item/component';
|
|
|
|
|
|
|
|
const GenericComponentContent: React.FC<GenericComponentProps> = ({
|
|
|
|
isResizing,
|
2024-03-26 05:13:57 +08:00
|
|
|
genericComponentLayoutInformation,
|
2024-02-19 18:59:45 +08:00
|
|
|
renderFunctionComponents,
|
2024-03-26 05:13:57 +08:00
|
|
|
genericComponentId,
|
2024-02-19 18:59:45 +08:00
|
|
|
}) => {
|
|
|
|
const {
|
|
|
|
height,
|
|
|
|
width,
|
|
|
|
top,
|
|
|
|
left,
|
|
|
|
right,
|
2024-03-26 05:13:57 +08:00
|
|
|
} = genericComponentLayoutInformation;
|
2024-02-19 18:59:45 +08:00
|
|
|
|
|
|
|
const isMinimized = width === 0 && height === 0;
|
|
|
|
|
2024-03-26 05:13:57 +08:00
|
|
|
const componentToRender = renderFunctionComponents.filter((g) => genericComponentId === g.id);
|
2024-02-19 18:59:45 +08:00
|
|
|
return (
|
|
|
|
<Styled.Container
|
|
|
|
style={{
|
|
|
|
height,
|
|
|
|
width,
|
|
|
|
top,
|
|
|
|
left,
|
|
|
|
right,
|
|
|
|
}}
|
|
|
|
isResizing={isResizing}
|
|
|
|
isMinimized={isMinimized}
|
|
|
|
>
|
2024-03-26 05:13:57 +08:00
|
|
|
<GenericComponentItem
|
|
|
|
key={componentToRender[0]?.id}
|
|
|
|
renderFunction={componentToRender[0]?.contentFunction}
|
|
|
|
/>
|
2024-02-19 18:59:45 +08:00
|
|
|
</Styled.Container>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default GenericComponentContent;
|