diff --git a/src/App.js b/src/App.js
index 61c60aa..0a638ce 100644
--- a/src/App.js
+++ b/src/App.js
@@ -89,6 +89,9 @@ function App() {
+
+
+
{
}
const handleInput = async (setter, val, type) => {
- if (!navigator.onLine) setToLocalForage('syncData', true);
setter(val);
let appData = await getFromLocalForage('appData') || {};
appData[type] = val;
@@ -38,10 +37,14 @@ const AssessmentType = () => {
}
const saveDataOnline = async () => {
- saveDataToHasura({
- text_input: textData,
- date_input: dateData
- })
+ if (!navigator.onLine) {
+ setToLocalForage('syncData', true);
+ toast('Your data has been saved and will be synced with server once internet is available ✅')
+ } else
+ saveDataToHasura({
+ text_input: textData,
+ date_input: dateData
+ })
}
useEffect(() => {
diff --git a/src/pages/forms/GenericOdkForm.jsx b/src/pages/forms/GenericOdkForm.jsx
index cde5c8f..1431371 100644
--- a/src/pages/forms/GenericOdkForm.jsx
+++ b/src/pages/forms/GenericOdkForm.jsx
@@ -14,6 +14,7 @@ const GenericOdkForm = () => {
const [surveyUrl, setSurveyUrl] = useState("");
let { formName } = useParams();
const scheduleId = useRef();
+ const [formSubmitted] = useState(false);
const formSpec = {
forms: {
[formName]: {
@@ -143,7 +144,8 @@ const GenericOdkForm = () => {
}, []);
const getSurveyUrl = async () => {
- let surveyUrl = await getOfflineCapableForm('widgets');
+ let surveyUrl = await getOfflineCapableForm('Nursing Form-Medical (CRP)');
+ // let surveyUrl = await getOfflineCapableForm('widgets');
console.log("SurveyURL:", surveyUrl);
if (!surveyUrl)
setSurveyUrl("https://8065-samagradevelop-workflow-871i2twcw0a.ws-us98.gitpod.io/x/wnoqac4d")
@@ -151,6 +153,18 @@ const GenericOdkForm = () => {
setSurveyUrl(surveyUrl);
}
+
+ // TODO
+ const clearFormCache = async () => {
+ let formUri = await getFromLocalForage('formUri');
+ const formId = formUri.slice(formUri.lastIndexOf('/') + 1);
+ const enketoDB = indexedDB.open('enketo', 3);
+ indexedDB.databases().then(r => console.log(r))
+ console.log(enketoDB)
+ }
+
+
+
return (
@@ -172,6 +186,7 @@ const GenericOdkForm = () => {
/>
>
)}
+ {/*
Clear saved data
*/}
);