-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Light-it-labs/feature/recreating-login-page
Feature/recreating login page
- Loading branch information
Showing
31 changed files
with
1,000 additions
and
167 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
apps/eo_web/dist/assets/main-c9849107.css → apps/eo_web/dist/assets/main-90f1cf5a.css
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { api } from "~/api/axios"; | ||
import { API_URL } from "~/api/common"; | ||
import { | ||
useProfileStore, | ||
type Profile, | ||
type Session, | ||
} from "~/stores/useProfileStore"; | ||
|
||
interface LoginResponse { | ||
profile: Profile; | ||
session: Session; | ||
} | ||
|
||
export const login = async (credential: { | ||
email: string; | ||
password: string; | ||
}) => { | ||
return await api.post<LoginResponse>(`${API_URL}/v2/profile/login`, { | ||
email: credential.email, | ||
password: credential.password, | ||
}); | ||
}; | ||
|
||
export const register = async (credential: { | ||
email: string; | ||
password: string; | ||
}) => { | ||
return await api.post<string>(`${API_URL}/v2/profile`, { | ||
email: credential.email, | ||
password: credential.password, | ||
}); | ||
}; | ||
|
||
export const GetToken = () => { | ||
const session = useProfileStore((state) => state.session); | ||
return session?.token; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
declare global { | ||
interface Window { | ||
data: { | ||
[key: string]: string; | ||
}; | ||
} | ||
} | ||
|
||
export const API_URL = (() => { | ||
return window.data?.apiUrl || "http://localhost:4200"; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { api } from "~/api/axios"; | ||
import { API_URL } from "~/api/common"; | ||
|
||
export interface ResendEmailVerificationResponse { | ||
success: boolean; | ||
} | ||
export const resendEmailVerification = async (email: string) => { | ||
return await api.post<ResendEmailVerificationResponse>( | ||
`${API_URL}/v2/profile/resend_confirmation_email`, | ||
{ email }, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { api } from "~/api/axios"; | ||
import { API_URL } from "~/api/common"; | ||
import { useProfileStore } from "~/stores/useProfileStore"; | ||
|
||
export interface ZipCodeValidationResponseSuccess { | ||
app_flags: { | ||
can_delete_sessions: boolean; | ||
can_edit_sessions: boolean; | ||
can_mute_sessions: boolean; | ||
malady_selection: Array<{ | ||
label: string; | ||
slug: string; | ||
}>; | ||
}; | ||
birth_date: string | null; | ||
caregiver: boolean; | ||
ced: boolean; | ||
email: string; | ||
first_name: string | null; | ||
gender: string | null; | ||
last_name: string | null; | ||
malady: string; | ||
med_card: boolean; | ||
phone: unknown; | ||
status: string; | ||
timezone: string; | ||
uid: string; | ||
zip: string; | ||
} | ||
|
||
export interface ZipCodeValidationResponseError { | ||
errors: { | ||
zip?: Array<{ | ||
code: string; | ||
message: string; | ||
}>; | ||
default?: Array<{ | ||
code: string; | ||
message: string; | ||
}>; | ||
}; | ||
} | ||
|
||
export const useElixirApi = () => { | ||
const token = useProfileStore((state) => state.session?.token); | ||
|
||
const authHeader = { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}; | ||
const validateZipCode = async (zipCode: string) => { | ||
return api.post< | ||
ZipCodeValidationResponseSuccess | ZipCodeValidationResponseError | ||
>( | ||
`${API_URL}/v2/profile/validate_zip_code`, | ||
{ | ||
zip: zipCode, | ||
}, | ||
authHeader, | ||
); | ||
}; | ||
|
||
return { | ||
validateZipCode, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { toast } from "react-toastify"; | ||
|
||
import { Button } from "@eo/ui"; | ||
|
||
import { ROUTES } from "~/router"; | ||
import { useProfileStore } from "~/stores/useProfileStore"; | ||
|
||
export const Header = () => { | ||
const profile = useProfileStore((state) => state.profile); | ||
|
||
const setProfile = useProfileStore((state) => state.setProfile); | ||
const setSession = useProfileStore((state) => state.setSession); | ||
|
||
const navigate = useNavigate(); | ||
|
||
const logout = () => { | ||
setProfile(null); | ||
setSession(null); | ||
navigate(ROUTES.login); | ||
toast.info("You has been logged out!"); | ||
}; | ||
return ( | ||
<header className="border-1 relative flex h-[93px] w-full flex-row items-center justify-center border bg-white shadow-lg"> | ||
<div></div> | ||
<img | ||
src="https://assets-global.website-files.com/641990da28209a736d8d7c6a/641990da28209a61b68d7cc2_eo-logo%201.svg" | ||
alt="Leters EO" | ||
className="h-11 w-20" | ||
/> | ||
<div className="absolute right-12"> | ||
{profile && ( | ||
<Button variant="outline" onClick={() => logout()} className=""> | ||
Log out | ||
</Button> | ||
)} | ||
</div> | ||
</header> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
export const ROUTES = { | ||
base: "app/", | ||
login: "app/login", | ||
login: "/app/login", | ||
register: "/app/register", | ||
registrationComplete: "/app/register/complete", | ||
home: "/app/home", | ||
zipCodeValidation: "/app/profile/zip-code-validation", | ||
emailVerification: "app/profile/email-verification", | ||
unavailableZipCode: "/app/profile/unavailable-zip-code", | ||
eligibleProfile: "/app/profile/eligible-profile", | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import { Button, Typography } from "@eo/ui"; | ||
|
||
import { LayoutDefault } from "~/layouts"; | ||
import { ROUTES } from "~/router"; | ||
|
||
export const EligibleProfile = () => { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<LayoutDefault> | ||
<div className="flex h-full h-full flex-col items-center justify-center"> | ||
<Typography variant="large" className="mx-10 text-center"> | ||
Looks like you’re eligible for eo! Next, we’ll get you to fill out | ||
some information so we can better serve you... | ||
</Typography> | ||
<div className="mt-10 flex flex-row justify-center"> | ||
<Button className="text-center" onClick={() => navigate(ROUTES.home)}> | ||
Continue | ||
</Button> | ||
</div> | ||
</div> | ||
</LayoutDefault> | ||
); | ||
}; |
Oops, something went wrong.