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

feat: New care group screen #76

Merged
merged 20 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions client/assets/arrow-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions client/assets/profile/plus.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: 1 addition & 1 deletion client/components/nav_buttons/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function BackButton() {

return (
<IconButton
className="align-center m-2 flex h-[50px] w-[52px] justify-center rounded-xl bg-carewallet-gray"
className="align-center m-2 flex h-[50px] w-[52px] justify-center rounded-xl border border-carewallet-lightgray bg-carewallet-white"
mode="contained"
icon={({ color }) => <ArrowLeft fill={color} />}
onPress={() => navigation.goBack()}
Expand Down
20 changes: 20 additions & 0 deletions client/components/profile/AddButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';

import { useNavigation } from '@react-navigation/native';
import { IconButton } from 'react-native-paper';

import Plus from '../../assets/profile/plus.svg';
import { AppStackNavigation } from '../../navigation/types';

export function AddButtom() {
const navigation = useNavigation<AppStackNavigation>();

return (
<IconButton
className="align-center m-2 flex h-[50px] w-[52px] justify-center rounded-xl bg-carewallet-blue"
mode="contained"
icon={({ color }) => <Plus fill={color} />}
onPress={() => navigation.goBack()}
/>
);
}
49 changes: 49 additions & 0 deletions client/components/profile/CareTaker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';

import { useNavigation } from '@react-navigation/native';

import { AppStackNavigation } from '../../navigation/types';
import { GroupRole, Role } from '../../types/group';
import { User } from '../../types/user';

interface CareProps {
user: User | undefined;
role: GroupRole | undefined;
}

export function CareTaker({ user, role }: CareProps) {
if (!user) return null;
const navigation = useNavigation<AppStackNavigation>();
// const { user: signedInUser, group } = useCareWalletContext();
// const [activeUser, setActiveUser] = useState(signedInUser.userID);
Comment on lines +19 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// const { user: signedInUser, group } = useCareWalletContext();
// const [activeUser, setActiveUser] = useState(signedInUser.userID);


const handlePress = () => {
navigation.navigate('Profile');
};

return (
<TouchableOpacity onPress={handlePress}>
<View className="mb-2 flex flex-row items-center rounded-xl border border-carewallet-lightgray bg-carewallet-white">
<View className="mb-3 ml-3 h-20 w-20 rounded-full border border-carewallet-lightgray bg-carewallet-white" />
<View className="mt-5 flex h-fit max-h-fit min-h-fit flex-row items-center">
<View className="mb-5 ml-8">
<Text className="flex-wrap text-left font-carewallet-manrope-semibold text-xl text-carewallet-black">
{user.first_name} {user.last_name}
</Text>
<View className="flex w-[60vw] flex-row pt-3">
<View className="flex flex-col">
<Text className="items-center justify-center text-left font-carewallet-manrope text-xs text-carewallet-black">
{`${role?.role} ${role?.role !== Role.PATIENT ? 'CARETAKER' : ''}`}
</Text>
<Text className="items-center justify-center text-left font-carewallet-manrope text-xs text-carewallet-black">
{user.phone ? user.phone : user.email}
</Text>
</View>
</View>
</View>
</View>
</View>
</TouchableOpacity>
);
}
6 changes: 6 additions & 0 deletions client/navigation/AppNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import LoginPage from '../screens/LoginPage';
import { CareGroup } from '../screens/Profile/CareGroup';
import { TaskCreation } from '../screens/TaskCreation';
import { TaskType } from '../screens/TaskType';
import { AppStackBottomTabNavigator } from './AppStackBottomTabNavigator';
Expand Down Expand Up @@ -29,6 +30,11 @@ export function AppNavigation() {
options={{ headerShown: false }}
component={TaskCreation}
/>
<AppStack.Screen
name="CareGroup"
options={{ headerShown: false }}
component={CareGroup}
/>
</AppStack.Navigator>
);
}
6 changes: 6 additions & 0 deletions client/navigation/AppStackBottomTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Home from '../assets/bottom-nav/home.svg';
import User from '../assets/bottom-nav/user.svg';
import TimelineCalendarScreen from '../screens/Calendar';
import MedicationList from '../screens/MedicationList';
import { CareGroup } from '../screens/Profile/CareGroup';
import PatientView from '../screens/Profile/PatientView';
import Profile from '../screens/Profile/Profile';
import SingleTaskScreen from '../screens/SingleTask';
Expand Down Expand Up @@ -83,6 +84,11 @@ export function ProfileNavigation() {
options={{ headerShown: false }}
component={PatientView}
/>
<AppStack.Screen
name="CareGroup"
options={{ headerShown: false }}
component={CareGroup}
/>
</AppStack.Navigator>
);
}
Expand Down
1 change: 1 addition & 0 deletions client/navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type AppStackParamList = {
CalendarContainer: { screen: string; params: { screen: string } } | undefined;
CalendarTopNav: undefined;
TaskCreation: { taskType: string };
CareGroup: undefined;
};

export type AppStackNavigation = NavigationProp<AppStackParamList>;
Expand Down
100 changes: 100 additions & 0 deletions client/screens/Profile/CareGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React, { useState } from 'react';
import { ActivityIndicator, ScrollView, View } from 'react-native';

import { useNavigation } from '@react-navigation/native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { Button, Text } from 'react-native-paper';

import Settings from '../../assets/profile/settings.svg';
import { BackButton } from '../../components/nav_buttons/BackButton';
import { AddButtom } from '../../components/profile/AddButton';
import { CareTaker } from '../../components/profile/CareTaker';
import { useCareWalletContext } from '../../contexts/CareWalletContext';
import { AppStackNavigation } from '../../navigation/types';
import { useGroup } from '../../services/group';
import { useUsers } from '../../services/user';

