merge: R3 TypeScript fixes — cc-graph-shapes duplicates, CCGraphNavPanel, snapshotService, App.tsx simplification
This commit is contained in:
commit
cbff4deef2
@ -117,9 +117,9 @@ export class NavigationSnapshotService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
loadSnapshot(editor.store, snapshotCopy as Parameters<typeof loadSnapshot>[1]);
|
loadSnapshot(editor.store, snapshotCopy as any);
|
||||||
} else {
|
} else {
|
||||||
loadSnapshot(store, snapshotCopy as Parameters<typeof loadSnapshot>[1]);
|
loadSnapshot(store, snapshotCopy as any);
|
||||||
}
|
}
|
||||||
logger.debug('snapshot-service', '✅ Snapshot loaded successfully');
|
logger.debug('snapshot-service', '✅ Snapshot loaded successfully');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -35,7 +35,6 @@ import { CCTimetableLessonNodeShape, CCTimetableLessonNodeShapeUtil } from './CC
|
|||||||
import { CCPlannedLessonNodeShape, CCPlannedLessonNodeShapeUtil } from './CCPlannedLessonNodeShapeUtil'
|
import { CCPlannedLessonNodeShape, CCPlannedLessonNodeShapeUtil } from './CCPlannedLessonNodeShapeUtil'
|
||||||
import { CCDepartmentStructureNodeShape, CCDepartmentStructureNodeShapeUtil } from './CCDepartmentStructureNodeShapeUtil'
|
import { CCDepartmentStructureNodeShape, CCDepartmentStructureNodeShapeUtil } from './CCDepartmentStructureNodeShapeUtil'
|
||||||
import { CCUserTeacherTimetableNodeShape, CCUserTeacherTimetableNodeShapeUtil } from './CCUserTeacherTimetableNodeShapeUtil'
|
import { CCUserTeacherTimetableNodeShape, CCUserTeacherTimetableNodeShapeUtil } from './CCUserTeacherTimetableNodeShapeUtil'
|
||||||
import { CCTimetableLessonNodeShape, CCTimetableLessonNodeShapeUtil } from './CCTimetableLessonNodeShapeUtil'
|
|
||||||
|
|
||||||
// Create a const object with all node types
|
// Create a const object with all node types
|
||||||
export const NODE_SHAPE_TYPES = {
|
export const NODE_SHAPE_TYPES = {
|
||||||
@ -82,7 +81,7 @@ export const NODE_SHAPE_TYPES = {
|
|||||||
export type NodeShapeType = typeof NODE_SHAPE_TYPES[keyof typeof NODE_SHAPE_TYPES];
|
export type NodeShapeType = typeof NODE_SHAPE_TYPES[keyof typeof NODE_SHAPE_TYPES];
|
||||||
|
|
||||||
// Define AllNodeShapes as a union type of all shape types
|
// Define AllNodeShapes as a union type of all shape types
|
||||||
export type AllNodeShapes =
|
export type AllNodeShapes =
|
||||||
| CCUserNodeShape
|
| CCUserNodeShape
|
||||||
| CCTeacherNodeShape
|
| CCTeacherNodeShape
|
||||||
| CCStudentNodeShape
|
| CCStudentNodeShape
|
||||||
@ -118,8 +117,7 @@ export type AllNodeShapes =
|
|||||||
| CCTimetableLessonNodeShape
|
| CCTimetableLessonNodeShape
|
||||||
| CCPlannedLessonNodeShape
|
| CCPlannedLessonNodeShape
|
||||||
| CCDepartmentStructureNodeShape
|
| CCDepartmentStructureNodeShape
|
||||||
| CCUserTeacherTimetableNodeShape
|
| CCUserTeacherTimetableNodeShape;
|
||||||
| CCTimetableLessonNodeShape;
|
|
||||||
|
|
||||||
// Export all shape utils in an object for easy access
|
// Export all shape utils in an object for easy access
|
||||||
export const ShapeUtils = {
|
export const ShapeUtils = {
|
||||||
@ -159,17 +157,16 @@ export const ShapeUtils = {
|
|||||||
[CCPlannedLessonNodeShapeUtil.type]: CCPlannedLessonNodeShapeUtil,
|
[CCPlannedLessonNodeShapeUtil.type]: CCPlannedLessonNodeShapeUtil,
|
||||||
[CCDepartmentStructureNodeShapeUtil.type]: CCDepartmentStructureNodeShapeUtil,
|
[CCDepartmentStructureNodeShapeUtil.type]: CCDepartmentStructureNodeShapeUtil,
|
||||||
[CCUserTeacherTimetableNodeShapeUtil.type]: CCUserTeacherTimetableNodeShapeUtil,
|
[CCUserTeacherTimetableNodeShapeUtil.type]: CCUserTeacherTimetableNodeShapeUtil,
|
||||||
[CCTimetableLessonNodeShapeUtil.type]: CCTimetableLessonNodeShapeUtil,
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// Add a type guard to check if a shape is a valid node shape
|
// Add a type guard to check if a shape is a valid node shape
|
||||||
export const isValidNodeShape = (shape: TLShape): shape is AllNodeShapes => {
|
export const isValidNodeShape = (shape: TLShape): shape is AllNodeShapes => {
|
||||||
return shape &&
|
return shape &&
|
||||||
typeof shape.type === 'string' &&
|
typeof shape.type === 'string' &&
|
||||||
Object.values(NODE_SHAPE_TYPES).includes(shape.type as NodeShapeType);
|
Object.values(NODE_SHAPE_TYPES).includes(shape.type as NodeShapeType);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add a type guard to check if a type string is a valid node type
|
// Add a type guard to check if a type string is a valid node type
|
||||||
export const isValidNodeType = (type: string): type is NodeShapeType => {
|
export const isValidNodeType = (type: string): type is NodeShapeType => {
|
||||||
return Object.values(NODE_SHAPE_TYPES).includes(type as NodeShapeType);
|
return Object.values(NODE_SHAPE_TYPES).includes(type as NodeShapeType);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect, useCallback, createContext, useContext } from 'react';
|
import React, { useState, useEffect, useCallback, createContext, useContext, useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
Box, IconButton, CircularProgress, Collapse, Typography, Tooltip,
|
Box, IconButton, CircularProgress, Collapse, Typography, Tooltip,
|
||||||
ToggleButtonGroup, ToggleButton,
|
ToggleButtonGroup, ToggleButton,
|
||||||
@ -518,7 +518,7 @@ export function CCGraphNavPanel() {
|
|||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
setTree(data.tree);
|
setTree(data.tree);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('graph-nav-panel', 'Failed to load graph tree', err);
|
logger.error('graph-panel', 'Failed to load graph tree', err);
|
||||||
setError('Failed to load navigation tree');
|
setError('Failed to load navigation tree');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@ -650,12 +650,12 @@ export function CCGraphNavPanel() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleCalendarWizardComplete = useCallback(() => {
|
const handleCalendarWizardComplete = useCallback(() => {
|
||||||
logger.info('graph-nav-panel', 'School calendar setup complete');
|
logger.info('graph-panel', 'School calendar setup complete');
|
||||||
refreshAll();
|
refreshAll();
|
||||||
}, [refreshAll]);
|
}, [refreshAll]);
|
||||||
|
|
||||||
const handleTimetableWizardComplete = useCallback((timetableId: string) => {
|
const handleTimetableWizardComplete = useCallback((timetableId: string) => {
|
||||||
logger.info('graph-nav-panel', 'Teacher timetable setup complete', { timetableId });
|
logger.info('graph-panel', 'Teacher timetable setup complete', { timetableId });
|
||||||
refreshAll();
|
refreshAll();
|
||||||
}, [refreshAll]);
|
}, [refreshAll]);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user