Skip to content

Commit

Permalink
Merge pull request #213 from Light-it-labs/develop
Browse files Browse the repository at this point in the history
[Release] 🚀 - 02/08/2024
  • Loading branch information
sgoycoechea-lightit authored Aug 2, 2024
2 parents d676215 + 13cc704 commit 1bbc69a
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 150 deletions.
2 changes: 0 additions & 2 deletions apps/eo_web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ ZUKO_SLUG_ID_PROCESS_START=
CANCER_PROFILE_PATIENT_ID=
CANCER_PROFILE_CAREGIVER_ID=
CANCER_SURVEY_FORM=
ATHLETE_PROFILE_FORM=
ATHLETE_SURVEY_FORM=
API_URL=
API_LARAVEL=
2 changes: 0 additions & 2 deletions apps/eo_web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ interface EnvironmentsConfigs {
CANCER_PROFILE_CAREGIVER_ID: string;
CANCER_PATIENT_SURVEY_ID: string;
CANCER_CAREGIVER_SURVEY_ID: string;
ATHLETE_PROFILE_FORM: string;
ATHLETE_SURVEY_FORM: string;
SENIOR_INTRO_QUESTION_PATIENT_ID: string;
SENIOR_INTRO_QUESTION_CAREGIVER_ID: string;
SENIOR_PROFILE_PATIENT_ID: string;
Expand Down
9 changes: 2 additions & 7 deletions apps/eo_web/src/api/useApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { apiElixir, apiLaravel } from "~/api/axios";
import {
type AvoidPresentation,
type Maladies,
Expand All @@ -7,6 +6,7 @@ import {
type ThcProductPreferences,
type WorseSymptomsMoment,
} from "~/api/PrePlanTypes";
import { apiElixir, apiLaravel } from "~/api/axios";
import { useProfileStore, type Profile } from "~/stores/useProfileStore";
import { type FlowType } from "~/stores/useProfilingStore";

Expand Down Expand Up @@ -80,6 +80,7 @@ interface CreatePreProfileParams {
email: string;
phone_number: string;
origin: string;
referred_by: string;
}

export const useApi = () => {
Expand Down Expand Up @@ -154,11 +155,6 @@ export const useApi = () => {
data,
);

const postAthleteSurveyFormSubmission = async (data: object) =>
await apiLaravel.post<
LaravelSuccessBase<ProfileCreationResult> | LaravelErrorValidation
>("/api/athletes/survey", data);

const postSeniorFormSubmission = async (data: object) =>
await apiLaravel.post<
LaravelSuccessBase<ProfileCreationResult> | LaravelErrorValidation
Expand Down Expand Up @@ -190,7 +186,6 @@ export const useApi = () => {
eligibleEmail,
postCancerFormSubmission,
postCancerSurveyFormSubmission,
postAthleteSurveyFormSubmission,
postSeniorFormSubmission,
postSeniorSurveyFormSubmission,
surveyStatus,
Expand Down
5 changes: 0 additions & 5 deletions apps/eo_web/src/configs/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export const CANCER_PATIENT_SURVEY_ID =
export const CANCER_CAREGIVER_SURVEY_ID =
window.data.getEnv("CANCER_CAREGIVER_SURVEY_ID") || 233415093176152;

export const ATHLETE_PROFILE_FORM =
window.data.getEnv("ATHLETE_PROFILE_FORM") || 233115151709146;
export const ATHLETE_SURVEY_FORM =
window.data.getEnv("ATHLETE_SURVEY_FORM") || 233164188186664;

export const SENIOR_INTRO_QUESTION_PATIENT_ID =
window.data.getEnv("SENIOR_INTRO_QUESTION_PATIENT_ID") || 233233204641040;
export const SENIOR_INTRO_QUESTION_CAREGIVER_ID =
Expand Down
9 changes: 0 additions & 9 deletions apps/eo_web/src/router/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Route, Routes } from "react-router-dom";

import { ROUTES } from "~/router/routes";
import { AccountCreation } from "~/screens/AccountCreation";
import { AthleteSurveyForm } from "~/screens/Athlete/AthleteSurveyForm";
import { AthleteSurveyThankYou } from "~/screens/Athlete/AthleteSurveyThankYou";
import { CancerSurveyThankYou } from "~/screens/Cancer/CancerSurveyThankYou";
import { Profiling } from "~/screens/Cancer/Profiling";
import { SurveyForm } from "~/screens/Cancer/SurveyForm";
Expand Down Expand Up @@ -113,13 +111,6 @@ export const Router = () => {
path={ROUTES.cancerSurveyThankYou}
/>

{/* ATHLETES */}
<Route element={<AthleteSurveyForm />} path={ROUTES.athleteSurvey} />
<Route
element={<AthleteSurveyThankYou />}
path={ROUTES.athleteSurveyThankYou}
/>

{/* SENIOR */}
<Route element={<SeniorProfiling />} path={ROUTES.seniorForm} />
<Route element={<SeniorSurveyForm />} path={ROUTES.seniorSurvey} />
Expand Down
4 changes: 0 additions & 4 deletions apps/eo_web/src/router/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export const ROUTES = {
cancerSurvey: "/cancer/survey",
cancerSurveyThankYou: "/cancer/survey-thank-you",

// Athletes PATH
athleteSurvey: "/athletes/survey",
athleteSurveyThankYou: "athletes/survey-thank-you",

// Senior PATH
seniorForm: "/senior/profiling",
seniorSurvey: "/senior/survey",
Expand Down
38 changes: 36 additions & 2 deletions apps/eo_web/src/screens/AccountCreation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ import {
type FlowType,
} from "~/stores/useProfilingStore";

export const ReferralOptions = {
"Twist Out Cancer": Flows.twist_out_cancer,
"Unite for Her": Flows.unite_for_her,
"Imerman Angels": Flows.imerman,
"Stupid Cancer": Flows.stupid_cancer,
"Cancer Support Community": Flows.cancer_support_community,
"UVA Health": Flows.uva,
"Inova Schar Cancer Institute": Flows.inova,
} as const;

export type ReferralOptionsType = keyof typeof ReferralOptions;

const getFlowFromReferral = (value: string) => {
const keys = Object.keys(ReferralOptions) as ReferralOptionsType[]
const key = keys.find(key => key === value)
return key ? ReferralOptions[key] : undefined
}

const getReferredBy = (searchParams: URLSearchParams) => {
const encodedReferredBy = searchParams.get("referred_by") ?? undefined
return encodedReferredBy ? decodeURIComponent(encodedReferredBy) : undefined
}


export const signUpSchema = z.object({
// Profiling
firstName: z.string().min(1, { message: "First name is required" }),
Expand Down Expand Up @@ -66,6 +90,7 @@ export type SignUpFormSchema = z.infer<typeof signUpSchema>;

export const AccountCreation = () => {
const navigate = useNavigate();

const [useParams] = useSearchParams();
const {
account,
Expand All @@ -75,8 +100,13 @@ export const AccountCreation = () => {
setState,
setExperience,
flow,
setFlow,
setReferredBy,
} = useProfilingStore((state) => state);

const referredBy = getReferredBy(useParams)
const referredFlow = referredBy ? getFlowFromReferral(referredBy) : undefined

const [validatingForm, setValidatingForm] = useState(false);
const { mutate: createPreProfile } = usePreProfile().preProfileMutation;
const {
Expand Down Expand Up @@ -110,6 +140,7 @@ export const AccountCreation = () => {
email: data.email,
phone_number: data.phoneNumber.replace(/\D/g, ""),
origin: getIndex(flow),
referred_by: referredBy ?? "",
});
switch (channel) {
case "cancer":
Expand Down Expand Up @@ -166,6 +197,7 @@ export const AccountCreation = () => {
const submissionId = useParams.get("submission_id");
const state = useParams.get("state");
const experience = useParams.get("experience") ?? "";
const referredBy = getReferredBy(useParams) ?? "";

if (!submissionId) {
toast.error(
Expand All @@ -178,6 +210,8 @@ export const AccountCreation = () => {
setState(state);
setIntroQuestionSubmissionId(submissionId);
setExperience(experience);
setReferredBy(referredBy);
if (referredFlow) setFlow(referredFlow);
}
});

Expand Down Expand Up @@ -260,7 +294,7 @@ export const AccountCreation = () => {
className={tw(
"font-nunito text-[11px] font-light ",
errors.agreeReceiveNotifications?.message &&
"text-red-500",
"text-red-500",
)}
>
I agree to receive emails and text messages related to my
Expand All @@ -282,7 +316,7 @@ export const AccountCreation = () => {
className={tw(
"font-nunito text-[11px] font-light !leading-4",
errors.agreeTermsAndConditions?.message &&
"text-red-500",
"text-red-500",
)}
>
I have read and agree to the{" "}
Expand Down
42 changes: 0 additions & 42 deletions apps/eo_web/src/screens/Athlete/AthleteSurveyForm.tsx

This file was deleted.

75 changes: 0 additions & 75 deletions apps/eo_web/src/screens/Athlete/AthleteSurveyThankYou.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion apps/eo_web/src/screens/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Checkout = () => {
const { usePayment } = useProfilingStore();
const [searchParams] = useSearchParams();

const { account, introQuestionSubmissionId, channel, flow, origin } =
const { account, introQuestionSubmissionId, channel, flow, origin, referredBy } =
useProfilingStore();

const formParams = new URLSearchParams({
Expand Down Expand Up @@ -80,6 +80,7 @@ export const Checkout = () => {
agree_terms_and_conditions: account.agreeTermsAndConditions,
channel,
flow,
referred_by: referredBy,
}),
);

Expand Down
3 changes: 2 additions & 1 deletion apps/eo_web/src/screens/ProfilingIntroQuestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import { useProfilingStore } from "~/stores/useProfilingStore";

export const ProfilingIntroQuestions = () => {
const navigate = useNavigate();
const { channel, type, origin } = useProfilingStore((state) => state);
const { channel, type, origin, flow } = useProfilingStore((state) => state);
const searchParams = new URLSearchParams({
origin,
flow
});

let introQuestionsId: string | number | null = null;
Expand Down
6 changes: 6 additions & 0 deletions apps/eo_web/src/stores/useProfilingStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface ProfilingStore {
experience: string;
account: Account;
flow: FlowType;
referredBy: string;
setAccountData: (account: Account) => void;
setChannel: (channel: Channel) => void;
setType: (type: Type) => void;
Expand All @@ -60,6 +61,7 @@ export interface ProfilingStore {
setOrigin: (origin: string) => void;
setExperience: (experience: string) => void;
setFlow: (flow: FlowType) => void;
setReferredBy: (referredBy: string) => void;
}

const defaultState = {
Expand All @@ -81,6 +83,7 @@ const defaultState = {
},
usePayment: true,
flow: Flows.marketing_site,
referredBy: "",
};

export const useProfilingStore = create<ProfilingStore>()(
Expand Down Expand Up @@ -119,6 +122,9 @@ export const useProfilingStore = create<ProfilingStore>()(
setFlow: (flow: FlowType) => {
set({ flow });
},
setReferredBy: (referredBy: string) => {
set({ referredBy });
},
...defaultState,
}),
{
Expand Down
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
"iconify",
"imerman",
"inova",
"intoxi",
"jotform",
"LARAVEL",
"manypkg",
"medtech",
"middlewares",
"nonworkday",
"NEXTAUTH",
"pnpm",
"rgba",
Expand Down

0 comments on commit 1bbc69a

Please sign in to comment.