app/src/utils/tldraw/cc-base/cc-graph/CCJournalNodeShapeUtil.tsx
kcar 61ef95a35e fix(nav): register Journal/Planner shapes, fix headerColor crash, enable academic week expansion
Bugs fixed:
- 'cc-teacher-timetable-node' missing from NODE_TYPE_THEMES caused
  Cannot read properties of undefined (reading 'headerColor') crash
  when clicking My Timetable
- 'cc-journal-node' and 'cc-planner-node' had no shape utils registered,
  causing 'No shape util found for type' error on Journal/Planner click
- Added null safety (?? fallback) to getNodeTheme to prevent future crashes
  from any other unmapped type
- Removed AcademicWeek from canExpand exclusion so weeks can be expanded
  to show individual academic days

Added:
- CCJournalNodeShapeUtil and CCPlannerNodeShapeUtil (stub shapes)
- CCJournalNodeProps and CCPlannerNodeProps types
- Journal/Planner added to CCNodeTypes, ccGraphShapeProps, NODE_TYPE_THEMES
- 'cc-department-structure-node' mapping added to NODE_TYPE_THEMES

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 10:55:40 +01:00

37 lines
1.3 KiB
TypeScript

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>
)
}
}