@@ -4,6 +4,7 @@ import { useEditorStore } from "./editorStore";
44import { ShareDialog } from "./ShareDialog" ;
55import { LoadExternalDialog } from "./LoadExternalDialog" ;
66import { getTranslations } from "./translations" ;
7+ import { useJsonStore } from "./useJsonStore" ;
78
89interface EditorDialogsProps {
910 defaultLanguage ?: string ;
@@ -15,14 +16,14 @@ export const EditorDialogs = memo(({ defaultLanguage = "en", jsonStore = "https:
1516 const settings = useEditorStore ( state => state . settings ) ;
1617 const helpOpen = useEditorStore ( state => state . helpOpen ) ;
1718 const pendingExternalId = useEditorStore ( state => state . pendingExternalId ) ;
18-
19+ const [ getFromJsonStore ] = useJsonStore ( ) ;
20+
1921 // Get actions from store
2022 const setHelpOpen = useEditorStore ( state => state . setHelpOpen ) ;
2123 const setShareDialogOpen = useEditorStore ( state => state . setShareDialogOpen ) ;
2224 const setLoadExternalDialogOpen = useEditorStore ( state => state . setLoadExternalDialogOpen ) ;
2325 const setPendingExternalId = useEditorStore ( state => state . setPendingExternalId ) ;
2426 const getRoadmapData = useEditorStore ( state => state . getRoadmapData ) ;
25- const loadRoadmapData = useEditorStore ( state => state . loadRoadmapData ) ;
2627
2728 const language = settings ?. language || defaultLanguage ;
2829 const t = getTranslations ( language ) ;
@@ -38,19 +39,6 @@ export const EditorDialogs = memo(({ defaultLanguage = "en", jsonStore = "https:
3839 downloadAnchorNode . remove ( ) ;
3940 } ;
4041
41- const onLoadFromStore = async ( id : string ) => {
42- try {
43- const response = await fetch ( `${ jsonStore } /api/json/${ id } ` ) ;
44- if ( ! response . ok ) throw new Error ( "Failed to load from JSON store" ) ;
45- const data = await response . json ( ) ;
46- loadRoadmapData ( data ) ;
47- setLoadExternalDialogOpen ( false ) ;
48- setPendingExternalId ( null ) ;
49- } catch ( error ) {
50- console . error ( "Failed to load from JSON store" , error ) ;
51- }
52- } ;
53-
5442 const keyboardShortcuts = [
5543 { action : t . shortcuts . undo , shortcut : "Ctrl+Z" } ,
5644 { action : t . shortcuts . redo , shortcut : "Ctrl+Y or Ctrl+Shift+Z" } ,
@@ -121,7 +109,7 @@ export const EditorDialogs = memo(({ defaultLanguage = "en", jsonStore = "https:
121109 onDownloadCurrent = { onDownload }
122110 onReplace = { ( ) => {
123111 if ( pendingExternalId ) {
124- onLoadFromStore ( pendingExternalId ) ;
112+ getFromJsonStore ( pendingExternalId ) ;
125113 }
126114 } }
127115 />
0 commit comments