Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hybrid #1075

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions www/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
"scootershare": "Scooter share",
"drove_alone": "Gas Car Drove Alone",
"shared_ride": "Gas Car Shared Ride",
"hybrid_drove_alone": "Hybrid Drove Alone",
"hybrid_shared_ride": "Hybrid Shared Ride",
"e_car_drove_alone": "E-Car Drove Alone",
"e_car_shared_ride": "E-Car Shared Ride",
"moped": "Moped",
Expand Down
6 changes: 3 additions & 3 deletions www/js/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ const App = () => {
<AppContext.Provider value={appContextValue}>
{appContent}

{ /* If we are past the consent page (route > CONSENT), the permissions popup can show if needed.
This also includes if onboarding is DONE altogether (because "DONE" is > "CONSENT") */ }
{(onboardingState && onboardingState.route > OnboardingRoute.CONSENT) &&
{ /* If we are fully consented, (route > PROTOCOL), the permissions popup can show if needed.
This also includes if onboarding is DONE altogether (because "DONE" is > "PROTOCOL") */ }
{(onboardingState && onboardingState.route > OnboardingRoute.PROTOCOL) &&
<AppStatusModal permitVis={permissionsPopupVis} setPermitVis={setPermissionsPopupVis} />
}
</AppContext.Provider>
Expand Down
6 changes: 3 additions & 3 deletions www/js/onboarding/OnboardingStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext } from "react";
import { StyleSheet } from "react-native";
import { AppContext } from "../App";
import WelcomePage from "./WelcomePage";
import ConsentPage from "./ConsentPage";
import ProtocolPage from "./ProtocolPage";
import SurveyPage from "./SurveyPage";
import SaveQrPage from "./SaveQrPage";
import SummaryPage from "./SummaryPage";
Expand All @@ -19,8 +19,8 @@ const OnboardingStack = () => {
return <WelcomePage />;
} else if (onboardingState.route == OnboardingRoute.SUMMARY) {
return <SummaryPage />;
} else if (onboardingState.route == OnboardingRoute.CONSENT) {
return <ConsentPage />;
} else if (onboardingState.route == OnboardingRoute.PROTOCOL) {
return <ProtocolPage />;
} else if (onboardingState.route == OnboardingRoute.SAVE_QR) {
return <SaveQrPage />;
} else if (onboardingState.route == OnboardingRoute.SURVEY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { AppContext } from '../App';
import { getAngularService } from '../angular-react-helper';
import PrivacyPolicy from './PrivacyPolicy';
import { onboardingStyles } from './OnboardingStack';
import { setProtocolDone } from './onboardingHelper';

const ConsentPage = () => {
const ProtocolPage = () => {

const { t } = useTranslation();
const context = useContext(AppContext);
Expand All @@ -20,10 +21,8 @@ const ConsentPage = () => {
};

function agree() {
const StartPrefs = getAngularService('StartPrefs');
StartPrefs.markConsented().then((response) => {
refreshOnboardingState();
});
setProtocolDone(true);
refreshOnboardingState();
};

// privacy policy and data collection info, followed by accept/reject buttons
Expand All @@ -40,4 +39,4 @@ const ConsentPage = () => {
</>);
}

export default ConsentPage;
export default ProtocolPage;
15 changes: 9 additions & 6 deletions www/js/onboarding/SaveQrPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ const SaveQrPage = ({ }) => {

useEffect(() => {
if (overallStatus == true && !registerUserDone) {
logDebug('permissions done, going to log in');
login(onboardingState.opcode).then((response) => {
logDebug('login done, refreshing onboarding state');
setRegisterUserDone(true);
preloadDemoSurveyResponse();
refreshOnboardingState();
const StartPrefs = getAngularService('StartPrefs');
StartPrefs.markConsented().then((response) => {
logDebug('permissions done, going to log in');
login(onboardingState.opcode).then((response) => {
logDebug('login done, refreshing onboarding state');
setRegisterUserDone(true);
preloadDemoSurveyResponse();
refreshOnboardingState();
});
});
} else {
logDebug('permissions not done, waiting');
Expand Down
17 changes: 10 additions & 7 deletions www/js/onboarding/onboardingHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { logDebug } from "../plugin/logger";
export const INTRO_DONE_KEY = 'intro_done';

// route = WELCOME if no config present
// route = SUMMARY if config present, but not consented and summary not done
// route = CONSENT if config present, but not consented and summary done
// route = SAVE_QR if config present, consented, but save qr not done
// route = SUMMARY if config present, but protocol not done and summary not done
// route = PROTOCOL if config present, but protocol not done and summary done
// route = SAVE_QR if config present, protocol done, but save qr not done
// route = SURVEY if config present, consented and save qr done
// route = DONE if onboarding is finished (intro_done marked)
export enum OnboardingRoute { WELCOME, SUMMARY, CONSENT, SAVE_QR, SURVEY, DONE };
export enum OnboardingRoute { WELCOME, SUMMARY, PROTOCOL, SAVE_QR, SURVEY, DONE };
export type OnboardingState = {
opcode: string,
route: OnboardingRoute,
Expand All @@ -21,6 +21,9 @@ export type OnboardingState = {
export let summaryDone = false;
export const setSummaryDone = (b) => summaryDone = b;

export let protocolDone = false;
export const setProtocolDone = (b) => protocolDone = b;

export let saveQrDone = false;
export const setSaveQrDone = (b) => saveQrDone = b;

Expand All @@ -41,10 +44,10 @@ export function getPendingOnboardingState(): Promise<OnboardingState> {
route = OnboardingRoute.DONE;
} else if (!config) {
route = OnboardingRoute.WELCOME;
} else if (!isConsented && !summaryDone) {
} else if (!protocolDone && !summaryDone) {
route = OnboardingRoute.SUMMARY;
} else if (!isConsented) {
route = OnboardingRoute.CONSENT;
} else if (!protocolDone) {
route = OnboardingRoute.PROTOCOL;
} else if (!saveQrDone) {
route = OnboardingRoute.SAVE_QR;
} else {
Expand Down
4 changes: 3 additions & 1 deletion www/json/label-options.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
{"value":"scootershare", "baseMode":"E_SCOOTER", "met_equivalent":"IN_VEHICLE", "kgCo2PerKm": 0.00894},
{"value":"drove_alone", "baseMode":"CAR", "met_equivalent":"IN_VEHICLE", "kgCo2PerKm": 0.22031},
{"value":"shared_ride", "baseMode":"CAR", "met_equivalent":"IN_VEHICLE", "kgCo2PerKm": 0.11015},
{"value":"hybrid_drove_alone", "baseMode":"CAR", "met_equivalent":"IN_VEHICLE", "kgCo2PerKm": 0.127},
{"value":"hybrid_shared_ride", "baseMode":"CAR", "met_equivalent":"IN_VEHICLE", "kgCo2PerKm": 0.0635},
{"value":"e_car_drove_alone", "baseMode":"E_CAR", "met_equivalent":"IN_VEHICLE", "kgCo2PerKm": 0.08216},
{"value":"e_car_shared_ride", "baseMode":"E_CAR", "met_equivalent":"IN_VEHICLE", "kgCo2PerKm": 0.04108},
{"value":"moped", "baseMode":"MOPED", "met_equivalent":"IN_VEHICLE", "kgCo2PerKm": 0.05555},
Expand Down Expand Up @@ -51,4 +53,4 @@
{"value":"free_shuttle"},
{"value":"other"}
]
}
}