Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions apps/frontend/src/api/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useCallback, useEffect, useState } from 'react';
import {
Application,
AvailabilityFields,
CandidateInfo,
LearnerInfo,
User,
VolunteerInfo,
Expand Down Expand Up @@ -72,6 +73,12 @@ export class ApiClient {
return this.get(`/api/learner_info/${appId}`) as Promise<LearnerInfo>;
}

public async getCandidateInfoByEmail(email: string): Promise<CandidateInfo> {
return this.get(
`/api/CandidateInfo/email/${encodeURIComponent(email)}`,
) as Promise<CandidateInfo>;
}

public async updateAvailability(
appId: number,
availability: Partial<AvailabilityFields>,
Expand Down
5 changes: 5 additions & 0 deletions apps/frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,8 @@ export interface User {
lastName: string;
userType: UserType;
}

export interface CandidateInfo {
email: string;
appId: number;
}
6 changes: 5 additions & 1 deletion apps/frontend/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BrowserRouter, Outlet, Route, Routes } from 'react-router-dom';
import { ChakraProvider, defaultSystem } from '@chakra-ui/react';
import AdminLanding from './containers/AdminLanding';
import AdminViewApplication from './containers/AdminViewApplication';
import CandidateViewApplication from './containers/CandidateViewApplication';
import NotFound from './containers/404';
import RequireAuth from './auth/RequireAuth';
import RequireRole from './auth/RequireRole';
Expand Down Expand Up @@ -45,7 +46,10 @@ export const App: React.FC = () => {
element={<RequireRole allowedUserTypes={[UserType.STANDARD]} />}
>
<Route path="candidate" element={<Outlet />}>
<Route path="view-application" />
<Route
path="view-application"
element={<CandidateViewApplication />}
/>
<Route path="upload-forms" />
<Route path="settings" />
</Route>
Expand Down
3 changes: 3 additions & 0 deletions apps/frontend/src/assets/icons/personIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/frontend/src/auth/cognito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export const getIdToken = async (): Promise<string | undefined> => {
};

export const isAuthenticated = async (): Promise<boolean> => {
if (import.meta.env.VITE_DEV_AUTH_EMAIL) return true;

try {
await getCurrentUser();
return true;
Expand Down
5 changes: 5 additions & 0 deletions apps/frontend/src/auth/current-session-user-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export const fetchAndStoreCurrentSessionUserType =
};

export const getCurrentSessionUserType = async (): Promise<UserType | null> => {
const devUserType = import.meta.env.VITE_DEV_AUTH_USER_TYPE as string;
if (devUserType === UserType.ADMIN || devUserType === UserType.STANDARD) {
return devUserType;
}

// Prefer the cached role first so route guards do not call the backend on
// every render, but only if Cognito still considers the session valid.
const storedUserType = getCurrentSessionUserTypeFromStorage();
Expand Down
110 changes: 110 additions & 0 deletions apps/frontend/src/components/EmergencyContactFrame.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { Box, Flex, Text } from '@chakra-ui/react';
import personIcon from '../assets/icons/personIcon.svg?url';

interface EmergencyContactFrameProps {
name: string;
phone: string;
relationship: string;
}

const EmergencyContactFrame = ({
name,
phone,
relationship,
}: EmergencyContactFrameProps) => {
return (
<Flex
align="center"
gap="26px"
bg="#F5F5F5"
borderRadius="md"
px="20px"
py="50px"
w="100%"
>
<Flex
w="100px"
h="100px"
borderRadius="200px"
bg="#013594"
align="center"
justify="center"
flexShrink={0}
p="29px"
>
<img
src={personIcon}
alt="Emergency contact avatar"
style={{
width: '100%',
height: '100%',
filter: 'brightness(0) invert(1)',
}}
/>
</Flex>

<Box
display="grid"
gridTemplateColumns="1fr 1fr"
gridTemplateRows="auto auto auto"
gap="4px"
flex={1}
alignItems="start"
>
<Text
fontSize="20px"
fontFamily="Lato, sans-serif"
fontWeight="700"
color="#000"
lineHeight="normal"
gridRow="1"
gridColumn="1"
>
Emergency Contact
</Text>

<Flex
align="center"
justify="center"
px="12px"
py="6px"
borderRadius="20px"
border="1px solid #013594"
bg="#008CA7"
gridRow="1"
gridColumn="2"
alignSelf="center"
w="fit-content"
>
<Text color="white" fontWeight="600" fontSize="sm">
{relationship}
</Text>
</Flex>

<Text
fontSize="18px"
fontFamily="Lato, sans-serif"
fontWeight="400"
color="#000"
gridRow="2"
gridColumn="1 / span 2"
>
{name}
</Text>

<Text
fontSize="18px"
fontFamily="Lato, sans-serif"
fontWeight="400"
color="gray.600"
gridRow="3"
gridColumn="1"
>
{phone}
</Text>
</Box>
</Flex>
);
};

export default EmergencyContactFrame;
8 changes: 6 additions & 2 deletions apps/frontend/src/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ export default function NavBar({ logo, userType }: NavBarProps) {
)}
{userType === UserType.STANDARD && (
<NavbarItem
href="#myapplication"
href="/candidate/view-application"
label="My Application"
icon={<FaPerson />}
/>
)}
{userType === UserType.STANDARD && (
<NavbarItem href="#myforms" label="My Forms" icon={<FaRegFile />} />
<NavbarItem
href="/candidate/upload-forms"
label="My Forms"
icon={<FaRegFile />}
/>
)}
<NavbarItem
href="#settings"
Expand Down
16 changes: 11 additions & 5 deletions apps/frontend/src/containers/AdminViewApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import {
LearnerInfo,
UserType,
VolunteerInfo,
} from '../api/types';
import QuestionFrame from '../components/QuestionFrame';
import RequirementsFrame from '../components/RequirementsFrame';
import UploadedMaterial from '../components/UploadedMaterial';
import SchoolAffiliationFrame from '../components/SchoolAffiliationFrame';
} from '@api/types';
import QuestionFrame from '@components/QuestionFrame';
import RequirementsFrame from '@components/RequirementsFrame';
import UploadedMaterial from '@components/UploadedMaterial';
import SchoolAffiliationFrame from '@components/SchoolAffiliationFrame';
import EmergencyContactFrame from '@components/EmergencyContactFrame';

const AdminViewApplication: React.FC = () => {
const { appId } = useParams<{ appId: string }>();
Expand Down Expand Up @@ -213,6 +214,11 @@ const AdminViewApplication: React.FC = () => {
}}
/>
)}
<EmergencyContactFrame
name={application.emergencyContactName}
phone={application.emergencyContactPhone}
relationship={application.emergencyContactRelationship}
/>
</Box>
</div>
);
Expand Down
Loading
Loading