export function CareGroup() {
const navigation = useNavigation<AppStackNavigation>();
const { user: signedInUser, group } = useCareWalletContext();
const [activeUser] = useState(signedInUser.userID);
const { roles, rolesAreLoading } = useGroup(group.groupID);
const { users, usersAreLoading } = useUsers(
roles?.map((role) => role.user_id) ?? []
);

if (rolesAreLoading || usersAreLoading) {
return (
<View className="w-full flex-1 items-center justify-center bg-carewallet-white text-3xl">
<ActivityIndicator size="large" />
<Text>Loading...</Text>
</View>
);
}

if (!roles || !users) {
return (
<View className="w-full flex-1 items-center justify-center bg-carewallet-white text-3xl">
<Text className="text-xl">Could Not Load Profile...</Text>
</View>
);
}
return (
<GestureHandlerRootView className="bg-carewallet-white pt-5">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have no idea but i removed it

<View className="flex flex-row items-center border-b border-carewallet-lightgray pb-5">
<View className="pl-2">
<BackButton />
</View>
<View className="mx-auto ">
<Text className="text-center font-carewallet-manrope-bold text-lg text-carewallet-blue ">
Care Group
</Text>
</View>
<View className="pr-2">
<AddButtom />
</View>
</View>

<ScrollView>
<View className="bg-carewallet-lightergray">
<View className="flex h-[10vh] items-center">
<View className="h-[10vh] scroll-pb-96">
<View className="flex w-full flex-row justify-end text-carewallet-black">
<Button
className="mx-auto mt-2 h-[50px] w-[96vw] items-start justify-center rounded-xl border-carewallet-lightgray bg-carewallet-white"
textColor="#000000"
mode="outlined"
icon={() => <Settings />} // Example using FontAwesome icon
>
<Text className="font-carewallet-manrope-semibold">
{' '}
Manage Caregiver Capabiities{' '}
</Text>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Text className="font-carewallet-manrope-semibold">
{' '}
Manage Caregiver Capabiities{' '}
</Text>
<Text className="font-carewallet-manrope-semibold">
Manage Caregiver Capabiities
</Text>

</Button>
</View>
</View>
</View>

<View className="mx-2 mt-2 flex h-[180vh] w-[96vw] flex-col items-center rounded-xl">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for 180vh here? Scroll view should handle height on its own

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

{users
.filter((user) => user.user_id !== activeUser)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should prob filter out patient as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

.map((user) => (
<View
key={user.user_id} // <-- Add key prop here
onTouchEnd={() => {
navigation.navigate('Profile');
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this able to set the active profile on profile page depending on who you click on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see ignore my comment from before. I'm trying to do it like this but I'm assuming that the navigate function doesn't take into account the new state even if it was set differently again?:

onPress={() => { setActiveUser(user.user_id) navigation.navigate('Profile'); }}

>
<CareTaker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a scroll bug when I am scrolling and had pressed on a card it will visit the card after i lift up my finger. Look at other scroll views on how we handled this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part should be fixed, although it still will navigate to 'Profile' and not the profile of the person it touches. since the profile component doesn't take in a userId or anything not sure how to navigate to the profile of an actual user without refactoring the profile component. any ideas or is it okay as is? @MattCMcCoy

user={user}
role={roles.find((role) => role.user_id === user.user_id)}
/>
</View>
))}
<View className="h-[70vh] pt-10"></View>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<View className="h-[70vh] pt-10"></View>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

</View>
</View>
</ScrollView>
</GestureHandlerRootView>
);
}
6 changes: 5 additions & 1 deletion client/screens/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ export default function Profile() {
/>
</View>
<View className="mb-auto flex-1 items-center">
<CircleCard Icon={<Settings />} ButtonText="Settings" />
<CircleCard
Icon={<Settings />}
ButtonText="Settings"
onTouchEnd={() => navigation.navigate('CareGroup')}
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This button is nested in settings on main. So when fixing merge conflicts, let caplan or I know if you have any problems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my latest commit i will have allowed it to navigate from the settings page by pressing the 'manage caregiver capabilities' button

</View>
<View className="mb-5 items-center">
<CircleCard
Expand Down
10 changes: 5 additions & 5 deletions client/screens/TaskCreation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
} from 'react-native-gesture-handler';

import { BackButton } from '../components/nav_buttons/BackButton';
import { AddressComponent } from '../components/task_creation/AddressComponent.tsx';
import { RadioGroup } from '../components/task_creation/RadioGroup.tsx';
import { TextInputLine } from '../components/task_creation/TextInputLine.tsx';
import { TextInputParagraph } from '../components/task_creation/TextInputParagraph.tsx';
import { TaskCreationJson } from '../types/task-creation-json.ts';
import { AddressComponent } from '../components/task_creation/AddressComponent';
import { RadioGroup } from '../components/task_creation/RadioGroup';
import { TextInputLine } from '../components/task_creation/TextInputLine';
import { TextInputParagraph } from '../components/task_creation/TextInputParagraph';
import { TaskCreationJson } from '../types/task-creation-json';

type ParamList = {
mt: {
Expand Down
4 changes: 2 additions & 2 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "expo/tsconfig.base",
"compilerOptions": {
"jsx": "react",
"strict": true,
"allowImportingTsExtensions": true
"strict": true
// "allowImportingTsExtensions": true
}
}
3 changes: 3 additions & 0 deletions go.mod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module carewallet

go 1.21.6