-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Bottom-Shelf): Adds the quick tasks to the library
- Loading branch information
Showing
7 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
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,25 @@ | ||
import React from 'react'; | ||
import { Text, View } from 'react-native'; | ||
|
||
export const QuickTaskCard = ({ | ||
name, | ||
label | ||
}: { | ||
name: String; | ||
label: String; | ||
}): 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> | ||
); | ||
}; |
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,66 @@ | ||
// components/TasksPopup.tsx | ||
import React, { useCallback, useMemo, useRef } from 'react'; | ||
import { FlatList, Text, View } from 'react-native'; | ||
|
||
import BottomSheet, { BottomSheetBackdrop } from '@gorhom/bottom-sheet/'; | ||
import { GestureHandlerRootView } from 'react-native-gesture-handler'; | ||
import { Button } from 'react-native-paper'; | ||
|
||
import { QuickTaskCard } from '../components/QuickTaskCard'; | ||
|
||
// import { fetchTasks } from '../services/taskService'; | ||
|
||
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' } | ||
]; | ||
|
||
// if (isLoading) { | ||
// return <Text>Loading...</Text>; | ||
// } | ||
|
||
const snapPoints = useMemo(() => ['70%'], []); | ||
const bottomSheetRef = useRef<BottomSheet>(null); | ||
|
||
const handleOpenPress = () => bottomSheetRef.current?.expand(); | ||
const handleClosePress = () => bottomSheetRef.current?.close(); | ||
|
||
const renderBackdrop = useCallback( | ||
(props: any) => ( | ||
<BottomSheetBackdrop | ||
appearsOnIndex={0} | ||
disappearsOnIndex={-1} | ||
{...props} | ||
opacity={0.3} | ||
/> | ||
), | ||
[] | ||
); | ||
return ( | ||
<GestureHandlerRootView style={{ flex: 1 }}> | ||
<Button onPress={handleOpenPress}>Open</Button> | ||
<Button onPress={handleClosePress}>Close</Button> | ||
<BottomSheet | ||
snapPoints={snapPoints} | ||
ref={bottomSheetRef} | ||
enablePanDownToClose={true} | ||
backdropComponent={renderBackdrop} | ||
handleIndicatorStyle={{ backgroundColor: 'white' }} | ||
> | ||
<Text className="ml-6 text-lg font-bold">Today's Quick Tasks</Text> | ||
<View style={{ height: 10 }} /> | ||
<FlatList | ||
data={tasks} | ||
className="w-full align-middle" | ||
ItemSeparatorComponent={() => <View style={{ height: 10 }} />} | ||
keyExtractor={(item) => item.id} | ||
renderItem={({ item }) => ( | ||
<QuickTaskCard name={item.name} label={item.label} /> | ||
)} | ||
/> | ||
</BottomSheet> | ||
</GestureHandlerRootView> | ||
); | ||
} |
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,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<Task[]> => { | ||
const { data } = await axios.get(`${api_url}/tasks/filtered?`, { | ||
params: queryParams | ||
}); | ||
return data; | ||
}; | ||
|
||
export const getTaskLabels = async (taskID: string): Promise<TaskLabel[]> => { | ||
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<Task[]>({ | ||
queryKey: ['filteredTaskList', queryParams], | ||
queryFn: () => getFilteredTasks(queryParams), | ||
refetchInterval: 20000 | ||
}); | ||
return { | ||
tasks, | ||
tasksIsLoading | ||
}; | ||
}; |
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,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; | ||
} |