From e55e6613d25d022acedcdcbfd233ff5068bf5852 Mon Sep 17 00:00:00 2001 From: Amit Sharma <coutamit.s19@gmail.com> Date: Fri, 10 Mar 2023 06:46:27 +0000 Subject: [PATCH] Added env script for reach --- .gitpod.yml | 1 + apps/wrapper/src/App.js | 3 +-- .../src/components/GenericForm/index.js | 9 ++++---- .../components/GenericForm/index.module.css | 21 +++++++++---------- make-envs-for-react.sh | 1 + 5 files changed, 17 insertions(+), 18 deletions(-) create mode 100644 make-envs-for-react.sh diff --git a/.gitpod.yml b/.gitpod.yml index a5e31db..6e195f7 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -3,6 +3,7 @@ tasks: openMode: tab-after init: | bash install-node.sh + bash make-envs-for-react.sh nvm use 14 cd packages/enketo-express && pnpm i && pnpm i -g grunt gp sync-done setup diff --git a/apps/wrapper/src/App.js b/apps/wrapper/src/App.js index 3240c2e..cd87c16 100644 --- a/apps/wrapper/src/App.js +++ b/apps/wrapper/src/App.js @@ -2,7 +2,6 @@ import './App.css'; import React, { useState, useEffect } from 'react'; import GenericForm from './components/GenericForm'; - function App() { const [flows, setFlows] = useState([ { @@ -40,7 +39,7 @@ function App() { {flows?.map(el => <div className='workflowBtns' onClick={() => setSelectedFlow(el)}>{el.name}</div>)} </div> </> - : <GenericForm {...{ selectedFlow }} /> + : <GenericForm {...{ selectedFlow, setSelectedFlow}} /> } </div> diff --git a/apps/wrapper/src/components/GenericForm/index.js b/apps/wrapper/src/components/GenericForm/index.js index 025013c..99c290b 100644 --- a/apps/wrapper/src/components/GenericForm/index.js +++ b/apps/wrapper/src/components/GenericForm/index.js @@ -4,7 +4,7 @@ import styles from './index.module.css'; const GITPOD_URL = process.env.GITPOD_WORKSPACE_URL const GenericForm = (props) => { - const { selectedFlow } = props; + const { selectedFlow, setSelectedFlow } = props; const formSpec = require(`../../${selectedFlow.config}`); const [isFirst, setIsFirst] = useState(true); // Encode string method to URI @@ -14,6 +14,7 @@ const GenericForm = (props) => { const getFormURI = (form, ofsd, prefillSpec) => { console.log(form, ofsd, prefillSpec); + // return encodeURIComponent(`https://3006-samagradevelop-workflow-gkbrz650idv.ws-us89b.gitpod.io/prefill?form=${form}&onFormSuccessData=${encodeFunction(ofsd)}&prefillSpec=${encodeFunction(prefillSpec)}`); return encodeURIComponent(`${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "3006-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}/prefill?form=${form}&onFormSuccessData=${encodeFunction(ofsd)}&prefillSpec=${encodeFunction(prefillSpec)}`); } @@ -56,10 +57,8 @@ const GenericForm = (props) => { return ( <div className={styles.container}> - <div className={styles.header}> - <div>Go back</div> - <div>{selectedFlow.name}</div> - </div> + <div>{selectedFlow.name}</div> + <div onClick={() => setSelectedFlow({})}>Go Back</div> <iframe title='current-form' className={styles.odkForm} src={ diff --git a/apps/wrapper/src/components/GenericForm/index.module.css b/apps/wrapper/src/components/GenericForm/index.module.css index 57d95a0..777b953 100644 --- a/apps/wrapper/src/components/GenericForm/index.module.css +++ b/apps/wrapper/src/components/GenericForm/index.module.css @@ -6,23 +6,22 @@ align-items: center; width: 40vw; padding-bottom: 2rem; + position: relative; } -.header { - display: flex; - flex-direction: row; - width: 100%; - justify-content: space-between; -} - -.header:nth-child(1) { - font-size: 1rem; +.container >div:nth-child(1) { + font-size: 3rem; color: #ffc119; } -.header:nth-child(2) { - font-size: 3rem; +.container >div:nth-child(2) { + font-size: 1rem; color: #ffc119; + position: absolute; + top: 0; + left: 0; + cursor: pointer; + margin-top: 1.5rem; } .odkForm { diff --git a/make-envs-for-react.sh b/make-envs-for-react.sh new file mode 100644 index 0000000..9e75e6c --- /dev/null +++ b/make-envs-for-react.sh @@ -0,0 +1 @@ +echo REACT_APP_GITPOD_WORKSPACE_URL=${GITPOD_WORKSPACE_URL} > ./apps/wrappers/.env \ No newline at end of file -- GitLab