-
Notifications
You must be signed in to change notification settings - Fork 0
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/single task display screen #44
Closed
Closed
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7b3e223
feat(SingleTask.tsx): Hardcoded screen
narayansharma-21 b0c3391
feat(SingleTask.tsx): Added route functionality
narayansharma-21 ae2cd86
feat(SingleTask.tsx): Implemented entirety of v4 of lofi with additio…
narayansharma-21 7a432a8
fix(task.ts): Refactored service routes to use tanStack in the Single…
narayansharma-21 e49287f
fix(Attempted-to-fix-the-query): SingleTask.tsx
narayansharma-21 d70d203
fix(SingleTask.tsx): Fixed undefined error on xcode
narayansharma-21 0760bc7
Merge branch 'main' into feature/single-task-display-screen
narayansharma-21 8a2cfa5
fix(SingleTask.tsx): Bug fix
narayansharma-21 7139ac2
feat: add title to task db table
MattCMcCoy d329142
fix: cycle import in app nav
MattCMcCoy 17bc80a
Merge branch 'bugfix/cycleimport' into feature/addtitletotaskmodel
MattCMcCoy 0039498
fix(SingleTask.tsx): Initial fix to title issue
narayansharma-21 7cfd5f7
Merge remote-tracking branch 'origin/feature/addtitletotaskmodel' int…
narayansharma-21 3f3389c
fix(SingleTask.tsx): Utilized new backend route to dynamically show t…
narayansharma-21 8f16fba
fix(AppStackBottomTabNavigator): removed single task display from nav…
narayansharma-21 3c14bba
Merge branch 'main' into feature/single-task-display-screen
narayansharma-21 2325fa5
style(Task.tsx): Updated svgs and got rid of TaskInfo type
narayansharma-21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
|
||
import { useNavigation } from '@react-navigation/native'; | ||
import { Button } from 'react-native-paper'; | ||
|
||
import { AppStackNavigation } from '../navigation/AppNavigation'; | ||
|
||
// TODO style | ||
export function BackButton() { | ||
const navigation = useNavigation<AppStackNavigation>(); | ||
|
||
return ( | ||
<Button | ||
className="bg-carewallet-gray" | ||
onPress={() => navigation.goBack()} | ||
mode="contained" | ||
style={{ borderRadius: 8, marginTop: 16 }} | ||
contentStyle={{ height: 48 }} | ||
> | ||
Back | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import React, { useState } from 'react'; | ||
import { Text, TextInput, View } from 'react-native'; | ||
|
||
import DropDownPicker from 'react-native-dropdown-picker'; | ||
|
||
import CheckMark from '../assets/checkmark.svg'; | ||
import Reject from '../assets/reject.svg'; | ||
import { BackButton } from '../components/BackButton'; | ||
import { useGetTaskLabel } from '../services/task'; | ||
import { TaskInfo } from '../types/taskInfo'; | ||
import { Category, categoryToTypeMap, TypeOfTask } from '../types/type'; | ||
|
||
export default function SingleTaskScreen() { | ||
const [taskId] = useState<string>('1'); | ||
|
||
const [open, setOpen] = useState(false); | ||
|
||
const [taskType, setTaskType] = useState<TypeOfTask | undefined>( | ||
TypeOfTask.MEDICATION_MANAGEMENT | ||
); | ||
|
||
const label = useGetTaskLabel(taskId); | ||
|
||
// Would extract real information in future and not display default, placeholder info | ||
const [taskInfo] = useState({ | ||
created_date: '8:00AM', | ||
task_id: 1, | ||
task_info: { title: 'Doctors Appointment' }, | ||
notes: | ||
'Description here. Description here. Description here. Description here. Description here. Description here. Description here. Description here. Description here. Description here. Description here.' | ||
}); | ||
|
||
// Gets category based on Task Type | ||
const getCategoryFromTaskType = ( | ||
taskType: TypeOfTask | undefined | ||
): Category => { | ||
console.log(taskType); | ||
if (!taskType) { | ||
return Category.ALL; // Return a default category if taskType is undefined | ||
} | ||
// Iterate over each category in the categoryToTypeMap object | ||
for (const category in categoryToTypeMap) { | ||
// Check if the taskType exists in the current category's array of task types | ||
if (categoryToTypeMap[category as Category].includes(taskType)) { | ||
return category as Category; // Return the category if found | ||
} | ||
} | ||
return Category.ALL; // Return a default category if no match is found | ||
}; | ||
|
||
// Gets title from the task_info object | ||
const getTitleFromTaskInfo = (taskInfo: TaskInfo): string => { | ||
try { | ||
if ('title' in taskInfo) { | ||
return taskInfo.title; | ||
} else { | ||
return ''; | ||
} | ||
} catch (error) { | ||
console.error('Error parsing task info to extract title:', error); | ||
return ''; | ||
} | ||
}; | ||
|
||
return ( | ||
<View className="flex flex-col items-start p-4"> | ||
<View className="flex-row items-center"> | ||
<BackButton /> | ||
</View> | ||
<View className="absolute right-0 top-4 m-4"> | ||
<DropDownPicker | ||
// Very light placeholder for the real dropdown picker. Once backend routes are added | ||
// to update a task status, then this can be dynamically rendered | ||
open={open} | ||
value="value" | ||
items={[ | ||
{ label: 'INCOMPLETE', value: 'incomplete' }, | ||
{ label: 'COMPLETE', value: 'Complete' }, | ||
{ label: 'PARTIAL', value: 'Partial' } | ||
]} | ||
setOpen={setOpen} | ||
setValue={setTaskType} | ||
placeholder="To-do" | ||
containerStyle={{ height: 40, marginBottom: 8, width: 100 }} | ||
/> | ||
</View> | ||
<View className="mt-4"> | ||
<Text className="text-base ">{label || 'Label Here'}</Text> | ||
</View> | ||
<View className="mt-4"> | ||
<Text className="text-base "> | ||
{getCategoryFromTaskType(taskType) || 'Category Task'} | {taskType} | ||
</Text> | ||
</View> | ||
<View className="mt-4"> | ||
<Text className="text-black font-inter text-2xl font-bold"> | ||
{getTitleFromTaskInfo(taskInfo.task_info) || 'Doctor’s Appointment'}{' '} | ||
{'\n'} @ {taskInfo.created_date} | ||
</Text> | ||
</View> | ||
<View className="mt-2"> | ||
<Text className="text-black font-inter mb-4 text-base font-normal"> | ||
{taskInfo.notes} | ||
</Text> | ||
<Text className="text-black font-inter text-xl font-bold"> | ||
Additional Notes{' '} | ||
</Text> | ||
<TextInput className="border-black mb-2 h-32 w-80 rounded-lg border-2" /> | ||
</View> | ||
|
||
<View className="ml-auto flex-1 flex-row space-x-4"> | ||
{/* Once backend endpoints for assignining tasks are implemented, then can connect these buttons */} | ||
<CheckMark /> | ||
<Reject /> | ||
</View> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import axios from 'axios'; | ||
|
||
import { Task } from '../types/task'; | ||
import { TypeOfTask } from '../types/type'; | ||
import { api_url } from './api-links'; | ||
|
||
export const getTaskLabel = async ( | ||
taskID: string | undefined | ||
): Promise<string> => { | ||
const { data } = await axios.get(`${api_url}/tasks/${taskID}/labels`); | ||
return data.label_name; | ||
}; | ||
|
||
export const getTask = async (taskID: string): Promise<Task> => { | ||
const { data } = await axios.get(`${api_url}/tasks/${taskID}`); | ||
return data; | ||
}; | ||
|
||
export const useGetTaskLabel = (taskId: string | undefined): string => { | ||
const { data: label } = useQuery({ | ||
queryKey: ['taskId', taskId], | ||
queryFn: () => getTaskLabel(taskId) | ||
}); | ||
return label ?? ''; // Empty string if no label found | ||
}; | ||
|
||
// Helper Function to get Task Type by ID using getTaskId | ||
export const getTaskType = async (tid: string): Promise<TypeOfTask> => { | ||
try { | ||
const task = await getTask(tid); | ||
return task.task_type; | ||
} catch (error) { | ||
console.error('Error fetching task type:', error); | ||
throw error; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { TypeOfTask } from './type'; | ||
|
||
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: TypeOfTask; | ||
task_info?: JSON | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface TaskInfo { | ||
title: string; | ||
// Add other properties if needed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface TaskLabel { | ||
task_id: number; | ||
group_id: number; | ||
label_name: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
export enum TypeOfTask { | ||
MEDICATION_MANAGEMENT = 'Medication Management', | ||
PHYSICIAN_APPT = 'Physician Appointment', | ||
PRESCRIPTION_MGMT = 'Prescription Management', | ||
LABS_OUTPATIENT_SERVICES = 'Labs & Outpatient Services', | ||
REHAB_HOME_THERAPIES = 'Rehab/Home Therapies', | ||
TRANSITIONAL_CARE_COORD = 'Transitional Care Coordination', | ||
FAMILY_CONVERSATIONS = 'Family Conversations', | ||
TRANSPORTATION = 'Transportation', | ||
RESPITE_CAREGIVER_SUPPORT = 'Respite and Caregiver Support', | ||
HOME_SAFETY = 'Home Safety', | ||
HEALTH_INSURANCE = 'Health Insurance', | ||
MANAGING_EXPENSES_BILL_PAYMENTS = 'Managing Expenses & Bill Payments', | ||
LEGAL = 'Legal', | ||
FINANCIAL = 'Financial', | ||
OTHER = 'Other' | ||
} | ||
|
||
export enum Category { | ||
ALL = '', | ||
HEALTH = 'Health & Medication', | ||
PERSONAL = 'Personal', | ||
HOME = 'Home & Lifestyle', | ||
FINANCIAL = 'Financial & Legal' | ||
} | ||
|
||
export const categoryToTypeMap: Record<Category, TypeOfTask[]> = { | ||
[Category.ALL]: [], | ||
[Category.HEALTH]: [ | ||
TypeOfTask.MEDICATION_MANAGEMENT, | ||
TypeOfTask.PHYSICIAN_APPT, | ||
TypeOfTask.PRESCRIPTION_MGMT, | ||
TypeOfTask.LABS_OUTPATIENT_SERVICES, | ||
TypeOfTask.REHAB_HOME_THERAPIES, | ||
TypeOfTask.TRANSITIONAL_CARE_COORD, | ||
TypeOfTask.HEALTH_INSURANCE | ||
], | ||
[Category.PERSONAL]: [ | ||
TypeOfTask.FAMILY_CONVERSATIONS, | ||
TypeOfTask.RESPITE_CAREGIVER_SUPPORT | ||
], | ||
[Category.HOME]: [ | ||
TypeOfTask.TRANSPORTATION, | ||
TypeOfTask.REHAB_HOME_THERAPIES, | ||
TypeOfTask.TRANSITIONAL_CARE_COORD, | ||
TypeOfTask.HOME_SAFETY | ||
], | ||
[Category.FINANCIAL]: [ | ||
TypeOfTask.FINANCIAL, | ||
TypeOfTask.MANAGING_EXPENSES_BILL_PAYMENTS | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra package.json not needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :ahhhhhhhhh: forgot about that |
||
"dependencies": { | ||
"@tanstack/react-query": "^5.24.1", | ||
"react-native-dropdown-picker": "^5.4.6" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prolly shouldnt be apart of bottom nav
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah for sure, just put it there so it'd be easy for me to access when testing on expo and since I didn't have access to the other task screens. I can just pull it out from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove from bottom nav?