Skip to content

Commit

Permalink
feature: resolve the following problems
Browse files Browse the repository at this point in the history
* RadioGroup error using forwardRef when isn't necessary
* Make Jotform iframe as component and adding a loading to prevent weird behavios while jotform load the form
* fix jotform undefined variable
* add package.lock file pending
* new color for tailwind
  • Loading branch information
cgarcia-lightit committed Jan 16, 2024
1 parent 3f83ca8 commit 9ec6f72
Show file tree
Hide file tree
Showing 14 changed files with 279 additions and 262 deletions.
121 changes: 121 additions & 0 deletions apps/eo_web/dist/assets/main-38e0bdbb.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

121 changes: 0 additions & 121 deletions apps/eo_web/dist/assets/main-e874f5ce.js

This file was deleted.

6 changes: 3 additions & 3 deletions apps/eo_web/dist/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
"src": "../../packages/ui/src/assets/avatar.svg"
},
"src/main.css": {
"file": "assets/main-0d348634.css",
"file": "assets/main-41da5d34.css",
"src": "src/main.css"
},
"src/main.tsx": {
"assets": [
"assets/UploadFile-694e44b5.svg"
],
"css": [
"assets/main-0d348634.css"
"assets/main-41da5d34.css"
],
"file": "assets/main-e874f5ce.js",
"file": "assets/main-38e0bdbb.js",
"isEntry": true,
"src": "src/main.tsx"
}
Expand Down
19 changes: 19 additions & 0 deletions apps/eo_web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions apps/eo_web/src/components/JotformFrame.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { useEffect, useRef, useState } from "react";

import { jotformScript } from "~/helpers/jotform_script";
// import { forwardRef } from "@eo/shared";
import { useMount } from "~/hooks/useMount";

interface JotformFrameProps {
formId: string | number;
searchParam?: URLSearchParams;
}

const Iframe = ({ formId, searchParam }: JotformFrameProps) => {
const ref = useRef<HTMLIFrameElement>(null);
useMount(() => {
jotformScript(formId);
setTimeout(() => {
if (ref?.current?.hidden) ref.current.hidden = false;
}, 1700);
}, [formId, searchParam]);

return (
<iframe
ref={ref}
src={`https://form.jotform.com/${formId}?${
searchParam ? searchParam.toString() : ""
}`}
id={`JotFormIFrame-${formId}`}
title=""
onLoad={() => {
window.parent.scrollTo(0, 0);
}}
allow="geolocation; microphone; camera"
allowFullScreen={true}
className="h-full w-full"
style={{
minWidth: "100%",
height: "539px",
border: "none",
}}
hidden
></iframe>
);
};

const Loading = () => {
const [showLoading, setShowLoading] = useState(true);
useEffect(() => {
setTimeout(() => {
setShowLoading(false);
}, 1200);
});

return (
<>
{showLoading && (
<div
className="h-12 w-12 animate-spin rounded-full border-4 border-gray-200 border-t-gray-1000"
style={{
position: "absolute",
top: "50%",
right: "calc(50% - 20px)",
}}
/>
)}
</>
);
};

