File size: 1,113 Bytes
07bbbbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
 * ConvertDBDialogWrapper Component
 * 
 * Wrapper component that manages state for ConvertDBDialog
 * This is needed because the dialog needs to maintain its own state
 * when shown imperatively via showEnhancedDialog
 */

import React, { useState } from 'react';
import { ConvertDBDialog, ConvertOptions } from './ConvertDBDialog';
import { MdxProfile } from '../types';

interface ConvertDBDialogWrapperProps {
  profile: MdxProfile;
  initialOptions: ConvertOptions;
  onOptionsReady: (options: ConvertOptions) => void;
  isProfileInUse?: boolean;
}

export const ConvertDBDialogWrapper: React.FC<ConvertDBDialogWrapperProps> = ({
  profile,
  initialOptions,
  onOptionsReady,
  isProfileInUse = false,
}) => {
  const [options, setOptions] = useState<ConvertOptions>(initialOptions);

  // Update parent with latest options whenever they change
  React.useEffect(() => {
    onOptionsReady(options);
  }, [options, onOptionsReady]);

  return (
    <ConvertDBDialog
      profile={profile}
      options={options}
      onOptionsChange={setOptions}
      isProfileInUse={isProfileInUse}
    />
  );
};