-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathImportDialogProvider.tsx
34 lines (30 loc) · 1 KB
/
ImportDialogProvider.tsx
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
// SPDX-FileCopyrightText: Meta Platforms, Inc. and its affiliates
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0
import { useState } from 'react';
import { AllowedFrontendChannels } from '../../../shared/ipc-channels';
import { FileFormatInfo } from '../../../shared/shared-types';
import {
ShowImportDialogListener,
useIpcRenderer,
} from '../../util/use-ipc-renderer';
import { ImportDialog } from './ImportDialog';
export const ImportDialogProvider: React.FC = () => {
const [isOpen, setIsOpen] = useState<boolean>(false);
const [fileFormat, setFileFormat] = useState<FileFormatInfo>();
useIpcRenderer<ShowImportDialogListener>(
AllowedFrontendChannels.ImportFileShowDialog,
(_, fileFormat) => {
setFileFormat(fileFormat);
setIsOpen(true);
},
[],
);
return isOpen && fileFormat ? (
<ImportDialog
fileFormat={fileFormat}
closeDialog={() => setIsOpen(false)}
/>
) : undefined;
};