import { CCBaseShapeUtil } from '../CCBaseShapeUtil'
import { CCBaseShape } from '../cc-types'
import { ccGraphShapeProps, getDefaultCCJournalNodeProps } from './cc-graph-props'
import { getNodeStyles, NODE_THEMES, NODE_TYPE_THEMES } from './cc-graph-styles'
import { CCJournalNodeProps } from './cc-graph-types'

export interface CCJournalNodeShape extends CCBaseShape {
  type: 'cc-journal-node'
  props: CCJournalNodeProps
}

export class CCJournalNodeShapeUtil extends CCBaseShapeUtil<CCJournalNodeShape> {
  static type = 'cc-journal-node' as const
  static props = ccGraphShapeProps['cc-journal-node']

  getDefaultProps(): CCJournalNodeShape['props'] {
    const defaultProps = getDefaultCCJournalNodeProps()
    const theme = NODE_THEMES[NODE_TYPE_THEMES[CCJournalNodeShapeUtil.type]] ?? NODE_THEMES.resource
    return {
      ...defaultProps,
      headerColor: theme.headerColor,
    }
  }

  DefaultComponent = () => null

  renderContent = (shape: CCJournalNodeShape) => {
    const styles = getNodeStyles(shape.type)
    return (
      <div style={styles.container}>
        <div style={{ ...styles.header, color: shape.props.headerColor }}>Journal</div>
        <div style={{ fontSize: 11, color: 'var(--color-text-2)' }}>Personal teaching journal</div>
      </div>
    )
  }
}