export const JotformFrame = ({ formId, searchParam }: JotformFrameProps) => {
return (
<>
<Loading />
<Iframe formId={formId} searchParam={searchParam} />
</>
);
};
1 change: 1 addition & 0 deletions apps/eo_web/src/helpers/jotform_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const jotformScript = (profileId) => {
return;
}
var args = e.data.split(":");
let iframe;
if (args.length > 2) {
iframe = document.getElementById(
"JotFormIFrame-" + args[args.length - 1],
Expand Down
4 changes: 2 additions & 2 deletions apps/eo_web/src/hooks/useMount.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef } from "react";

export const useMount = (fn: () => void) => {
export const useMount = (fn: () => void, deps: unknown[] = []) => {
const onceFlag = useRef(true);

useEffect(() => {
Expand All @@ -9,5 +9,5 @@ export const useMount = (fn: () => void) => {
fn();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, deps);
};
26 changes: 2 additions & 24 deletions apps/eo_web/src/screens/Cancer/Profiling.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useNavigate } from "react-router-dom";

import { JotformFrame } from "~/components/JotformFrame";
import {
CANCER_PROFILE_CAREGIVER_ID,
CANCER_PROFILE_PATIENT_ID,
} from "~/configs/env";
import { jotformScript } from "~/helpers/jotform_script";
import { useMount } from "~/hooks/useMount";
import { LayoutDefault } from "~/layouts";
import { ROUTES } from "~/router";
import { useProfilingStore } from "~/stores/useProfilingStore";
Expand Down Expand Up @@ -34,31 +33,10 @@ export const Profiling = () => {
navigate(ROUTES.userRolSelector);
}

useMount(() => {
setTimeout(() => {
jotformScript(cancerProfileId);
}, 400);
});

return (
<LayoutDefault>
<div className="mb-10 flex h-screen flex-col">
{/* uncomment for real flow */}
<iframe
id={`JotFormIFrame-${cancerProfileId}`}
title=""
onLoad={() => window.parent.scrollTo(0, 0)}
allow="geolocation; microphone; camera"
allowTransparency={true}
allowFullScreen={true}
src={`https://form.jotform.com/${cancerProfileId}?${searchParam.toString()}`}
className="h-full w-full"
style={{
minWidth: "100%",
height: "539px",
border: "none",
}}
></iframe>
<JotformFrame formId={cancerProfileId} searchParam={searchParam} />
</div>
</LayoutDefault>
);
Expand Down
26 changes: 4 additions & 22 deletions apps/eo_web/src/screens/Cancer/SurveyForm.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import { useEffect } from "react";
import { useSearchParams } from "react-router-dom";

import { JotformFrame } from "~/components/JotformFrame";
import {
CANCER_CAREGIVER_SURVEY_ID,
CANCER_PATIENT_SURVEY_ID,
} from "~/configs/env";
import { jotformScript } from "~/helpers/jotform_script";
import { LayoutDefault } from "~/layouts";
import { useProfilingStore } from "~/stores/useProfilingStore";


export const SurveyForm = () => {
const [searchParams] = useSearchParams();
const setUsePayment = useProfilingStore((s) => s.setUsePayment)
const setUsePayment = useProfilingStore((s) => s.setUsePayment);

const isPilot = (searchParams.get("pilot") ?? "") === "true";
const email = searchParams.get("email") ?? "";
const profiled = searchParams.get("profiled") ?? "patient";
const symptoms = searchParams.get("symptoms") ?? "";

setUsePayment(!isPilot)
setUsePayment(!isPilot);

const formId =
profiled === "patient"
Expand All @@ -31,27 +30,10 @@ export const SurveyForm = () => {
symptoms,
});

useEffect(() => {
jotformScript(formId);
}, [formId]);
return (
<LayoutDefault>
<div className="mb-10 flex h-screen flex-col">
<iframe
id={`JotFormIFrame-${formId}`}
title=""
onLoad={() => window.parent.scrollTo(0, 0)}
allow="geolocation; microphone; camera"
allowTransparency={true}
allowFullScreen={true}
src={`https://form.jotform.com/${formId}?${params.toString()}`}
className="h-full w-full"
style={{
minWidth: "100%",
height: "539px",
border: "none",
}}
></iframe>
<JotformFrame formId={formId} searchParam={params} />
</div>
</LayoutDefault>
);
Expand Down
26 changes: 2 additions & 24 deletions apps/eo_web/src/screens/Senior/Profiling.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useNavigate } from "react-router-dom";

import { JotformFrame } from "~/components/JotformFrame";
import {
SENIOR_PROFILE_CAREGIVER_ID,
SENIOR_PROFILE_PATIENT_ID,
} from "~/configs/env";
import { jotformScript } from "~/helpers/jotform_script";
import { useMount } from "~/hooks/useMount";
import { LayoutDefault } from "~/layouts";
import { ROUTES } from "~/router";
import { useProfilingStore } from "~/stores/useProfilingStore";
Expand Down Expand Up @@ -34,31 +33,10 @@ export const Profiling = () => {
navigate(ROUTES.userRolSelector);
}

useMount(() => {
setTimeout(() => {
jotformScript(seniorFormId);
}, 400);
});

return (
<LayoutDefault>
<div className="mb-10 flex h-screen flex-col">
{/* uncomment for real flow */}
<iframe
id={`JotFormIFrame-${seniorFormId}`}
title=""
onLoad={() => window.parent.scrollTo(0, 0)}
allow="geolocation; microphone; camera"
allowTransparency={true}
allowFullScreen={true}
src={`https://form.jotform.com/${seniorFormId}?${searchParam.toString()}`}
className="h-full w-full"
style={{
minWidth: "100%",
height: "539px",
border: "none",
}}
></iframe>
<JotformFrame formId={seniorFormId} searchParam={searchParam} />
</div>
</LayoutDefault>
);
Expand Down
22 changes: 2 additions & 20 deletions apps/eo_web/src/screens/Senior/SeniorSurveyForm.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useEffect } from "react";
import { useSearchParams } from "react-router-dom";

import { JotformFrame } from "~/components/JotformFrame";
import {
SENIOR_CAREGIVER_SURVEY_ID,
SENIOR_PATIENT_SURVEY_ID,
} from "~/configs/env";
import { jotformScript } from "~/helpers/jotform_script";
import { LayoutDefault } from "~/layouts";


Expand All @@ -25,27 +24,10 @@ export const SeniorSurveyForm = () => {
? SENIOR_PATIENT_SURVEY_ID
: SENIOR_CAREGIVER_SURVEY_ID;

useEffect(() => {
jotformScript(formId);
}, []);
return (
<LayoutDefault>
<div className="mb-10 flex h-screen flex-col">
<iframe
id={`JotFormIFrame-${formId}`}
title=""
onLoad={() => window.parent.scrollTo(0, 0)}
allow="geolocation; microphone; camera"
allowTransparency={true}
allowFullScreen={true}
src={`https://form.jotform.com/${formId}?${searchParam.toString()}`}
className="h-full w-full"
style={{
minWidth: "100%",
height: "539px",
border: "none",
}}
></iframe>
<JotformFrame formId={formId} searchParam={searchParam} />
</div>
</LayoutDefault>
);
Expand Down
2 changes: 2 additions & 0 deletions packages/config/tailwind/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ export default {
transparent: "transparent",
gray: {
50: "#FEFEFF",
200: "#DFE4EB",
600: "#7C7B7A",
700: "#697079",
800: "#535A63",
1000: "#1B1D21",
},
cream: {
100: "#F8F6F3",
Expand Down
Loading

0 comments on commit 9ec6f72

Please sign in to comment.