|
1 | | -import React from 'react'; |
| 1 | +import React, { useState, useEffect } from 'react'; |
2 | 2 | import './App.css'; |
3 | 3 | import { useFHIRPathUI } from './hooks'; |
4 | 4 | import Editor from '@monaco-editor/react'; |
5 | 5 | import { Allotment } from "allotment"; |
6 | 6 | import "allotment/dist/style.css"; |
7 | | -import { Play, ShareFat, FileArrowDown } from "@phosphor-icons/react"; |
| 7 | +import { Play, ShareFat, FileArrowDown, Gear, Copy, Info } from "@phosphor-icons/react"; |
8 | 8 | import Loader from './components/loader'; |
9 | 9 | import logo from './assets/logo.png'; |
10 | 10 | import { ToastContainer } from 'react-toastify'; |
11 | 11 | import 'react-toastify/dist/ReactToastify.css'; |
12 | 12 | import { ResultOutput } from './components/ResultOutput'; |
13 | 13 | import { WeeklyPopup } from './components/WeeklyPopup'; |
| 14 | +import { DrawerButton } from './components/DrawerButton'; |
| 15 | +import { SettingsContainer } from './containers/Settings' |
| 16 | +import { CredentialsContainer } from './containers/Credentials' |
| 17 | + |
14 | 18 |
|
15 | 19 | const App: React.FC = () => { |
16 | | - const { url, handleUrlChange, handleFetch, |
17 | | - resource, expression, setExpression, setResource, |
18 | | - handleExecute, result, handleShare, isLoading, isExecuteActive, isGetResourceActive, isShareActive } = useFHIRPathUI(); |
| 20 | + const { url, handleUrlChange, handleFetch, |
| 21 | + resource, expression, setExpression, setResource, |
| 22 | + handleExecute, result, handleShare, isLoading, isExecuteActive, isGetResourceActive, isShareActive, handleShareResult, isShareResultActive } = useFHIRPathUI(); |
19 | 23 |
|
20 | | - return ( |
21 | | - <div className="App"> |
22 | | - {isLoading ? <Loader /> : null} |
23 | | - <WeeklyPopup /> |
24 | | - <div className='header'> |
25 | | - <img src={logo} alt="Logo" className='logo' /> |
26 | | - <div className='searchBlock'> |
27 | | - <input className="input" type="url" value={url} onChange={handleUrlChange} placeholder='You can paste the URL to get the FHIR Resource' /> |
28 | | - </div> |
29 | | - <div className="buttonsBlock"> |
30 | | - <button onClick={() => handleFetch(url)} disabled={!isGetResourceActive}><FileArrowDown fontSize={24} /></button> |
31 | | - <button onClick={() => handleExecute(resource, expression)} disabled={!isExecuteActive}><Play fontSize={24} /></button> |
32 | | - <button onClick={handleShare} disabled={!isShareActive}><ShareFat fontSize={24} /></button> |
| 24 | + return ( |
| 25 | + <div className="App"> |
| 26 | + {isLoading ? <Loader /> : null} |
| 27 | + <WeeklyPopup /> |
| 28 | + <div className='header'> |
| 29 | + <img src={logo} alt="Logo" className='logo' /> |
| 30 | + <div className='searchBlock'> |
| 31 | + <input className="input" type="url" value={url} onChange={handleUrlChange} placeholder='You can paste the URL to get the FHIR Resource' /> |
| 32 | + </div> |
| 33 | + <div className="buttonsBlock"> |
| 34 | + <button onClick={() => handleFetch(url)} disabled={!isGetResourceActive}><FileArrowDown fontSize={24} /></button> |
| 35 | + <button onClick={() => handleExecute(resource, expression)} disabled={!isExecuteActive}><Play fontSize={24} /></button> |
| 36 | + <button onClick={handleShare} disabled={!isShareActive}><ShareFat fontSize={24} /></button> |
| 37 | + <button onClick={handleShareResult} disabled={!isShareResultActive}><Copy fontSize={24} /></button> |
| 38 | + <DrawerButton content={<SettingsContainer />} button={<button><Gear fontSize={24} /></button>} title="Settings" size="large" /> |
| 39 | + <DrawerButton content={<CredentialsContainer />} button={<button><Info fontSize={24} /></button>} title="Credentials" /> |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + <div className='editor'> |
| 43 | + <Allotment defaultSizes={[550, 250]}> |
| 44 | + <div className='editorWrapper'> |
| 45 | + <Editor height="100vh" defaultLanguage="json" value={resource} onChange={(value) => setResource(value as string)} options={{ formatOnPaste: true, formatOnType: true }} /> |
| 46 | + </div> |
| 47 | + <div style={{ height: '100vh' }}> |
| 48 | + <Allotment defaultSizes={[100, 300]} vertical> |
| 49 | + <div className='editorWrapper'> |
| 50 | + <Editor defaultLanguage="ruby" value={expression} onChange={(value) => setExpression(value as string)} options={{ |
| 51 | + formatOnPaste: true, formatOnType: true, minimap: { |
| 52 | + enabled: false, |
| 53 | + }, |
| 54 | + }} /> |
| 55 | + </div> |
| 56 | + <ResultOutput resultItems={result} /> |
| 57 | + </Allotment> |
| 58 | + </div> |
| 59 | + </Allotment> |
| 60 | + </div> |
| 61 | + <ToastContainer /> |
33 | 62 | </div> |
34 | | - </div> |
35 | | - <div className='editor'> |
36 | | - <Allotment defaultSizes={[550, 250]}> |
37 | | - <div className='editorWrapper'> |
38 | | - <Editor height="100vh" defaultLanguage="json" value={resource} onChange={(value) => setResource(value as string)} options={{ formatOnPaste: true, formatOnType: true }} /> |
39 | | - </div> |
40 | | - <div style={{ height: '100vh' }}> |
41 | | - <Allotment defaultSizes={[100, 300]} vertical> |
42 | | - <div className='editorWrapper'> |
43 | | - <Editor defaultLanguage="ruby" value={expression} onChange={(value) => setExpression(value as string)} options={{ |
44 | | - formatOnPaste: true, formatOnType: true, minimap: { |
45 | | - enabled: false, |
46 | | - }, |
47 | | - }} /> |
48 | | - </div> |
49 | | - <ResultOutput resultItems={result} /> |
50 | | - </Allotment> |
51 | | - </div> |
52 | | - </Allotment> |
53 | | - </div> |
54 | | - <ToastContainer /> |
55 | | - </div> |
56 | | - ); |
| 63 | + ); |
57 | 64 | }; |
58 | 65 |
|
59 | 66 | export default App; |
0 commit comments