From 7139ac29458842703eabfe93a1f20eebc0a39b5b Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Mon, 18 Mar 2024 15:05:11 -0400 Subject: [PATCH 1/4] feat: add title to task db table --- backend/db/migrations/3.task.sql | 11 ++-- backend/docs/docs.go | 8 +++ backend/docs/swagger.json | 8 +++ backend/docs/swagger.yaml | 5 ++ backend/main.go | 17 +++--- backend/models/task.go | 1 + backend/schema/tasks/routes.go | 2 + backend/schema/tasks/task_test.go | 89 +++++++++++++++++++--------- backend/schema/tasks/transactions.go | 31 ++++------ 9 files changed, 112 insertions(+), 60 deletions(-) diff --git a/backend/db/migrations/3.task.sql b/backend/db/migrations/3.task.sql index 7da671b..1565c2b 100644 --- a/backend/db/migrations/3.task.sql +++ b/backend/db/migrations/3.task.sql @@ -8,6 +8,7 @@ CREATE TYPE task_type AS ENUM ('med_mgmt', 'dr_appt', 'financial', 'other'); CREATE TABLE IF NOT EXISTS task ( task_id serial NOT NULL, + task_title varchar NOT NULL, group_id integer NOT NULL, created_by varchar NOT NULL, created_date timestamp NOT NULL, -- add default val with current timestamp? @@ -38,12 +39,12 @@ CREATE TABLE IF NOT EXISTS task_assignees ( FOREIGN KEY (assigned_by) REFERENCES users (user_id) ); -INSERT INTO task (group_id, created_by, created_date, start_date, end_date, notes, task_status, task_type) +INSERT INTO task (task_title, group_id, created_by, created_date, start_date, end_date, notes, task_status, task_type) VALUES - (1, 'user2', '2024-02-03 10:45:00', '2024-02-05 10:00:00', '2024-02-05 11:00:00', 'Pick up medication from pharmacy', 'INCOMPLETE', 'med_mgmt'), - (2, 'user3', '2024-02-20 23:59:59', '2024-02-10 14:30:00', NULL, 'Schedule doctor appointment', 'INCOMPLETE', 'other'), - (3, 'user4', '2020-02-05 11:00:00', NULL, '2024-02-20 23:59:59', 'Submit insurance claim', 'PARTIAL', 'financial'), - (4, 'user1', '2006-01-02 15:04:05', NULL, NULL, 'Refill water pitcher', 'COMPLETE', 'other') + ('task 1', 1, 'user2', '2024-02-03 10:45:00', '2024-02-05 10:00:00', '2024-02-05 11:00:00', 'Pick up medication from pharmacy', 'INCOMPLETE', 'med_mgmt'), + ('task 2', 2, 'user3', '2024-02-20 23:59:59', '2024-02-10 14:30:00', NULL, 'Schedule doctor appointment', 'INCOMPLETE', 'other'), + ('task 3', 3, 'user4', '2020-02-05 11:00:00', NULL, '2024-02-20 23:59:59', 'Submit insurance claim', 'PARTIAL', 'financial'), + ('task 4', 4, 'user1', '2006-01-02 15:04:05', NULL, NULL, 'Refill water pitcher', 'COMPLETE', 'other') ; INSERT INTO task_assignees (task_id, user_id, assignment_status, assigned_by, assigned_date) diff --git a/backend/docs/docs.go b/backend/docs/docs.go index 751b7a3..471098b 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -535,6 +535,11 @@ const docTemplate = `{ "name": "taskStatus", "in": "query" }, + { + "type": "string", + "name": "taskTitle", + "in": "query" + }, { "type": "string", "name": "taskType", @@ -1187,6 +1192,9 @@ const docTemplate = `{ "task_status": { "type": "string" }, + "task_title": { + "type": "string" + }, "task_type": { "type": "string" } diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index 1336662..4a43d2d 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -528,6 +528,11 @@ "name": "taskStatus", "in": "query" }, + { + "type": "string", + "name": "taskTitle", + "in": "query" + }, { "type": "string", "name": "taskType", @@ -1180,6 +1185,9 @@ "task_status": { "type": "string" }, + "task_title": { + "type": "string" + }, "task_type": { "type": "string" } diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index 91b65c9..6ff3091 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -102,6 +102,8 @@ definitions: type: string task_status: type: string + task_title: + type: string task_type: type: string type: object @@ -766,6 +768,9 @@ paths: - in: query name: taskStatus type: string + - in: query + name: taskTitle + type: string - in: query name: taskType type: string diff --git a/backend/main.go b/backend/main.go index e5f1ee6..6fb1c0c 100644 --- a/backend/main.go +++ b/backend/main.go @@ -13,6 +13,7 @@ import ( "carewallet/schema/tasks" "carewallet/schema/user" "fmt" + "log" "os" "github.com/gin-gonic/gin" @@ -39,7 +40,14 @@ func main() { defer conn.Close() - r := gin.Default() + // prepare gin + // uncomment below mode if want to get back to release debug mode + //gin.SetMode(gin.ReleaseMode) + + // gin with default setup + r := gin.New() + r.Use(gin.Logger()) + r.Use(gin.Recovery()) v1 := r.Group("/") { @@ -67,10 +75,5 @@ func main() { r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) } - err = r.Run(":8080") - - if err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } + log.Fatalf("%v", r.Run(":8080")) } diff --git a/backend/models/task.go b/backend/models/task.go index 4f700c2..512e6ef 100644 --- a/backend/models/task.go +++ b/backend/models/task.go @@ -6,6 +6,7 @@ import ( type Task struct { TaskID int `json:"task_id"` + TaskTitle string `json:"task_title"` GroupID int `json:"group_id"` CreatedBy string `json:"created_by"` // User ID CreatedDate time.Time `json:"created_date"` diff --git a/backend/schema/tasks/routes.go b/backend/schema/tasks/routes.go index 9452a46..ff83402 100644 --- a/backend/schema/tasks/routes.go +++ b/backend/schema/tasks/routes.go @@ -64,6 +64,7 @@ func (pg *PgModel) GetTaskByID(c *gin.Context) { type TaskQuery struct { TaskID string `form:"taskID"` + TaskTitle string `form:"taskTitle"` GroupID string `form:"groupID"` CreatedBy string `form:"createdBy"` TaskStatus string `form:"taskStatus"` @@ -87,6 +88,7 @@ func (pg *PgModel) GetFilteredTasks(c *gin.Context) { var filterQuery TaskQuery if err := c.ShouldBindQuery(&filterQuery); err != nil { c.JSON(http.StatusBadRequest, err.Error()) + fmt.Println("error binding to query: ", err) return } tasks, err := GetTasksByQueryFromDB(pg.Conn, filterQuery) diff --git a/backend/schema/tasks/task_test.go b/backend/schema/tasks/task_test.go index 9ec9d8d..16462b4 100644 --- a/backend/schema/tasks/task_test.go +++ b/backend/schema/tasks/task_test.go @@ -42,6 +42,7 @@ func TestTaskGroup(t *testing.T) { t.Run("TestGetFilteredTasks", func(t *testing.T) { getRequest := TaskQuery{ + TaskTitle: "", GroupID: "", CreatedBy: "", TaskStatus: "", @@ -64,6 +65,7 @@ func TestTaskGroup(t *testing.T) { if http.StatusOK != w.Code { t.Error("Failed to retrieve tasks by filter query.") + return } var responseTasks []models.Task @@ -71,30 +73,49 @@ func TestTaskGroup(t *testing.T) { if err != nil { t.Error("Failed to unmarshal json") + return } start_date_1 := time.Date(2024, 2, 10, 14, 30, 0, 0, time.UTC) + note := "Schedule doctor appointment" + note2 := "Refill water pitcher" expectedTasks := []models.Task{ { - TaskID: 2, - GroupID: 2, - CreatedBy: "user3", - CreatedDate: time.Date(2024, 2, 20, 23, 59, 59, 0, time.UTC), - StartDate: &start_date_1, - TaskStatus: "INCOMPLETE", - TaskType: "other", + TaskID: 2, + TaskTitle: "task 2", + GroupID: 2, + CreatedBy: "user3", + CreatedDate: time.Date(2024, 2, 20, 23, 59, 59, 0, time.UTC), + StartDate: &start_date_1, + EndDate: nil, + Notes: ¬e, + Repeating: false, + RepeatingInterval: nil, + RepeatingEndDate: nil, + TaskStatus: "INCOMPLETE", + TaskType: "other", + TaskInfo: nil, }, { - TaskID: 4, - GroupID: 4, - CreatedBy: "user1", - CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC), - TaskStatus: "COMPLETE", - TaskType: "other", + TaskID: 4, + TaskTitle: "task 4", + GroupID: 4, + CreatedBy: "user1", + CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC), + StartDate: nil, + EndDate: nil, + Notes: ¬e2, + Repeating: false, + RepeatingInterval: nil, + RepeatingEndDate: nil, + TaskStatus: "COMPLETE", + TaskType: "other", + TaskInfo: nil, }, } if !reflect.DeepEqual(expectedTasks, responseTasks) { t.Error("Result was not correct") + return } }) @@ -192,13 +213,20 @@ func TestTaskGroup(t *testing.T) { note := "Refill water pitcher" expectedTasks := []models.Task{ { - TaskID: 4, - GroupID: 4, - CreatedBy: "user1", - CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC), - Notes: ¬e, - TaskStatus: "COMPLETE", - TaskType: "other", + TaskID: 4, + TaskTitle: "task 4", + GroupID: 4, + CreatedBy: "user1", + CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC), + StartDate: nil, + EndDate: nil, + Notes: ¬e, + Repeating: false, + RepeatingInterval: nil, + RepeatingEndDate: nil, + TaskStatus: "COMPLETE", + TaskType: "other", + TaskInfo: nil, }, } @@ -226,13 +254,20 @@ func TestTaskGroup(t *testing.T) { note := "Refill water pitcher" expectedTasks := []models.Task{ { - TaskID: 4, - GroupID: 4, - CreatedBy: "user1", - CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC), - Notes: ¬e, - TaskStatus: "COMPLETE", - TaskType: "other", + TaskID: 4, + TaskTitle: "task 4", + GroupID: 4, + CreatedBy: "user1", + CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC), + StartDate: nil, + EndDate: nil, + Notes: ¬e, + Repeating: false, + RepeatingInterval: nil, + RepeatingEndDate: nil, + TaskStatus: "COMPLETE", + TaskType: "other", + TaskInfo: nil, }, } diff --git a/backend/schema/tasks/transactions.go b/backend/schema/tasks/transactions.go index ba60f4c..b6294a3 100644 --- a/backend/schema/tasks/transactions.go +++ b/backend/schema/tasks/transactions.go @@ -13,6 +13,7 @@ import ( func GetTasksByQueryFromDB(pool *pgx.Conn, filterQuery TaskQuery) ([]models.Task, error) { query_fields := []string{ filterQuery.TaskID, + filterQuery.TaskTitle, filterQuery.GroupID, filterQuery.CreatedBy, filterQuery.TaskStatus, @@ -20,7 +21,7 @@ func GetTasksByQueryFromDB(pool *pgx.Conn, filterQuery TaskQuery) ([]models.Task filterQuery.StartDate, filterQuery.EndDate} - field_names := []string{"task_id =", "group_id =", "created_by =", "task_status =", "task_type =", "start_date >=", "end_date <="} + field_names := []string{"task_id =", "task_title =", "group_id =", "created_by =", "task_status =", "task_type =", "start_date >=", "end_date <="} var query string var args []interface{} @@ -34,7 +35,7 @@ func GetTasksByQueryFromDB(pool *pgx.Conn, filterQuery TaskQuery) ([]models.Task } } - rows, err := pool.Query("SELECT task_id, group_id, created_by, created_date, start_date, end_date, task_status, task_type FROM task WHERE "+query, args...) + rows, err := pool.Query("SELECT * FROM task WHERE "+query, args...) if err != nil { print(err, "error selecting tasks by query") @@ -47,10 +48,10 @@ func GetTasksByQueryFromDB(pool *pgx.Conn, filterQuery TaskQuery) ([]models.Task for rows.Next() { task := models.Task{} - err := rows.Scan(&task.TaskID, &task.GroupID, &task.CreatedBy, &task.CreatedDate, &task.StartDate, &task.EndDate, &task.TaskStatus, &task.TaskType) + err := rows.Scan(&task.TaskID, &task.TaskTitle, &task.GroupID, &task.CreatedBy, &task.CreatedDate, &task.StartDate, &task.EndDate, &task.Notes, &task.Repeating, &task.RepeatingInterval, &task.RepeatingEndDate, &task.TaskStatus, &task.TaskType, &task.TaskInfo) if err != nil { - print(err, "error scanning tasks by query") + print(err.Error(), "error scanning tasks by query") return nil, err } @@ -143,7 +144,7 @@ func GetTasksByAssignedFromDB(pool *pgx.Conn, userIDs []string) ([]models.Task, // Get all tasks by task ID var task models.Task for _, task_id := range task_ids { - err := pool.QueryRow("SELECT * FROM task WHERE task_id = $1;", task_id).Scan(&task.TaskID, &task.GroupID, &task.CreatedBy, &task.CreatedDate, &task.StartDate, &task.EndDate, &task.Notes, &task.Repeating, &task.RepeatingInterval, &task.RepeatingEndDate, &task.TaskStatus, &task.TaskType, &task.TaskInfo) + err := pool.QueryRow("SELECT * FROM task WHERE task_id = $1;", task_id).Scan(&task.TaskID, &task.TaskTitle, &task.GroupID, &task.CreatedBy, &task.CreatedDate, &task.StartDate, &task.EndDate, &task.Notes, &task.Repeating, &task.RepeatingInterval, &task.RepeatingEndDate, &task.TaskStatus, &task.TaskType, &task.TaskInfo) if err != nil { print(err, "error querying task by ID") return nil, err @@ -158,7 +159,7 @@ func GetTasksByAssignedFromDB(pool *pgx.Conn, userIDs []string) ([]models.Task, // CreateTaskInDB creates a new task in the database and returns its ID func CreateTaskInDB(pool *pgx.Conn, newTask models.Task) (int, error) { query := ` - INSERT INTO task (group_id, created_by, created_date, start_date, end_date, notes, repeating, repeating_interval, repeating_end_date, task_status, task_type, task_info) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING task_id` + INSERT INTO task (group_id, created_by, created_date, start_date, end_date, notes, repeating, repeating_interval, repeating_end_date, task_status, task_type, task_info, task_title) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) RETURNING task_id` var newTaskID int err := pool.QueryRow( @@ -175,6 +176,7 @@ func CreateTaskInDB(pool *pgx.Conn, newTask models.Task) (int, error) { newTask.TaskStatus, newTask.TaskType, newTask.TaskInfo, + newTask.TaskTitle, ).Scan(&newTaskID) return newTaskID, err @@ -200,24 +202,11 @@ func UpdateTaskInfoInDB(pool *pgx.Conn, taskID int, taskInfo json.RawMessage) er // GetTaskByID fetches a task from the database by its ID func GetTaskByID(pool *pgx.Conn, taskID int) (models.Task, error) { - query := ` - SELECT task_id, group_id, created_by, created_date, start_date, end_date, notes, repeating, repeating_interval, repeating_end_date, task_status, task_type, task_info FROM task WHERE task_id = $1` + query := `SELECT * FROM task WHERE task_id = $1` var task models.Task err := pool.QueryRow(query, taskID).Scan( - &task.TaskID, - &task.GroupID, - &task.CreatedBy, - &task.CreatedDate, - &task.StartDate, - &task.EndDate, - &task.Notes, - &task.Repeating, - &task.RepeatingInterval, - &task.RepeatingEndDate, - &task.TaskStatus, - &task.TaskType, - &task.TaskInfo, + &task.TaskID, &task.TaskTitle, &task.GroupID, &task.CreatedBy, &task.CreatedDate, &task.StartDate, &task.EndDate, &task.Notes, &task.Repeating, &task.RepeatingInterval, &task.RepeatingEndDate, &task.TaskStatus, &task.TaskType, &task.TaskInfo, ) return task, err } From ea1d7c49a8fdbb6cc7fe7eb8a428471fb7735947 Mon Sep 17 00:00:00 2001 From: Matt McCoy <59743922+MattCMcCoy@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:30:51 -0400 Subject: [PATCH 2/4] style: LET THERE BE COLOR (#53) --- client/tailwind.config.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/tailwind.config.js b/client/tailwind.config.js index a55a506..87c6280 100644 --- a/client/tailwind.config.js +++ b/client/tailwind.config.js @@ -6,7 +6,13 @@ module.exports = { 'carewallet-white': '#FFFFFF', 'carewallet-black': '#000000', 'carewallet-gray': '#BEBEBE', - 'carewallet-lightgray': '#D9D9D9' + 'carewallet-lightgray': '#D9D9D9', + 'carewallet-blue': '#1A56C4', + 'carewallet-green': '#4DB8A6', + 'carewallet-coral': '#FF6258', + 'carewallet-yellow': '#FFD9900', + 'carewallet-purple': '#990099', + 'carewallet-pink': '#FC2C51' } }, plugins: [] From fa9dcfbf856b8406ab7d54cd4dc1bc6e81733a0f Mon Sep 17 00:00:00 2001 From: Matt McCoy <59743922+MattCMcCoy@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:34:00 -0400 Subject: [PATCH 3/4] Feature/patient view (#50) * feat: patient view --- client/assets/profile/edit.svg | 12 +++++ client/components/profile/Header.tsx | 23 +++++---- client/components/profile/HealthStats.tsx | 30 ++++++++++++ .../components/profile/ProfileTopHeader.tsx | 42 ++++++++++------- client/navigation/AppNavigation.tsx | 7 ++- .../navigation/AppStackBottomTabNavigator.tsx | 27 +++++++++-- client/screens/Profile/PatientView.tsx | 47 +++++++++++++++++++ client/screens/{ => Profile}/Profile.tsx | 23 +++++---- 8 files changed, 173 insertions(+), 38 deletions(-) create mode 100644 client/assets/profile/edit.svg create mode 100644 client/components/profile/HealthStats.tsx create mode 100644 client/screens/Profile/PatientView.tsx rename client/screens/{ => Profile}/Profile.tsx (75%) diff --git a/client/assets/profile/edit.svg b/client/assets/profile/edit.svg new file mode 100644 index 0000000..aa15c67 --- /dev/null +++ b/client/assets/profile/edit.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/client/components/profile/Header.tsx b/client/components/profile/Header.tsx index b386ec4..9817d01 100644 --- a/client/components/profile/Header.tsx +++ b/client/components/profile/Header.tsx @@ -5,9 +5,11 @@ import { useNavigation } from '@react-navigation/native'; import { styled } from 'nativewind'; import ArrowLeft from '../../assets/arrow-left.svg'; +import Edit from '../../assets/profile/edit.svg'; import Ellipse from '../../assets/profile/ellipse.svg'; +import { useCareWalletContext } from '../../contexts/CareWalletContext'; import { AppStackNavigation } from '../../navigation/AppNavigation'; -import { GroupRole } from '../../types/group'; +import { GroupRole, Role } from '../../types/group'; import { User } from '../../types/user'; import { ProfileTopHeader } from './ProfileTopHeader'; @@ -19,6 +21,7 @@ interface HeaderProps { } export function Header({ user, role }: HeaderProps) { + const { user: signedInUser } = useCareWalletContext(); const navigate = useNavigation(); if (!user) return null; @@ -27,14 +30,18 @@ export function Header({ user, role }: HeaderProps) { <> - } - rightButtonText="Edit" - /> + {role?.role === Role.PATIENT || + signedInUser.userID !== user.user_id ? ( + } + /> + ) : ( + } /> + )} - {`${role?.role.charAt(0)}${role?.role.slice(1).toLowerCase()} Caregiver`} + {`${role?.role.charAt(0)}${role?.role.slice(1).toLowerCase()} ${role?.role !== Role.PATIENT ? 'Caretaker' : ''}`} {user.phone ? user.phone : user.email} diff --git a/client/components/profile/HealthStats.tsx b/client/components/profile/HealthStats.tsx new file mode 100644 index 0000000..102645f --- /dev/null +++ b/client/components/profile/HealthStats.tsx @@ -0,0 +1,30 @@ +import React, { useState } from 'react'; +import { FlatList, Pressable, View } from 'react-native'; + +export function HealthStats() { + const [canPress, setCanPress] = useState(true); + + return ( + setCanPress(false)} + onScrollEndDrag={() => setCanPress(true)} + horizontal + showsHorizontalScrollIndicator={false} + data={Array.from({ length: 10 }, (_, i) => i)} + renderItem={({ index }) => ( + { + if (canPress) console.log('Pressed'); + }} + > + + + + + )} + /> + ); +} diff --git a/client/components/profile/ProfileTopHeader.tsx b/client/components/profile/ProfileTopHeader.tsx index ae2acd7..74c66a4 100644 --- a/client/components/profile/ProfileTopHeader.tsx +++ b/client/components/profile/ProfileTopHeader.tsx @@ -1,38 +1,46 @@ import React from 'react'; -import { Pressable, Text, View } from 'react-native'; +import { Text, View } from 'react-native'; +import { useNavigation } from '@react-navigation/native'; +import { IconButton } from 'react-native-paper'; + +import { AppStackNavigation } from '../../navigation/AppNavigation'; import { User } from '../../types/user'; interface ProfileTopHeaderProps { user: User; - onTouchEndLeft?: () => void; + onTouchEndLeft?: AppStackNavigation; leftButtonText?: JSX.Element | string; onTouchEndRight?: () => void; - rightButtonText?: string; + rightButtonText?: JSX.Element | string; } export function ProfileTopHeader({ user, - onTouchEndLeft, leftButtonText, - onTouchEndRight, rightButtonText }: ProfileTopHeaderProps) { + const navigation = useNavigation(); return ( - - - - {leftButtonText} - - - + + {leftButtonText && ( + leftButtonText} + onPress={() => navigation.goBack()} + /> + )} + {user.first_name} {user.last_name} - - - {rightButtonText} - - + {rightButtonText && ( + rightButtonText} + /> + )} ); } diff --git a/client/navigation/AppNavigation.tsx b/client/navigation/AppNavigation.tsx index c407636..309a89b 100644 --- a/client/navigation/AppNavigation.tsx +++ b/client/navigation/AppNavigation.tsx @@ -12,12 +12,17 @@ export type AppStackParamList = { Home: undefined; Login: undefined; Profile: undefined; + PatientView: undefined; + ProfileScreens: undefined; + Landing: undefined; + Calendar: undefined; + Notifications: undefined; TaskType: undefined; }; export type AppStackNavigation = NavigationProp; -const AppStack = createNativeStackNavigator(); +export const AppStack = createNativeStackNavigator(); export function AppNavigation() { return ( diff --git a/client/navigation/AppStackBottomTabNavigator.tsx b/client/navigation/AppStackBottomTabNavigator.tsx index 6793920..3d42c31 100644 --- a/client/navigation/AppStackBottomTabNavigator.tsx +++ b/client/navigation/AppStackBottomTabNavigator.tsx @@ -8,9 +8,11 @@ import Calendar from '../assets/bottom-nav/calendar.svg'; import Home from '../assets/bottom-nav/home.svg'; import User from '../assets/bottom-nav/user.svg'; import MedicationList from '../screens/MedicationList'; -import Profile from '../screens/Profile'; +import PatientView from '../screens/Profile/PatientView'; +import Profile from '../screens/Profile/Profile'; +import { AppStack, AppStackParamList } from './AppNavigation'; -const AppStackBottomTab = createBottomTabNavigator(); +const AppStackBottomTab = createBottomTabNavigator(); export function AppStackBottomTabNavigator() { return ( @@ -48,14 +50,31 @@ export function AppStackBottomTabNavigator() { component={MedicationList} /> , tabBarLabel: () => }} - component={Profile} + component={AppNavigation} /> ); } + +export function AppNavigation() { + return ( + + + + + ); +} diff --git a/client/screens/Profile/PatientView.tsx b/client/screens/Profile/PatientView.tsx new file mode 100644 index 0000000..d2a2f2d --- /dev/null +++ b/client/screens/Profile/PatientView.tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import { Pressable, Text, View } from 'react-native'; + +import { CircleCard } from '../../components/profile/CircleCard'; +import { Header } from '../../components/profile/Header'; +import { HealthStats } from '../../components/profile/HealthStats'; +import { useCareWalletContext } from '../../contexts/CareWalletContext'; +import { useGroup } from '../../services/group'; +import { useUsers } from '../../services/user'; +import { Role } from '../../types/group'; + +export default function PatientView() { + const { group } = useCareWalletContext(); + const { roles } = useGroup(group.groupID); + const { users } = useUsers(roles?.map((role) => role.user_id) ?? []); + const patientId = roles?.find((role) => role.role === Role.PATIENT)?.user_id; + + return ( + +
user.user_id === patientId)} + role={roles?.find((role) => role.user_id === patientId)} + /> + + + + + + View Past Health Stats + + + + + + + Upload Files + + + + + View Files + + + + + ); +} diff --git a/client/screens/Profile.tsx b/client/screens/Profile/Profile.tsx similarity index 75% rename from client/screens/Profile.tsx rename to client/screens/Profile/Profile.tsx index 8cc764b..08a47d7 100644 --- a/client/screens/Profile.tsx +++ b/client/screens/Profile/Profile.tsx @@ -1,15 +1,19 @@ import React, { useState } from 'react'; import { ActivityIndicator, Text, View } from 'react-native'; -import { CircleCard } from '../components/profile/CircleCard'; -import { Group } from '../components/profile/Group'; -import { Header } from '../components/profile/Header'; -import { useCareWalletContext } from '../contexts/CareWalletContext'; -import { useAuth } from '../services/auth'; -import { useGroup } from '../services/group'; -import { useUsers } from '../services/user'; +import { useNavigation } from '@react-navigation/native'; + +import { CircleCard } from '../../components/profile/CircleCard'; +import { Group } from '../../components/profile/Group'; +import { Header } from '../../components/profile/Header'; +import { useCareWalletContext } from '../../contexts/CareWalletContext'; +import { AppStackNavigation } from '../../navigation/AppNavigation'; +import { useAuth } from '../../services/auth'; +import { useGroup } from '../../services/group'; +import { useUsers } from '../../services/user'; export default function Profile() { + const navigation = useNavigation(); const { user: signedInUser, group } = useCareWalletContext(); const [activeUser, setActiveUser] = useState(signedInUser.userID); const { roles, rolesAreLoading } = useGroup(group.groupID); @@ -61,7 +65,10 @@ export default function Profile() { - + navigation.navigate('PatientView')} + /> From d329142d770cdbb99a60a4d66e82829db8b411ed Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Mon, 18 Mar 2024 15:53:07 -0400 Subject: [PATCH 4/4] fix: cycle import in app nav --- client/navigation/AppNavigation.tsx | 21 +------------------ .../navigation/AppStackBottomTabNavigator.tsx | 8 +++---- client/navigation/types.ts | 19 +++++++++++++++++ client/screens/LoginPage.tsx | 2 +- client/screens/Profile/Profile.tsx | 2 +- client/screens/TaskType.tsx | 4 ++-- 6 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 client/navigation/types.ts diff --git a/client/navigation/AppNavigation.tsx b/client/navigation/AppNavigation.tsx index 309a89b..d84eff0 100644 --- a/client/navigation/AppNavigation.tsx +++ b/client/navigation/AppNavigation.tsx @@ -1,28 +1,9 @@ import React from 'react'; -import { NavigationProp } from '@react-navigation/native'; -import { createNativeStackNavigator } from '@react-navigation/native-stack'; - import LoginPage from '../screens/LoginPage'; import { TaskType } from '../screens/TaskType'; import { AppStackBottomTabNavigator } from './AppStackBottomTabNavigator'; - -export type AppStackParamList = { - Main: undefined; - Home: undefined; - Login: undefined; - Profile: undefined; - PatientView: undefined; - ProfileScreens: undefined; - Landing: undefined; - Calendar: undefined; - Notifications: undefined; - TaskType: undefined; -}; - -export type AppStackNavigation = NavigationProp; - -export const AppStack = createNativeStackNavigator(); +import { AppStack } from './types'; export function AppNavigation() { return ( diff --git a/client/navigation/AppStackBottomTabNavigator.tsx b/client/navigation/AppStackBottomTabNavigator.tsx index 3d42c31..4b3fb45 100644 --- a/client/navigation/AppStackBottomTabNavigator.tsx +++ b/client/navigation/AppStackBottomTabNavigator.tsx @@ -10,9 +10,9 @@ import User from '../assets/bottom-nav/user.svg'; import MedicationList from '../screens/MedicationList'; import PatientView from '../screens/Profile/PatientView'; import Profile from '../screens/Profile/Profile'; -import { AppStack, AppStackParamList } from './AppNavigation'; +import { AppStack } from './types'; -const AppStackBottomTab = createBottomTabNavigator(); +const AppStackBottomTab = createBottomTabNavigator(); export function AppStackBottomTabNavigator() { return ( @@ -56,13 +56,13 @@ export function AppStackBottomTabNavigator() { tabBarIcon: ({ color }) => , tabBarLabel: () => }} - component={AppNavigation} + component={ProfileNavigation} /> ); } -export function AppNavigation() { +export function ProfileNavigation() { return ( ; + +export const AppStack = createNativeStackNavigator(); diff --git a/client/screens/LoginPage.tsx b/client/screens/LoginPage.tsx index 21051a9..e23a132 100644 --- a/client/screens/LoginPage.tsx +++ b/client/screens/LoginPage.tsx @@ -5,7 +5,7 @@ import { onAuthStateChanged } from '@firebase/auth'; import { useNavigation } from '@react-navigation/native'; import { auth } from '../firebase.config'; -import { AppStackNavigation } from '../navigation/AppNavigation'; +import { AppStackNavigation } from '../navigation/types'; import { useAuth } from '../services/auth'; export default function LoginPage() { diff --git a/client/screens/Profile/Profile.tsx b/client/screens/Profile/Profile.tsx index 08a47d7..30f90c0 100644 --- a/client/screens/Profile/Profile.tsx +++ b/client/screens/Profile/Profile.tsx @@ -7,7 +7,7 @@ import { CircleCard } from '../../components/profile/CircleCard'; import { Group } from '../../components/profile/Group'; import { Header } from '../../components/profile/Header'; import { useCareWalletContext } from '../../contexts/CareWalletContext'; -import { AppStackNavigation } from '../../navigation/AppNavigation'; +import { AppStackNavigation } from '../../navigation/types'; import { useAuth } from '../../services/auth'; import { useGroup } from '../../services/group'; import { useUsers } from '../../services/user'; diff --git a/client/screens/TaskType.tsx b/client/screens/TaskType.tsx index 35bc59d..066ab6a 100644 --- a/client/screens/TaskType.tsx +++ b/client/screens/TaskType.tsx @@ -19,7 +19,7 @@ import { Button, Text } from 'react-native-paper'; import { BackButton } from '../components/TaskType/BackButton'; import { CloseButton } from '../components/TaskType/CloseButton'; -import { AppStackNavigation } from '../navigation/AppNavigation'; +import { AppStackNavigation } from '../navigation/types'; import { Category, categoryToTypeMap, TypeOfTask } from '../types/type'; export function TaskType() { @@ -99,7 +99,7 @@ export function TaskType() { renderItem={({ item }) => ( navigation.navigate('New ' + item + ' Task')} + onPress={() => navigation.navigate('Home')} >