Skip to content

Commit

Permalink
refactor: added empty state when theres not an action for a subtask
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOduneye committed Dec 7, 2023
1 parent a5ce98f commit 2298141
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
1 change: 0 additions & 1 deletion client-new/src/components/task/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ const FormComponent = ({ actions, subTaskName }: FormComponentProps) => {
}
};

// </View >
return (
<View>
{actions.map((action, index) => (
Expand Down
31 changes: 26 additions & 5 deletions client-new/src/screens/app/tasks/SubTaskScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getActions } from '@/services/ActionsService';
import React from 'react';
import React, { useEffect } from 'react';
import { useQuery } from '@tanstack/react-query';
import { Button, ScrollView, Text, View, HStack, Pressable } from 'native-base';
import Icon from "react-native-vector-icons/Ionicons";
Expand All @@ -10,6 +10,7 @@ import BackArrowIcon from '@/components/icons/BackArrow';
import ActivityLoader from '@/components/reusable/ActivityLoader';
import { heightPercentageToDP as h, widthPercentageToDP as w } from 'react-native-responsive-screen';
import { moderateScale, verticalScale } from '@/utils/FontSizeUtils';
import NoTaskIcon from '@/components/icons/NoTaskIcon';

type SubTaskScreenProps = {
route: any
Expand All @@ -23,6 +24,10 @@ const SubTaskScreen = ({ route, navigation }: SubTaskScreenProps) => {
queryFn: () => getActions(subtask?.id)
});

useEffect(() => {
console.log(data);
}, [data]);

return (
<ScrollView backgroundColor={'#FFFAF2'}>
<View marginX={w('5%')} marginTop={h('5%')}>
Expand Down Expand Up @@ -58,11 +63,27 @@ const SubTaskScreen = ({ route, navigation }: SubTaskScreenProps) => {
</View>
{isLoading && <ActivityLoader />}
{error && <Text> error </Text>}
{data === null && <Text> null </Text>}
{data && data.actions && (
<View width={"100%"}>
<FormComponent actions={data.actions} subTaskName={subtask.sub_task_name} />
{data === null || (data && Object.keys(data).length === 0) ? (
<View width={"100%"} marginTop={h('10%')} justifyContent="center" alignItems="center">
<NoTaskIcon />

<Text
marginTop={h('2%')}
fontSize={moderateScale(16)}
lineHeight={verticalScale(19)}
fontWeight={'400'}
fontFamily={"Inter_400Regular"}
color={'gray.500'}
>
No Actions Available (yet)
</Text>
</View>
) : (
data && data.actions && (
<View width={"100%"}>
<FormComponent actions={data.actions} subTaskName={subtask.sub_task_name} />
</View>
)
)}
</View>
</ScrollView>
Expand Down

0 comments on commit 2298141

Please sign in to comment.