From 23c2fee1b0d77f359dfff5b502b7a1c24cfd9de0 Mon Sep 17 00:00:00 2001
From: patela22 <39590072+patela22@users.noreply.github.com>
Date: Wed, 28 Feb 2024 14:59:11 -0500
Subject: [PATCH 1/8] feat(Bottom-Shelf): Adds the quick tasks to the library
---
client/components/QuickTaskCard.tsx | 25 +++++++
.../navigation/AppStackBottomTabNavigator.tsx | 3 +-
client/package.json | 3 +
client/screens/QuickTasks.tsx | 66 +++++++++++++++++++
client/services/task.ts | 43 ++++++++++++
client/types/label.ts | 5 ++
client/types/task.ts | 15 +++++
7 files changed, 159 insertions(+), 1 deletion(-)
create mode 100644 client/components/QuickTaskCard.tsx
create mode 100644 client/screens/QuickTasks.tsx
create mode 100644 client/services/task.ts
create mode 100644 client/types/label.ts
create mode 100644 client/types/task.ts
diff --git a/client/components/QuickTaskCard.tsx b/client/components/QuickTaskCard.tsx
new file mode 100644
index 0000000..d8907a0
--- /dev/null
+++ b/client/components/QuickTaskCard.tsx
@@ -0,0 +1,25 @@
+import React from 'react';
+import { Text, View } from 'react-native';
+
+export const QuickTaskCard = ({
+ name,
+ label
+}: {
+ name: String;
+ label: String;
+}): JSX.Element => {
+ return (
+
+
+
+
+ {name}
+
+
+
+ {label}
+
+
+
+ );
+};
diff --git a/client/navigation/AppStackBottomTabNavigator.tsx b/client/navigation/AppStackBottomTabNavigator.tsx
index 6793920..993d7c8 100644
--- a/client/navigation/AppStackBottomTabNavigator.tsx
+++ b/client/navigation/AppStackBottomTabNavigator.tsx
@@ -9,6 +9,7 @@ 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 QuickTasks from '../screens/QuickTasks';
const AppStackBottomTab = createBottomTabNavigator();
@@ -36,7 +37,7 @@ export function AppStackBottomTabNavigator() {
tabBarIcon: ({ color }) => ,
tabBarLabel: () =>
}}
- component={MedicationList}
+ component={QuickTasks}
/>
Loading...;
+ // }
+
+ const snapPoints = useMemo(() => ['70%'], []);
+ const bottomSheetRef = useRef(null);
+
+ const handleOpenPress = () => bottomSheetRef.current?.expand();
+ const handleClosePress = () => bottomSheetRef.current?.close();
+
+ const renderBackdrop = useCallback(
+ (props: any) => (
+
+ ),
+ []
+ );
+ return (
+
+
+
+
+ Today's Quick Tasks
+
+ }
+ keyExtractor={(item) => item.id}
+ renderItem={({ item }) => (
+
+ )}
+ />
+
+
+ );
+}
diff --git a/client/services/task.ts b/client/services/task.ts
new file mode 100644
index 0000000..ba2271c
--- /dev/null
+++ b/client/services/task.ts
@@ -0,0 +1,43 @@
+import { useQuery, useQueryClient } from '@tanstack/react-query';
+import axios from 'axios';
+
+import { TaskLabel } from '../types/label';
+import { Task } from '../types/task';
+import { api_url } from './api-links';
+
+type TaskQueryParams = {
+ taskID?: string;
+ groupID?: string;
+ createdBy?: string;
+ taskStatus?: string;
+ taskType?: string;
+ startDate?: string;
+ endDate?: string;
+};
+
+const getFilteredTasks = async (
+ queryParams: TaskQueryParams
+): Promise => {
+ const { data } = await axios.get(`${api_url}/tasks/filtered?`, {
+ params: queryParams
+ });
+ return data;
+};
+
+export const getTaskLabels = async (taskID: string): Promise => {
+ const { data } = await axios.get(`${api_url}/tasks/${taskID}/labels`);
+ return data;
+};
+
+export const useFilteredTasks = (queryParams: TaskQueryParams) => {
+ const queryClient = useQueryClient();
+ const { data: tasks, isLoading: tasksIsLoading } = useQuery({
+ queryKey: ['filteredTaskList', queryParams],
+ queryFn: () => getFilteredTasks(queryParams),
+ refetchInterval: 20000
+ });
+ return {
+ tasks,
+ tasksIsLoading
+ };
+};
diff --git a/client/types/label.ts b/client/types/label.ts
new file mode 100644
index 0000000..3a3e99c
--- /dev/null
+++ b/client/types/label.ts
@@ -0,0 +1,5 @@
+export interface TaskLabel {
+ task_id: number;
+ group_id: number;
+ label_name: string;
+}
diff --git a/client/types/task.ts b/client/types/task.ts
new file mode 100644
index 0000000..901812b
--- /dev/null
+++ b/client/types/task.ts
@@ -0,0 +1,15 @@
+export interface Task {
+ task_id: number;
+ group_id: number;
+ created_by: string;
+ created_date: string;
+ start_date?: string | null;
+ end_date?: string | null;
+ notes?: string | null;
+ repeating: boolean;
+ repeating_interval?: string | null;
+ repeating_end_date?: string | null;
+ task_status: string;
+ task_type: string;
+ task_info?: string | null;
+}
From 72e17fac10d83c9fe8dcf42e3f16a4f02dd566b8 Mon Sep 17 00:00:00 2001
From: patela22 <39590072+patela22@users.noreply.github.com>
Date: Thu, 14 Mar 2024 15:58:49 -0400
Subject: [PATCH 2/8] feat(quicktask): quicktask and backend routes updated and
working
---
backend/db/migrations/3.task.sql | 14 ++++--
backend/docs/docs.go | 11 +++++
backend/docs/swagger.json | 11 +++++
backend/docs/swagger.yaml | 7 +++
backend/models/task.go | 1 +
backend/schema/tasks/routes.go | 2 +
backend/schema/tasks/task_test.go | 71 +++++++++++++++++++---------
backend/schema/tasks/transactions.go | 17 ++++---
client/components/QuickTaskCard.tsx | 4 +-
client/screens/QuickTasks.tsx | 36 +++++++++-----
client/services/task.ts | 3 +-
client/types/task.ts | 3 +-
12 files changed, 129 insertions(+), 51 deletions(-)
diff --git a/backend/db/migrations/3.task.sql b/backend/db/migrations/3.task.sql
index 7da671b..e51152b 100644
--- a/backend/db/migrations/3.task.sql
+++ b/backend/db/migrations/3.task.sql
@@ -13,6 +13,7 @@ CREATE TABLE IF NOT EXISTS task (
created_date timestamp NOT NULL, -- add default val with current timestamp?
start_date timestamp,
end_date timestamp,
+ quick_task BOOLEAN DEFAULT FALSE,
notes varchar,
repeating BOOLEAN DEFAULT FALSE,
repeating_interval varchar,
@@ -38,12 +39,15 @@ 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 (group_id, created_by, created_date, start_date, end_date, notes, task_status, task_type, quick_task)
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')
+ (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', FALSE),
+ (2, 'user3', '2024-02-20 23:59:59', '2024-02-10 14:30:00', NULL, 'Schedule doctor appointment', 'INCOMPLETE', 'other', FALSE),
+ (3, 'user4', '2020-02-05 11:00:00', NULL, '2024-02-20 23:59:59', 'Submit insurance claim', 'PARTIAL', 'financial', FALSE),
+ (4, 'user1', '2006-01-02 15:04:05', NULL, NULL, 'Refill water pitcher', 'COMPLETE', 'other', TRUE),
+ (5, 'user1', '2024-02-05 11:00:00', '2024-02-05 11:00:00', '2024-02-05 11:00:00', 'Get medications', 'INCOMPLETE', 'dr_appt', TRUE),
+ (5, 'user2', '2024-02-05 11:00:00', '2024-02-05 11:00:00', '2024-02-05 11:00:00', 'File Papers', 'INCOMPLETE', 'med_mgmt', TRUE),
+ (5, 'user3', '2024-02-05 11:00:00', '2024-02-05 11:00:00', '2024-02-05 11:00:00', 'Send check to Drs', 'INCOMPLETE', 'financial', TRUE)
;
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..e3d2b28 100644
--- a/backend/docs/docs.go
+++ b/backend/docs/docs.go
@@ -520,6 +520,11 @@ const docTemplate = `{
"name": "groupID",
"in": "query"
},
+ {
+ "type": "string",
+ "name": "quickTask",
+ "in": "query"
+ },
{
"type": "string",
"name": "startDate",
@@ -1166,6 +1171,9 @@ const docTemplate = `{
"notes": {
"type": "string"
},
+ "quick_task": {
+ "type": "boolean"
+ },
"repeating": {
"type": "boolean"
},
@@ -1304,6 +1312,9 @@ const docTemplate = `{
"notes": {
"type": "string"
},
+ "quick_task": {
+ "type": "boolean"
+ },
"repeating": {
"type": "boolean"
},
diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json
index 1336662..9279d36 100644
--- a/backend/docs/swagger.json
+++ b/backend/docs/swagger.json
@@ -513,6 +513,11 @@
"name": "groupID",
"in": "query"
},
+ {
+ "type": "string",
+ "name": "quickTask",
+ "in": "query"
+ },
{
"type": "string",
"name": "startDate",
@@ -1159,6 +1164,9 @@
"notes": {
"type": "string"
},
+ "quick_task": {
+ "type": "boolean"
+ },
"repeating": {
"type": "boolean"
},
@@ -1297,6 +1305,9 @@
"notes": {
"type": "string"
},
+ "quick_task": {
+ "type": "boolean"
+ },
"repeating": {
"type": "boolean"
},
diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml
index 91b65c9..e348164 100644
--- a/backend/docs/swagger.yaml
+++ b/backend/docs/swagger.yaml
@@ -88,6 +88,8 @@ definitions:
type: integer
notes:
type: string
+ quick_task:
+ type: boolean
repeating:
type: boolean
repeating_end_date:
@@ -178,6 +180,8 @@ definitions:
type: integer
notes:
type: string
+ quick_task:
+ type: boolean
repeating:
type: boolean
repeating_end_date:
@@ -757,6 +761,9 @@ paths:
- in: query
name: groupID
type: string
+ - in: query
+ name: quickTask
+ type: string
- in: query
name: startDate
type: string
diff --git a/backend/models/task.go b/backend/models/task.go
index 4f700c2..b89f4c7 100644
--- a/backend/models/task.go
+++ b/backend/models/task.go
@@ -11,6 +11,7 @@ type Task struct {
CreatedDate time.Time `json:"created_date"`
StartDate *time.Time `json:"start_date"`
EndDate *time.Time `json:"end_date"`
+ QuickTask bool `json:"quick_task"`
Notes *string `json:"notes"`
Repeating bool `json:"repeating"`
RepeatingInterval *string `json:"repeating_interval"`
diff --git a/backend/schema/tasks/routes.go b/backend/schema/tasks/routes.go
index 9452a46..9ed97ee 100644
--- a/backend/schema/tasks/routes.go
+++ b/backend/schema/tasks/routes.go
@@ -70,6 +70,7 @@ type TaskQuery struct {
TaskType string `form:"taskType"`
StartDate string `form:"startDate"`
EndDate string `form:"endDate"`
+ QuickTask string `form:"quickTask"`
}
// GetFilteredTasks godoc
@@ -192,6 +193,7 @@ type TaskBody struct {
CreatedDate time.Time `json:"created_date"`
StartDate *time.Time `json:"start_date"`
EndDate *time.Time `json:"end_date"`
+ QuickTask bool `json:"quick_task"`
Notes *string `json:"notes"`
Repeating bool `json:"repeating"`
RepeatingInterval *string `json:"repeating_interval"`
diff --git a/backend/schema/tasks/task_test.go b/backend/schema/tasks/task_test.go
index 12847d8..3f883de 100644
--- a/backend/schema/tasks/task_test.go
+++ b/backend/schema/tasks/task_test.go
@@ -48,6 +48,7 @@ func TestTaskGroup(t *testing.T) {
TaskType: "other",
StartDate: "",
EndDate: "",
+ QuickTask: "",
}
w := httptest.NewRecorder()
@@ -58,6 +59,7 @@ func TestTaskGroup(t *testing.T) {
query.Set("taskType", getRequest.TaskType)
query.Set("startDate", getRequest.StartDate)
query.Set("endDate", getRequest.EndDate)
+ query.Set("quickTask", getRequest.QuickTask)
req, _ := http.NewRequest("GET", "/tasks/filtered?"+query.Encode(), nil)
router.ServeHTTP(w, req)
@@ -73,23 +75,41 @@ func TestTaskGroup(t *testing.T) {
t.Error("Failed to unmarshal json")
}
start_date_1 := time.Date(2024, 2, 10, 14, 30, 0, 0, time.UTC)
- expectedTasks := []models.Task{
+ notes_1 := "Schedule doctor appointment"
+ notes_2 := "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,
+ GroupID: 2,
+ CreatedBy: "user3",
+ CreatedDate: time.Date(2024, 2, 20, 23, 59, 59, 0, time.UTC),
+ StartDate: &start_date_1,
+ EndDate: nil,
+ QuickTask: false,
+ Notes: ¬es_1,
+ 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,
+ GroupID: 4,
+ CreatedBy: "user1",
+ CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC),
+ StartDate: nil,
+ EndDate: nil,
+ QuickTask: true,
+ Notes: ¬es_2,
+ Repeating: false,
+ RepeatingInterval: nil,
+ RepeatingEndDate: nil,
+ TaskStatus: "COMPLETE",
+ TaskType: "other",
+ TaskInfo: nil,
},
}
@@ -192,13 +212,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,
+ GroupID: 4,
+ CreatedBy: "user1",
+ CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC),
+ StartDate: nil,
+ EndDate: nil,
+ QuickTask: true,
+ Notes: ¬e,
+ Repeating: false,
+ RepeatingInterval: nil,
+ RepeatingEndDate: nil,
+ TaskStatus: "COMPLETE",
+ TaskType: "other",
+ TaskInfo: nil,
},
}
@@ -257,10 +284,10 @@ func TestTaskGroup(t *testing.T) {
TaskID: 1,
GroupID: 1,
CreatedBy: "user1",
- CreatedDate: time.Now().UTC(),
StartDate: &startDate,
EndDate: &endDate,
Notes: ¬es,
+ QuickTask: false,
Repeating: repeating,
RepeatingInterval: &repeatingInterval,
RepeatingEndDate: &repeatingEndDate,
diff --git a/backend/schema/tasks/transactions.go b/backend/schema/tasks/transactions.go
index 31895b5..459a109 100644
--- a/backend/schema/tasks/transactions.go
+++ b/backend/schema/tasks/transactions.go
@@ -18,9 +18,10 @@ func GetTasksByQueryFromDB(pool *pgx.Conn, filterQuery TaskQuery) ([]models.Task
filterQuery.TaskStatus,
filterQuery.TaskType,
filterQuery.StartDate,
- filterQuery.EndDate}
+ filterQuery.EndDate,
+ filterQuery.QuickTask}
- field_names := []string{"task_id =", "group_id =", "created_by =", "task_status =", "task_type =", "start_date >=", "end_date <="}
+ field_names := []string{"task_id =", "group_id =", "created_by =", "task_status =", "task_type =", "start_date >=", "end_date <=", "quick_task ="}
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 task_id, group_id, created_by, created_date, start_date, end_date, quick_task, notes, task_status, task_type, task_info FROM task WHERE "+query, args...)
if err != nil {
print(err, "error selecting tasks by query")
@@ -47,7 +48,7 @@ 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.GroupID, &task.CreatedBy, &task.CreatedDate, &task.StartDate, &task.EndDate, &task.QuickTask, &task.Notes, &task.TaskStatus, &task.TaskType, &task.TaskInfo)
if err != nil {
print(err, "error scanning tasks by query")
@@ -144,7 +145,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.GroupID, &task.CreatedBy, &task.CreatedDate, &task.StartDate, &task.EndDate, &task.QuickTask, &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
@@ -159,7 +160,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, quick_task, 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, $13) RETURNING task_id`
var newTaskID int
err := pool.QueryRow(
@@ -169,6 +170,7 @@ func CreateTaskInDB(pool *pgx.Conn, newTask models.Task) (int, error) {
time.Now(), // Assuming created_date should be the current timestamp
newTask.StartDate,
newTask.EndDate,
+ newTask.QuickTask,
newTask.Notes,
newTask.Repeating,
newTask.RepeatingInterval,
@@ -202,7 +204,7 @@ 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`
+ SELECT task_id, group_id, created_by, created_date, start_date, end_date, quick_task, notes, repeating, repeating_interval, repeating_end_date, task_status, task_type, task_info FROM task WHERE task_id = $1`
var task models.Task
err := pool.QueryRow(query, taskID).Scan(
@@ -212,6 +214,7 @@ func GetTaskByID(pool *pgx.Conn, taskID int) (models.Task, error) {
&task.CreatedDate,
&task.StartDate,
&task.EndDate,
+ &task.QuickTask,
&task.Notes,
&task.Repeating,
&task.RepeatingInterval,
diff --git a/client/components/QuickTaskCard.tsx b/client/components/QuickTaskCard.tsx
index d8907a0..4c5ed46 100644
--- a/client/components/QuickTaskCard.tsx
+++ b/client/components/QuickTaskCard.tsx
@@ -5,8 +5,8 @@ export const QuickTaskCard = ({
name,
label
}: {
- name: String;
- label: String;
+ name: string;
+ label: string;
}): JSX.Element => {
return (
diff --git a/client/screens/QuickTasks.tsx b/client/screens/QuickTasks.tsx
index d49a563..b5eadf7 100644
--- a/client/screens/QuickTasks.tsx
+++ b/client/screens/QuickTasks.tsx
@@ -7,24 +7,29 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { Button } from 'react-native-paper';
import { QuickTaskCard } from '../components/QuickTaskCard';
-
-// import { fetchTasks } from '../services/taskService';
+import { useCareWalletContext } from '../contexts/CareWalletContext';
+import { useFilteredTasks } from '../services/task';
export default function QuickTasks() {
- const tasks = [
- { id: '1', name: 'Take out the trash', label: 'Home' },
- { id: '2', name: 'Do the laundry', label: 'Laundry' },
- { id: '3', name: 'Wash the dishes', label: 'Kitchen' }
- ];
+ // const tasksEx = [
+ // { task_id: 1, notes: 'Take out the trash', task_type: 'Home' },
+ // { task_id: 2, notes: 'Do the laundry', task_type: 'Laundry' },
+ // { task_id: 3, notes: 'Wash the dishes', task_type: 'Kitchen' }
+ // ];
- // if (isLoading) {
- // return Loading...;
- // }
+ const { user: signedInUser, group } = useCareWalletContext();
+ const { tasks, tasksIsLoading } = useFilteredTasks({
+ groupID: group.groupID.toString(),
+ quickTask: true
+ });
const snapPoints = useMemo(() => ['70%'], []);
const bottomSheetRef = useRef(null);
- const handleOpenPress = () => bottomSheetRef.current?.expand();
+ const handleOpenPress = () => {
+ bottomSheetRef.current?.expand();
+ console.log(tasks);
+ };
const handleClosePress = () => bottomSheetRef.current?.close();
const renderBackdrop = useCallback(
@@ -38,11 +43,16 @@ export default function QuickTasks() {
),
[]
);
+
+ if (tasksIsLoading) {
+ return Loading...;
+ }
return (
}
- keyExtractor={(item) => item.id}
+ keyExtractor={(item) => item.task_id.toString()}
renderItem={({ item }) => (
-
+
)}
/>
diff --git a/client/services/task.ts b/client/services/task.ts
index ba2271c..1036fd3 100644
--- a/client/services/task.ts
+++ b/client/services/task.ts
@@ -13,12 +13,13 @@ type TaskQueryParams = {
taskType?: string;
startDate?: string;
endDate?: string;
+ quickTask?: boolean;
};
const getFilteredTasks = async (
queryParams: TaskQueryParams
): Promise => {
- const { data } = await axios.get(`${api_url}/tasks/filtered?`, {
+ const { data } = await axios.get(`${api_url}/tasks/filtered`, {
params: queryParams
});
return data;
diff --git a/client/types/task.ts b/client/types/task.ts
index 901812b..3e3da09 100644
--- a/client/types/task.ts
+++ b/client/types/task.ts
@@ -5,10 +5,11 @@ export interface Task {
created_date: string;
start_date?: string | null;
end_date?: string | null;
- notes?: string | null;
+ notes: string;
repeating: boolean;
repeating_interval?: string | null;
repeating_end_date?: string | null;
+ quick_task: boolean;
task_status: string;
task_type: string;
task_info?: string | null;
From 370483c51b9599d06a9840f9797ae32beb893d1b Mon Sep 17 00:00:00 2001
From: patela22 <39590072+patela22@users.noreply.github.com>
Date: Sat, 16 Mar 2024 00:01:29 -0400
Subject: [PATCH 3/8] fix(tests): Fixed the test result
---
backend/schema/tasks/task_test.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/backend/schema/tasks/task_test.go b/backend/schema/tasks/task_test.go
index 3f883de..84d36c1 100644
--- a/backend/schema/tasks/task_test.go
+++ b/backend/schema/tasks/task_test.go
@@ -260,6 +260,7 @@ func TestTaskGroup(t *testing.T) {
Notes: ¬e,
TaskStatus: "COMPLETE",
TaskType: "other",
+ QuickTask: true,
},
}
From e5edb04e096f56f532a238fb81705f4dc8c5b17d Mon Sep 17 00:00:00 2001
From: patela22 <39590072+patela22@users.noreply.github.com>
Date: Sat, 16 Mar 2024 13:46:50 -0400
Subject: [PATCH 4/8] fix(CI-Tests): fixing tests
---
client/components/QuickTaskCard.tsx | 13 +++++++------
client/navigation/AppStackBottomTabNavigator.tsx | 2 +-
client/screens/QuickTasks.tsx | 8 +++++---
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/client/components/QuickTaskCard.tsx b/client/components/QuickTaskCard.tsx
index 4c5ed46..302a985 100644
--- a/client/components/QuickTaskCard.tsx
+++ b/client/components/QuickTaskCard.tsx
@@ -1,13 +1,12 @@
import React from 'react';
import { Text, View } from 'react-native';
-export const QuickTaskCard = ({
- name,
- label
-}: {
+interface QuickTaskCardProps {
name: string;
label: string;
-}): JSX.Element => {
+}
+
+function QuickTaskCard({ name, label }: QuickTaskCardProps): JSX.Element {
return (
@@ -22,4 +21,6 @@ export const QuickTaskCard = ({
);
-};
+}
+
+export { QuickTaskCard };
diff --git a/client/navigation/AppStackBottomTabNavigator.tsx b/client/navigation/AppStackBottomTabNavigator.tsx
index 993d7c8..b0f2d7a 100644
--- a/client/navigation/AppStackBottomTabNavigator.tsx
+++ b/client/navigation/AppStackBottomTabNavigator.tsx
@@ -9,7 +9,7 @@ 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 QuickTasks from '../screens/QuickTasks';
+import { QuickTasks } from '../screens/QuickTasks';
const AppStackBottomTab = createBottomTabNavigator();
diff --git a/client/screens/QuickTasks.tsx b/client/screens/QuickTasks.tsx
index b5eadf7..73914d1 100644
--- a/client/screens/QuickTasks.tsx
+++ b/client/screens/QuickTasks.tsx
@@ -10,14 +10,14 @@ import { QuickTaskCard } from '../components/QuickTaskCard';
import { useCareWalletContext } from '../contexts/CareWalletContext';
import { useFilteredTasks } from '../services/task';
-export default function QuickTasks() {
+function QuickTasks(): JSX.Element {
// const tasksEx = [
// { task_id: 1, notes: 'Take out the trash', task_type: 'Home' },
// { task_id: 2, notes: 'Do the laundry', task_type: 'Laundry' },
// { task_id: 3, notes: 'Wash the dishes', task_type: 'Kitchen' }
// ];
- const { user: signedInUser, group } = useCareWalletContext();
+ const { group } = useCareWalletContext();
const { tasks, tasksIsLoading } = useFilteredTasks({
groupID: group.groupID.toString(),
quickTask: true
@@ -59,7 +59,7 @@ export default function QuickTasks() {
backdropComponent={renderBackdrop}
handleIndicatorStyle={{ backgroundColor: 'white' }}
>
- Today's Quick Tasks
+ Today's Quick Tasks
);
}
+
+export { QuickTasks };
From f9d1b429a0b48492e400f4beaf1a561f699e771c Mon Sep 17 00:00:00 2001
From: patela22 <39590072+patela22@users.noreply.github.com>
Date: Sat, 16 Mar 2024 17:13:01 -0400
Subject: [PATCH 5/8] fix(quickTasks): updated to pass tests
---
backend/models/task.go | 2 +-
backend/schema/tasks/task_test.go | 6 +++---
client/screens/QuickTasks.tsx | 33 ++++++++++++++++++++-----------
client/services/task.ts | 3 +--
4 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/backend/models/task.go b/backend/models/task.go
index b89f4c7..e016d7c 100644
--- a/backend/models/task.go
+++ b/backend/models/task.go
@@ -11,7 +11,7 @@ type Task struct {
CreatedDate time.Time `json:"created_date"`
StartDate *time.Time `json:"start_date"`
EndDate *time.Time `json:"end_date"`
- QuickTask bool `json:"quick_task"`
+ QuickTask bool `json:"quick_task"`
Notes *string `json:"notes"`
Repeating bool `json:"repeating"`
RepeatingInterval *string `json:"repeating_interval"`
diff --git a/backend/schema/tasks/task_test.go b/backend/schema/tasks/task_test.go
index 84d36c1..aae3daf 100644
--- a/backend/schema/tasks/task_test.go
+++ b/backend/schema/tasks/task_test.go
@@ -77,8 +77,8 @@ func TestTaskGroup(t *testing.T) {
start_date_1 := time.Date(2024, 2, 10, 14, 30, 0, 0, time.UTC)
notes_1 := "Schedule doctor appointment"
notes_2 := "Refill water pitcher"
-
- expectedTasks := []models.Task{
+
+ expectedTasks := []models.Task{
{
TaskID: 2,
GroupID: 2,
@@ -288,7 +288,7 @@ func TestTaskGroup(t *testing.T) {
StartDate: &startDate,
EndDate: &endDate,
Notes: ¬es,
- QuickTask: false,
+ QuickTask: false,
Repeating: repeating,
RepeatingInterval: &repeatingInterval,
RepeatingEndDate: &repeatingEndDate,
diff --git a/client/screens/QuickTasks.tsx b/client/screens/QuickTasks.tsx
index 73914d1..8aae529 100644
--- a/client/screens/QuickTasks.tsx
+++ b/client/screens/QuickTasks.tsx
@@ -1,7 +1,8 @@
// components/TasksPopup.tsx
import React, { useCallback, useMemo, useRef } from 'react';
-import { FlatList, Text, View } from 'react-native';
+import { ActivityIndicator, FlatList, Text, View } from 'react-native';
+import { BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
import BottomSheet, { BottomSheetBackdrop } from '@gorhom/bottom-sheet/';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { Button } from 'react-native-paper';
@@ -11,12 +12,6 @@ import { useCareWalletContext } from '../contexts/CareWalletContext';
import { useFilteredTasks } from '../services/task';
function QuickTasks(): JSX.Element {
- // const tasksEx = [
- // { task_id: 1, notes: 'Take out the trash', task_type: 'Home' },
- // { task_id: 2, notes: 'Do the laundry', task_type: 'Laundry' },
- // { task_id: 3, notes: 'Wash the dishes', task_type: 'Kitchen' }
- // ];
-
const { group } = useCareWalletContext();
const { tasks, tasksIsLoading } = useFilteredTasks({
groupID: group.groupID.toString(),
@@ -33,20 +28,33 @@ function QuickTasks(): JSX.Element {
const handleClosePress = () => bottomSheetRef.current?.close();
const renderBackdrop = useCallback(
- (props: any) => (
+ (props: BottomSheetBackdropProps) => (
),
[]
);
+ const taskTypeDescriptions: Record = {
+ med_mgmt: 'Medication Management',
+ dr_appt: 'Doctor Appointment',
+ financial: 'Financial Task',
+ other: 'Other Task'
+ };
+
if (tasksIsLoading) {
- return Loading...;
+ return (
+
+
+ Loading Tasks...
+
+ );
}
+
return (
@@ -67,7 +75,10 @@ function QuickTasks(): JSX.Element {
ItemSeparatorComponent={() => }
keyExtractor={(item) => item.task_id.toString()}
renderItem={({ item }) => (
-
+
)}
/>
diff --git a/client/services/task.ts b/client/services/task.ts
index 1036fd3..d9be515 100644
--- a/client/services/task.ts
+++ b/client/services/task.ts
@@ -1,4 +1,4 @@
-import { useQuery, useQueryClient } from '@tanstack/react-query';
+import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { TaskLabel } from '../types/label';
@@ -31,7 +31,6 @@ export const getTaskLabels = async (taskID: string): Promise => {
};
export const useFilteredTasks = (queryParams: TaskQueryParams) => {
- const queryClient = useQueryClient();
const { data: tasks, isLoading: tasksIsLoading } = useQuery({
queryKey: ['filteredTaskList', queryParams],
queryFn: () => getFilteredTasks(queryParams),
From 36cfc47e9b4796a2437f26c264af9e6b52c1a5f9 Mon Sep 17 00:00:00 2001
From: patela22 <39590072+patela22@users.noreply.github.com>
Date: Sat, 16 Mar 2024 20:51:01 -0400
Subject: [PATCH 6/8] fix(PR-edits): PR edits
n
---
client/screens/QuickTasks.tsx | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/client/screens/QuickTasks.tsx b/client/screens/QuickTasks.tsx
index 8aae529..6fca2c1 100644
--- a/client/screens/QuickTasks.tsx
+++ b/client/screens/QuickTasks.tsx
@@ -2,8 +2,10 @@
import React, { useCallback, useMemo, useRef } from 'react';
import { ActivityIndicator, FlatList, Text, View } from 'react-native';
-import { BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
-import BottomSheet, { BottomSheetBackdrop } from '@gorhom/bottom-sheet/';
+import BottomSheet, {
+ BottomSheetBackdrop,
+ BottomSheetBackdropProps
+} from '@gorhom/bottom-sheet/';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { Button } from 'react-native-paper';
@@ -39,6 +41,7 @@ function QuickTasks(): JSX.Element {
[]
);
+ // Todo: Look into if there is a change for this
const taskTypeDescriptions: Record = {
med_mgmt: 'Medication Management',
dr_appt: 'Doctor Appointment',
From 0725f88e0f6ad05be2778c52246c6b16629b90e5 Mon Sep 17 00:00:00 2001
From: patela22 <39590072+patela22@users.noreply.github.com>
Date: Mon, 18 Mar 2024 19:26:03 -0400
Subject: [PATCH 7/8] fix(format): formated the backend
---
backend/schema/tasks/task_test.go | 42 +++++++++++++++----------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/backend/schema/tasks/task_test.go b/backend/schema/tasks/task_test.go
index 56666c7..63f2b98 100644
--- a/backend/schema/tasks/task_test.go
+++ b/backend/schema/tasks/task_test.go
@@ -83,28 +83,28 @@ func TestTaskGroup(t *testing.T) {
expectedTasks := []models.Task{
{
- TaskID: 2,
+ 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,
+ GroupID: 2,
+ CreatedBy: "user3",
+ CreatedDate: time.Date(2024, 2, 20, 23, 59, 59, 0, time.UTC),
+ StartDate: &start_date_1,
EndDate: nil,
QuickTask: false,
Notes: ¬es_1,
Repeating: false,
RepeatingInterval: nil,
RepeatingEndDate: nil,
- TaskStatus: "INCOMPLETE",
- TaskType: "other",
+ TaskStatus: "INCOMPLETE",
+ TaskType: "other",
TaskInfo: nil,
},
{
- TaskID: 4,
+ TaskID: 4,
TaskTitle: "task 4",
- GroupID: 4,
- CreatedBy: "user1",
- CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC),
+ GroupID: 4,
+ CreatedBy: "user1",
+ CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC),
StartDate: nil,
EndDate: nil,
Repeating: false,
@@ -112,8 +112,8 @@ func TestTaskGroup(t *testing.T) {
RepeatingEndDate: nil,
QuickTask: true,
Notes: ¬es_2,
- TaskStatus: "COMPLETE",
- TaskType: "other",
+ TaskStatus: "COMPLETE",
+ TaskType: "other",
TaskInfo: nil,
},
}
@@ -218,20 +218,20 @@ func TestTaskGroup(t *testing.T) {
note := "Refill water pitcher"
expectedTasks := []models.Task{
{
- TaskID: 4,
+ TaskID: 4,
TaskTitle: "task 4",
- GroupID: 4,
- CreatedBy: "user1",
- CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC),
+ GroupID: 4,
+ CreatedBy: "user1",
+ CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC),
StartDate: nil,
EndDate: nil,
QuickTask: true,
- Notes: ¬e,
+ Notes: ¬e,
Repeating: false,
RepeatingInterval: nil,
RepeatingEndDate: nil,
- TaskStatus: "COMPLETE",
- TaskType: "other",
+ TaskStatus: "COMPLETE",
+ TaskType: "other",
TaskInfo: nil,
},
}
@@ -273,7 +273,7 @@ func TestTaskGroup(t *testing.T) {
RepeatingEndDate: nil,
TaskStatus: "COMPLETE",
TaskType: "other",
- QuickTask: true,
+ QuickTask: true,
TaskInfo: nil,
},
}
From 31197a5a6e034665a5a641aed522652bcc0ae989 Mon Sep 17 00:00:00 2001
From: patela22 <39590072+patela22@users.noreply.github.com>
Date: Tue, 19 Mar 2024 18:53:42 -0400
Subject: [PATCH 8/8] fix(update): fix rq
---
client/navigation/AppStackBottomTabNavigator.tsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/client/navigation/AppStackBottomTabNavigator.tsx b/client/navigation/AppStackBottomTabNavigator.tsx
index 4acbf1f..107c485 100644
--- a/client/navigation/AppStackBottomTabNavigator.tsx
+++ b/client/navigation/AppStackBottomTabNavigator.tsx
@@ -11,7 +11,6 @@ import TimelineCalendarScreen from '../screens/Calendar';
import MedicationList from '../screens/MedicationList';
import PatientView from '../screens/Profile/PatientView';
import Profile from '../screens/Profile/Profile';
-import { QuickTasks } from '../screens/QuickTasks';
import { AppStack } from './types';
const AppStackBottomTab = createBottomTabNavigator();