@@ -18,7 +18,7 @@ import { RowWithTextField } from '@/lib/Layout';
1818import { ProgressCircle } from '@/lib/ProgressCircle' ;
1919import { TextField } from '@/lib/TextField' ;
2020import { useRouter } from 'next/navigation' ;
21- import { useCallback , useEffect , useMemo , useState } from 'react' ;
21+ import React , { useEffect , useMemo , useState } from 'react' ;
2222import { ToastContainer } from 'react-toastify' ;
2323import TablePicker from '../../create/cdc/tablemapping' ;
2424import {
@@ -37,7 +37,7 @@ import {
3737} from '../styles/edit.styles' ;
3838
3939type EditMirrorProps = {
40- params : { mirrorId : string } ;
40+ params : Promise < { mirrorId : string } > ;
4141} ;
4242
4343const defaultBatchSize = blankCDCSetting . maxBatchSize ;
@@ -51,7 +51,8 @@ const defaultSnapshotMaxParallelWorkers =
5151const defaultSnapshotNumTablesInParallel =
5252 blankCDCSetting . snapshotNumTablesInParallel ;
5353
54- export default function EditMirror ( { params : { mirrorId } } : EditMirrorProps ) {
54+ export default function EditMirror ( { params } : EditMirrorProps ) {
55+ const { mirrorId } = React . use ( params ) ;
5556 const theme = useTheme ( ) ;
5657 const [ rows , setRows ] = useState < TableMapRow [ ] > ( [ ] ) ;
5758 const [ loading , setLoading ] = useState ( false ) ;
@@ -71,41 +72,47 @@ export default function EditMirror({ params: { mirrorId } }: EditMirrorProps) {
7172 } ) ;
7273 const { push } = useRouter ( ) ;
7374
74- const fetchStateAndUpdateDeps = useCallback ( async ( ) => {
75- const res = await getMirrorState ( mirrorId ) ;
76- setMirrorState ( res ) ;
75+ useEffect ( ( ) => {
76+ const fetchStateAndUpdateDeps = async ( ) => {
77+ try {
78+ const res = await getMirrorState ( mirrorId ) ;
79+ setMirrorState ( res ) ;
7780
78- setConfig ( {
79- batchSize :
80- ( res as MirrorStatusResponse ) . cdcStatus ?. config ?. maxBatchSize ||
81- defaultBatchSize ,
82- idleTimeout :
83- ( res as MirrorStatusResponse ) . cdcStatus ?. config ?. idleTimeoutSeconds ||
84- defaultIdleTimeout ,
85- additionalTables : [ ] ,
86- removedTables : [ ] ,
87- numberOfSyncs : 0 ,
88- updatedEnv : { } ,
89- snapshotNumRowsPerPartition :
90- ( res as MirrorStatusResponse ) . cdcStatus ?. config
91- ?. snapshotNumRowsPerPartition || defaultSnapshotNumRowsPerPartition ,
92- snapshotNumPartitionsOverride :
93- ( res as MirrorStatusResponse ) . cdcStatus ?. config
94- ?. snapshotNumPartitionsOverride ||
95- defaultSnapshotNumPartitionsOverride ,
96- snapshotMaxParallelWorkers :
97- ( res as MirrorStatusResponse ) . cdcStatus ?. config
98- ?. snapshotMaxParallelWorkers || defaultSnapshotMaxParallelWorkers ,
99- snapshotNumTablesInParallel :
100- ( res as MirrorStatusResponse ) . cdcStatus ?. config
101- ?. snapshotNumTablesInParallel || defaultSnapshotNumTablesInParallel ,
102- skipInitialSnapshotForTableAdditions : false ,
103- } ) ;
104- } , [ mirrorId ] ) ;
81+ setConfig ( {
82+ batchSize :
83+ ( res as MirrorStatusResponse ) . cdcStatus ?. config ?. maxBatchSize ||
84+ defaultBatchSize ,
85+ idleTimeout :
86+ ( res as MirrorStatusResponse ) . cdcStatus ?. config
87+ ?. idleTimeoutSeconds || defaultIdleTimeout ,
88+ additionalTables : [ ] ,
89+ removedTables : [ ] ,
90+ numberOfSyncs : 0 ,
91+ updatedEnv : { } ,
92+ snapshotNumRowsPerPartition :
93+ ( res as MirrorStatusResponse ) . cdcStatus ?. config
94+ ?. snapshotNumRowsPerPartition ||
95+ defaultSnapshotNumRowsPerPartition ,
96+ snapshotNumPartitionsOverride :
97+ ( res as MirrorStatusResponse ) . cdcStatus ?. config
98+ ?. snapshotNumPartitionsOverride ||
99+ defaultSnapshotNumPartitionsOverride ,
100+ snapshotMaxParallelWorkers :
101+ ( res as MirrorStatusResponse ) . cdcStatus ?. config
102+ ?. snapshotMaxParallelWorkers || defaultSnapshotMaxParallelWorkers ,
103+ snapshotNumTablesInParallel :
104+ ( res as MirrorStatusResponse ) . cdcStatus ?. config
105+ ?. snapshotNumTablesInParallel ||
106+ defaultSnapshotNumTablesInParallel ,
107+ skipInitialSnapshotForTableAdditions : false ,
108+ } ) ;
109+ } catch ( error ) {
110+ notifyErr ( 'Failed to fetch mirror state' ) ;
111+ }
112+ } ;
105113
106- useEffect ( ( ) => {
107114 fetchStateAndUpdateDeps ( ) ;
108- } , [ fetchStateAndUpdateDeps ] ) ;
115+ } , [ mirrorId ] ) ;
109116
110117 const alreadySelectedTablesMapping : Map < string , TableMapping [ ] > =
111118 useMemo ( ( ) => {
0 commit comments