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

Feature/quick task screen frontend #52

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
14 changes: 9 additions & 5 deletions backend/db/migrations/3.task.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions backend/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ const docTemplate = `{
"name": "groupID",
"in": "query"
},
{
"type": "string",
"name": "quickTask",
"in": "query"
},
{
"type": "string",
"name": "startDate",
Expand Down Expand Up @@ -1166,6 +1171,9 @@ const docTemplate = `{
"notes": {
"type": "string"
},
"quick_task": {
"type": "boolean"
},
"repeating": {
"type": "boolean"
},
Expand Down Expand Up @@ -1304,6 +1312,9 @@ const docTemplate = `{
"notes": {
"type": "string"
},
"quick_task": {
"type": "boolean"
},
"repeating": {
"type": "boolean"
},
Expand Down
11 changes: 11 additions & 0 deletions backend/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@
"name": "groupID",
"in": "query"
},
{
"type": "string",
"name": "quickTask",
"in": "query"
},
{
"type": "string",
"name": "startDate",
Expand Down Expand Up @@ -1159,6 +1164,9 @@
"notes": {
"type": "string"
},
"quick_task": {
"type": "boolean"
},
"repeating": {
"type": "boolean"
},
Expand Down Expand Up @@ -1297,6 +1305,9 @@
"notes": {
"type": "string"
},
"quick_task": {
"type": "boolean"
},
"repeating": {
"type": "boolean"
},
Expand Down
7 changes: 7 additions & 0 deletions backend/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ definitions:
type: integer
notes:
type: string
quick_task:
type: boolean
repeating:
type: boolean
repeating_end_date:
Expand Down Expand Up @@ -178,6 +180,8 @@ definitions:
type: integer
notes:
type: string
quick_task:
type: boolean
repeating:
type: boolean
repeating_end_date:
Expand Down Expand Up @@ -757,6 +761,9 @@ paths:
- in: query
name: groupID
type: string
- in: query
name: quickTask
type: string
- in: query
name: startDate
type: string
Expand Down
1 change: 1 addition & 0 deletions backend/models/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 2 additions & 0 deletions backend/schema/tasks/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"`
Expand Down
70 changes: 49 additions & 21 deletions backend/schema/tasks/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func TestTaskGroup(t *testing.T) {
TaskType: "other",
StartDate: "",
EndDate: "",
QuickTask: "",
}

w := httptest.NewRecorder()
Expand All @@ -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)
Expand All @@ -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)
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: &notes_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: &notes_2,
Repeating: false,
RepeatingInterval: nil,
RepeatingEndDate: nil,
TaskStatus: "COMPLETE",
TaskType: "other",
TaskInfo: nil,
},
}

Expand Down Expand Up @@ -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: &note,
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: &note,
Repeating: false,
RepeatingInterval: nil,
RepeatingEndDate: nil,
TaskStatus: "COMPLETE",
TaskType: "other",
TaskInfo: nil,
},
}

Expand Down Expand Up @@ -233,6 +260,7 @@ func TestTaskGroup(t *testing.T) {
Notes: &note,
TaskStatus: "COMPLETE",
TaskType: "other",
QuickTask: true,
},
}

Expand All @@ -255,10 +283,10 @@ func TestTaskGroup(t *testing.T) {
TaskID: 1,
GroupID: 1,
CreatedBy: "user1",
CreatedDate: time.Now().UTC(),
StartDate: &startDate,
EndDate: &endDate,
Notes: &notes,
QuickTask: false,
Repeating: repeating,
RepeatingInterval: &repeatingInterval,
RepeatingEndDate: &repeatingEndDate,
Expand Down
17 changes: 10 additions & 7 deletions backend/schema/tasks/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand All @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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.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
Expand All @@ -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, 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(
Expand All @@ -168,6 +169,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,
Expand Down Expand Up @@ -201,7 +203,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(
Expand All @@ -211,6 +213,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,
Expand Down
26 changes: 26 additions & 0 deletions client/components/QuickTaskCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { Text, View } from 'react-native';

interface QuickTaskCardProps {
name: string;
label: string;
}

function QuickTaskCard({ name, label }: QuickTaskCardProps): JSX.Element {
return (
<View className="border-black h-[82px] w-[346px] self-center overflow-hidden rounded-[20px] border border-solid">
<View className="relative left-[19px] top-[17px] h-[48px] w-[295px]">
<View className="absolute left-0 top-0 h-[18px] w-[206px]">
<Text className="text-black absolute left-0 top-[2px] w-[206px] whitespace-nowrap text-[18px] font-[400] leading-[22px] tracking-[0px]">
{name}
</Text>
</View>
<Text className="text-black absolute left-0 top-[29px] w-[295px] text-[14px] font-[400] leading-[17px] tracking-[0px]">
{label}
</Text>
</View>
</View>
);
}

export { QuickTaskCard };
3 changes: 2 additions & 1 deletion client/navigation/AppStackBottomTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -36,7 +37,7 @@ export function AppStackBottomTabNavigator() {
tabBarIcon: ({ color }) => <Calendar color={color} />,
tabBarLabel: () => <Text></Text>
}}
component={MedicationList}
component={QuickTasks}
/>
<AppStackBottomTab.Screen
name="Notifications"
Expand Down
Loading
Loading