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] 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; +}