Skip to content

Commit

Permalink
Refactor/app nav (#77)
Browse files Browse the repository at this point in the history
* feat: complete refactor of the calendar component

* feat: add task button on calendar

* style: selected day color

* style: background on calendar

* feat: status pill to quick task

* style: general stuff

* refactor: general refactor of status pill

* feat: home dash small start idk bored

* feat: task details nav

* refactor: general change to getstatus to get actual pill JSX

* feat: folder structure things

* fix: remove file preview from upload

* fix: file title auto fill after selecting an image

* fix: remove plus sign

* refactor: general cleanup

* refactor: app nav

* refactor: folder structure cleanup

* style: fix some font things to match designs

* fix(fix-setting-overdue-tasks): no

no

no

* fix(it-didn't-save-this-smol-change): reorder of args in if statement

* fix(tet-fix): fix

---------

Co-authored-by: andrewcaplan1 <[email protected]>
  • Loading branch information
2 people authored and wyattchris committed Apr 16, 2024
1 parent 3050ba6 commit 528bb78
Show file tree
Hide file tree
Showing 21 changed files with 398 additions and 185 deletions.
20 changes: 12 additions & 8 deletions backend/db/migrations/3.task.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ CREATE TABLE IF NOT EXISTS task (
group_id integer NOT NULL,
created_by varchar NOT NULL,
created_date timestamp NOT NULL, -- add default val with current timestamp?
start_date timestamp,
end_date timestamp,
start_date timestamp NOT NULL,
end_date timestamp NOT NULL,
quick_task BOOLEAN DEFAULT FALSE,
notes varchar,
repeating BOOLEAN DEFAULT FALSE,
Expand Down Expand Up @@ -44,17 +44,17 @@ CREATE TABLE IF NOT EXISTS task_assignees (
INSERT INTO task (task_title, group_id, created_by, created_date, start_date, end_date, notes, task_status, task_type, quick_task)
VALUES
('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', FALSE),
('task 2', 2, 'user3', '2024-02-20 23:59:59', '2024-02-10 14:30:00', NULL, 'Schedule doctor appointment', 'INCOMPLETE', 'other', FALSE),
('task 3', 3, 'user4', '2020-02-05 11:00:00', NULL, '2024-02-20 23:59:59', 'Submit insurance claim', 'INPROGRESS', 'financial', FALSE),
('task 4', 4, 'user1', '2006-01-02 15:04:05', NULL, NULL, 'Refill water pitcher', 'COMPLETE', 'other', TRUE),
('task 2', 2, 'user3', '2024-02-20 23:59:59', '2024-02-10 14:30:00', '2024-02-10 14:30:00', 'Schedule doctor appointment', 'TODO', 'other', FALSE),
('task 3', 3, 'user4', '2020-02-05 11:00:00', '2024-02-10 14:30:00', '2024-02-20 23:59:59', 'Submit insurance claim', 'INPROGRESS', 'financial', FALSE),
('task 4', 4, 'user1', '2006-01-02 15:04:05', '2024-02-10 14:30:00', '2024-02-10 14:30:00', 'Refill water pitcher', 'COMPLETE', 'other', TRUE),
('task 1 - NO LABEL', 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),
('task 5', 5, 'user1', '2024-03-19 11:00:00', '2024-03-19 15:00:00', '2024-03-19 19:00:00', 'Get medications', 'INCOMPLETE', 'dr_appt', TRUE),
('task 6', 5, 'user2', '2024-03-19 11:00:00', '2024-03-19 11:00:00', '2024-03-19 13:00:00', 'File Papers', 'INCOMPLETE', 'med_mgmt', TRUE),
('task 7', 5, 'user3', '2024-03-19 11:00:00', '2024-03-19 07:00:00', '2024-03-19 09:00:00', 'Send check to Drs', 'INCOMPLETE', 'financial', TRUE),
('task 8', 5, 'user1', '2024-03-19 11:00:00', '2024-03-19 15:00:00', '2024-03-19 19:00:00', 'Get medications', 'INCOMPLETE', 'dr_appt', FALSE),
('task 9', 5, 'user2', '2024-03-19 11:00:00', '2024-03-19 11:00:00', '2024-03-19 13:00:00', 'File Papers', 'INCOMPLETE', 'med_mgmt', FALSE),
('task 10', 5, 'user3', '2024-03-19 11:00:00', '2024-03-19 07:00:00', '2024-03-19 09:00:00', 'Send check to Drs', 'INCOMPLETE', 'financial', FALSE),
('test tile', 5, 'P03ggWcw63N0RSY7ltbkeBoR6bd2', '2020-02-05 11:00:00', NULL, '2024-02-20 23:59:59', 'Submit insurance claim', 'INPROGRESS', 'financial', FALSE),
('test tile', 5, 'P03ggWcw63N0RSY7ltbkeBoR6bd2', '2020-02-05 11:00:00', '2024-02-20 23:59:59', '2024-02-20 23:59:59', 'Submit insurance claim', 'INPROGRESS', 'financial', FALSE),
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-03-29 07:00:00', '2024-03-29 08:00:00', 'Schedule doctor appointment', 'TODO', 'med_mgmt', TRUE),
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-03-29 08:00:00', '2024-03-29 09:00:00', 'Schedule doctor appointment', 'INPROGRESS', 'med_mgmt', TRUE),
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-03-29 09:00:00', '2024-03-29 10:00:00', 'Schedule doctor appointment', 'TODO', 'med_mgmt', TRUE),
Expand All @@ -68,7 +68,9 @@ VALUES
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-03-29 11:00:00', '2024-03-29 11:00:00', 'Schedule doctor appointment', 'TODO', 'med_mgmt', FALSE),
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-03-29 12:00:00', '2024-03-29 13:00:00', 'Schedule doctor appointment', 'TODO', 'med_mgmt', FALSE),
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-03-29 13:00:00', '2024-03-29 13:00:00', 'Schedule doctor appointment', 'INPROGRESS', 'med_mgmt', FALSE),
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-03-29 19:00:00', '2024-03-29 23:00:00', 'Schedule doctor appointment', 'OVERDUE', 'med_mgmt', TRUE)
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-03-29 19:00:00', '2024-04-29 23:00:00', 'Schedule doctor appointment', 'TODO', 'med_mgmt', TRUE),
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-04-10 13:00:00', '2024-04-10 13:00:00', 'Schedule doctor appointment', 'INPROGRESS', 'med_mgmt', FALSE),
('test tile', 5, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', '2024-02-20 23:59:59', '2024-04-10 19:00:00', '2024-04-10 23:00:00', 'Schedule doctor appointment', 'TODO', 'med_mgmt', TRUE)
;

INSERT INTO task_assignees (task_id, user_id, assignment_status, assigned_by, assigned_date)
Expand All @@ -84,5 +86,7 @@ VALUES
(17, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'NOTIFIED', 'user3', NOW()),
(18, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'DECLINED', 'user4', NOW()),
(19, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'ACCEPTED', 'user2', NOW()),
(20, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'NOTIFIED', 'user3', NOW())
(20, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'NOTIFIED', 'user3', NOW()),
(27, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'ACCEPTED', 'user2', NOW()),
(28, 'fIoFY26mJnYWH8sNdfuVoxpnVnr1', 'NOTIFIED', 'user3', NOW())
;
3 changes: 2 additions & 1 deletion backend/db/migrations/4.label.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ VALUES
(4, 'Household', 'purple'),
(1, 'Household', 'purple'),
(5, 'Financial', 'orange'),
(5, 'Appointments', 'green')
(5, 'Appointments', 'green'),
(5, 'Old People <3', 'red')
;

INSERT INTO task_labels (task_id, group_id, label_name)
Expand Down
18 changes: 10 additions & 8 deletions backend/schema/tasks/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func TestTaskGroup(t *testing.T) {
CreatedBy: "user3",
CreatedDate: time.Date(2024, 2, 20, 23, 59, 59, 0, time.UTC),
StartDate: &start_date_1,
EndDate: nil,
EndDate: &start_date_1,
QuickTask: false,
Notes: &notes_1,
Repeating: false,
RepeatingInterval: nil,
RepeatingEndDate: nil,
TaskStatus: "INCOMPLETE",
TaskStatus: "OVERDUE",
TaskType: "other",
TaskInfo: nil,
},
Expand All @@ -104,8 +104,8 @@ func TestTaskGroup(t *testing.T) {
GroupID: 4,
CreatedBy: "user1",
CreatedDate: time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC),
StartDate: nil,
EndDate: nil,
StartDate: &start_date_1,
EndDate: &start_date_1,
Repeating: false,
RepeatingInterval: nil,
RepeatingEndDate: nil,
Expand Down Expand Up @@ -215,15 +215,16 @@ func TestTaskGroup(t *testing.T) {
}

note := "Refill water pitcher"
start_date_1 := time.Date(2024, 2, 10, 14, 30, 0, 0, time.UTC)
expectedTasks := []models.Task{
{
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,
StartDate: &start_date_1,
EndDate: &start_date_1,
QuickTask: true,
Notes: &note,
Repeating: false,
Expand Down Expand Up @@ -257,15 +258,16 @@ func TestTaskGroup(t *testing.T) {
}

note := "Refill water pitcher"
start_date_1 := time.Date(2024, 2, 10, 14, 30, 0, 0, time.UTC)
expectedTasks := []models.Task{
{
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,
StartDate: &start_date_1,
EndDate: &start_date_1,
Notes: &note,
Repeating: false,
RepeatingInterval: nil,
Expand Down
52 changes: 47 additions & 5 deletions backend/schema/tasks/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ func getTasksByQueryFromDB(pool *pgxpool.Pool, filterQuery TaskQuery) ([]models.
results = append(results, task)
}

results, err = setTasksOverdue(results)

if err != nil {
print(err.Error(), "error setting tasks to overdue")
return nil, err
}

return results, nil
}

Expand Down Expand Up @@ -157,7 +164,14 @@ func getTasksByAssignedFromDB(pool *pgxpool.Pool, userIDs []string) ([]models.Ta
tasks = append(tasks, task)
}

return tasks, nil
newTasks, err := setTasksOverdue(tasks)

if err != nil {
print(err.Error(), "error setting tasks to overdue")
return nil, err
}

return newTasks, nil
}

// CreateTaskInDB creates a new task in the database and returns its ID
Expand Down Expand Up @@ -199,9 +213,7 @@ func deleteTaskInDB(pool *pgxpool.Pool, taskID int) error {
// UpdateTaskInfoInDB updates all fields of a task in the database
func updateTaskInfoInDB(pool *pgxpool.Pool, taskID int, taskFields models.Task) error {
// Construct the SQL query dynamically based on the task_fields parameter
query := `
UPDATE task SET task_title = $1, group_id = $2, created_by = $3, created_date = $4, start_date = $5, end_date = $6, quick_task = $7, notes = $8, repeating = $9, repeating_interval = $10, repeating_end_date = $11, task_status = $12, task_type = $13, task_info = $14 WHERE task_id = $15
`
query := `UPDATE task SET task_title = $1, group_id = $2, created_by = $3, created_date = $4, start_date = $5, end_date = $6, quick_task = $7, notes = $8, repeating = $9, repeating_interval = $10, repeating_end_date = $11, task_status = $12, task_type = $13, task_info = $14 WHERE task_id = $15`

// Execute the SQL query with the provided task fields and task ID
_, err := pool.Exec(context.Background(), query,
Expand All @@ -221,6 +233,7 @@ func updateTaskInfoInDB(pool *pgxpool.Pool, taskID int, taskFields models.Task)
taskFields.TaskInfo,
taskID,
)

return err
}

Expand All @@ -246,7 +259,20 @@ func getTaskByID(pool *pgxpool.Pool, taskID int) (models.Task, error) {
&task.TaskType,
&task.TaskInfo,
)
return task, err

if err != nil {
print(err.Error(), "error querying task by ID")
return task, err
}

tasks, err := setTasksOverdue([]models.Task{task})

if err != nil {
print(err.Error(), "error setting tasks to overdue")
return task, err
}

return tasks[len(tasks)-1], err
}

func getUsersAssignedToTaskFromDB(pool *pgxpool.Pool, taskID int) ([]string, error) {
Expand Down Expand Up @@ -275,3 +301,19 @@ func getUsersAssignedToTaskFromDB(pool *pgxpool.Pool, taskID int) ([]string, err

return userIDs, nil
}

func setTasksOverdue(tasks []models.Task) ([]models.Task, error) {
// Get the current date
currentDate := time.Now()

for i, task := range tasks {
// Check if the current date is greater than the end date of the task and isnt complete
if task.TaskStatus != "COMPLETE" && task.TaskStatus != "INCOMPLETE" && currentDate.After(*task.EndDate) {
// If it is, set the task status to "OVERDUE"
tasks[i].TaskStatus = "OVERDUE"
}
}

// Return the updated tasks
return tasks, nil
}
1 change: 0 additions & 1 deletion client/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@
"projectId": "c66c08fd-ea3e-4a67-84da-77ef27bb3c23"
}
}
// "owner": "andrew10"
}
}
2 changes: 1 addition & 1 deletion client/assets/filledarrowdown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 20 additions & 27 deletions client/components/ChooseFileButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Dimensions, Image, Text, TouchableOpacity, View } from 'react-native';
import { Text, TouchableOpacity, View } from 'react-native';

import { clsx } from 'clsx';
import { DocumentPickerAsset } from 'expo-document-picker';
Expand All @@ -14,31 +14,24 @@ export function ChooseFileButton({
picked: DocumentPickerAsset | null;
}) {
return (
<TouchableOpacity
onPress={onPress}
className={clsx(
'mt-2 flex h-[30vh] w-full items-center justify-center rounded-lg border-[3px] border-dashed border-carewallet-lightgray',
picked && 'h-[50vh]'
)}
>
{picked ? (
<View className="w-full items-center justify-center">
<Image
source={{
uri: picked.uri,
width: Dimensions.get('window').width / 2,
height: Dimensions.get('window').height / 3
}}
/>
</View>
) : (
<>
<Upload />
<Text className="text-medium font-carewallet-manrope-bold text-carewallet-black">
CHOOSE FILE
</Text>
</>
)}
</TouchableOpacity>
<View className="w-full flex-1">
<TouchableOpacity
onPress={onPress}
className={clsx(
'mt-2 flex h-[33vh] w-full items-center justify-center rounded-lg border-[3px] border-dashed border-carewallet-lightgray'
)}
>
{picked ? (
<Text className="my-20 ml-2">{picked.name}</Text>
) : (
<>
<Upload />
<Text className="text-medium font-carewallet-manrope-bold text-carewallet-black">
CHOOSE FILE
</Text>
</>
)}
</TouchableOpacity>
</View>
);
}
22 changes: 17 additions & 5 deletions client/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,28 @@ export function CWDropdown({
<View className="absolute right-3">
{isOpen ? (
<View className="rotate-180">
<ArrowDown />
<ArrowDown color="black" />
</View>
) : (
<ArrowDown />
<ArrowDown color="black" />
)}
</View>
</View>
<View className="flex w-[90vw] max-w-[90vw] flex-row" />
{isOpen && (
<View className="flex flex-row flex-wrap rounded-b-lg border border-carewallet-blue/20">
<View className="absolute top-14 flex flex-row flex-wrap rounded-b-lg border border-carewallet-blue/20 bg-carewallet-white">
{selected !== 'Select Label' && (
<View
className="h-14 w-full justify-center border-t border-carewallet-blue/20"
onTouchEnd={() => {
setLabel('Select Label');
setIsOpen(false);
}}
>
<Text className="w-40 text-ellipsis bg-carewallet-white pl-2 font-carewallet-manrope text-lg">
{''}
</Text>
</View>
)}
{items?.map(
(item, index) =>
item !== selected && (
Expand All @@ -51,7 +63,7 @@ export function CWDropdown({
setIsOpen(false);
}}
>
<Text className="w-40 text-ellipsis pl-2 font-carewallet-manrope text-lg">
<Text className="w-40 text-ellipsis bg-carewallet-white pl-2 font-carewallet-manrope text-lg">
{item}
</Text>
</View>
Expand Down
21 changes: 21 additions & 0 deletions client/components/home/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { Text, View } from 'react-native';

import moment from 'moment';

import { User } from '../../types/user';

export function Header({ user }: { user: User | undefined }) {
const currentTime = moment();
return (
<View>
<Text className="font-carewallet-manrope-semibold text-2xl text-carewallet-black">
{currentTime.format('A') === 'AM'
? `Good Morning ${user?.first_name ?? ''}!`
: currentTime.hour() >= 12 && currentTime.hour() < 15
? `Good Afternoon ${user?.first_name ?? ''}!`
: `Good Evening ${user?.first_name ?? ''}!`}
</Text>
</View>
);
}
Loading

0 comments on commit 528bb78

Please sign in to comment.