Skip to content

Commit

Permalink
Merge pull request #1889 from ever-co/bug/task-screen-related-issues-…
Browse files Browse the repository at this point in the history
…java-error

fixed java type error for related issue add modal
  • Loading branch information
evereq authored Nov 28, 2023
2 parents 6ad3230 + bc20ab7 commit 2c693c4
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 147 deletions.
Original file line number Diff line number Diff line change
@@ -1,70 +1,66 @@
/* eslint-disable react-native/no-color-literals */
/* eslint-disable react-native/no-inline-styles */
import { StyleSheet, TouchableWithoutFeedback, View } from "react-native"
import React, { useCallback, useMemo, useState } from "react"
import Accordion from "../../../Accordion"
import { AntDesign, Entypo } from "@expo/vector-icons"
import { useStores } from "../../../../models"
import { useTeamTasks } from "../../../../services/hooks/features/useTeamTasks"
import { ITeamTask } from "../../../../services/interfaces/ITask"
import TaskLinkedIssue from "../components/TaskLinkedIssue"
import CreateLinkedIssueModal from "../components/CreateLinkedIssueModal"
import { StyleSheet, TouchableWithoutFeedback, View } from 'react-native';
import React, { useCallback, useMemo, useState } from 'react';
import Accordion from '../../../Accordion';
import { AntDesign, Entypo } from '@expo/vector-icons';
import { useStores } from '../../../../models';
import { useTeamTasks } from '../../../../services/hooks/features/useTeamTasks';
import { ITeamTask } from '../../../../services/interfaces/ITask';
import TaskLinkedIssue from '../components/TaskLinkedIssue';
import CreateLinkedIssueModal from '../components/CreateLinkedIssueModal';

const ChildIssues = () => {
const {
TaskStore: { detailedTask: task },
} = useStores()
const { teamTasks: tasks, updateTask } = useTeamTasks()
TaskStore: { detailedTask: task }
} = useStores();
const { teamTasks: tasks, updateTask } = useTeamTasks();

const [modalOpen, setModalOpen] = useState<boolean>(false)
const [isLoading, setIsLoading] = useState<boolean>(false)
const [modalOpen, setModalOpen] = useState<boolean>(false);
const [isLoading, setIsLoading] = useState<boolean>(false);

const childTasks = useMemo(() => {
const children = task?.children?.reduce((acc, item) => {
const $item = tasks.find((ts) => ts?.id === item?.id) || item
const $item = tasks.find((ts) => ts?.id === item?.id) || item;
if ($item) {
acc.push($item)
acc.push($item);
}
return acc
}, [] as ITeamTask[])
return acc;
}, [] as ITeamTask[]);

return children || []
}, [task, tasks])
return children || [];
}, [task, tasks]);

const onTaskSelect = useCallback(async (childTask: ITeamTask | undefined) => {
setIsLoading(true)
setIsLoading(true);
const updatedTask: ITeamTask = {
...childTask,
parentId: task?.id,
parent: task,
}
parent: task
};
await updateTask(updatedTask, childTask?.id).finally(() => {
setIsLoading(false)
setModalOpen(false)
})
}, [])
setIsLoading(false);
setModalOpen(false);
});
}, []);

const isTaskEpic = task?.issueType === "Epic"
const isTaskStory = task?.issueType === "Story"
const childrenTasks = task?.children?.map((t) => t?.id) || []
const isTaskEpic = task?.issueType === 'Epic';
const isTaskStory = task?.issueType === 'Story';
const childrenTasks = task?.children?.map((t) => t?.id) || [];

const unchildTasks = tasks.filter((childTask) => {
const hasChild = () => {
if (isTaskEpic) {
return childTask.issueType !== "Epic"
return childTask.issueType !== 'Epic';
} else if (isTaskStory) {
return childTask.issueType !== "Epic" && childTask.issueType !== "Story"
return childTask.issueType !== 'Epic' && childTask.issueType !== 'Story';
} else {
return (
childTask.issueType === "Bug" ||
childTask.issueType === "Task" ||
childTask.issueType === null
)
return childTask.issueType === 'Bug' || childTask.issueType === 'Task' || childTask.issueType === null;
}
}
};

return childTask?.id !== task?.id && !childrenTasks.includes(childTask?.id) && hasChild()
})
return childTask?.id !== task?.id && !childrenTasks.includes(childTask?.id) && hasChild();
});

return (
<Accordion
Expand Down Expand Up @@ -96,12 +92,12 @@ const ChildIssues = () => {
<TaskLinkedIssue key={task?.id} task={task} />
))}
</Accordion>
)
}
);
};

export default ChildIssues
export default ChildIssues;

const styles = StyleSheet.create({
headerElement: { alignItems: "center", flexDirection: "row", gap: 10 },
verticalSeparator: { borderRightColor: "#B1AEBC", borderRightWidth: 1, height: 20 },
})
headerElement: { alignItems: 'center', flexDirection: 'row', gap: 10 },
verticalSeparator: { borderRightColor: '#B1AEBC', borderRightWidth: 1, height: 20 }
});
Loading

0 comments on commit 2c693c4

Please sign in to comment.