{childNode} | \n}\nexport default function Tasks(props) {\n const [form] = Form.useForm()\n const tableRef = useRef(null)\n const containerRef = useRef(null)\n const [modal, contextHolder] = Modal.useModal()\n const [addItemType, setAddItemType] = useState(\"\")\n const [editingTaskIndex, setEditingTaskIndex] = useState(-1)\n const [editingMsgIndex, setEditingMsgIndex] = useState(-1)\n const [loading, setLoading] = useState(false)\n const [saveLoading, setSaveLoading] = useState(false)\n const [tasksLoading, setTasksLoading] = useState(false)\n const [showCreateNewModal, setShowCreateNewModal] = useState(false)\n const [showSignatureModal, setShowSignatureModal] = useState(false)\n const [succeed, setSucceed] = useState(false)\n const [taskDocuments, setTaskDocuments] = useState([])\n const [addDocument, setAddDocument] = useState(false)\n const [searchedStatus, setSearchedStatus] = useState(\"\")\n const [taskList, setTaskList] = useState([])\n const [isViewfilesOpen, setIsViewfilesOpen] = useState(false)\n const [file, setFile] = useState([])\n const [uploadFile, setUploadFile] = useState(null)\n const [fileIndex, setFileIndex] = useState(0)\n const [numPages, setNumPages] = useState(null)\n const [pageNumber, setPageNumber] = useState(1)\n const [scale, setScale] = useState(1);\n const [pageWidth, setPageWidth] = useState(window.innerWidth)\n const [markList, setMarkList] = useState([])\n const [documentOptions, setDocumentOptions] = useState([])\n const [handleTransitionOpen, setHandleTransitionOpen] = useState(false)\n useEffect(() => {\n getusertasks()\n const handleResize = () => {\n let width = window.innerWidth\n if (width < 1312) {\n setPageWidth(window.innerWidth - 100)\n } else {\n setPageWidth(1200)\n }\n }\n handleResize()\n window.addEventListener('resize', handleResize)\n \n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [])\n useEffect(() => {\n setAddDocument(taskDocuments.length === 0)\n }, [taskDocuments])\n const setTransitioncheck = () => {\n let token = sessionStorage.getItem(\"ZeitroA\")\n let api = '/los/transitioncheckvisited'\n fetch(api, {\n method: 'GET',\n headers: {\n Authorization: \"Bearer \" + token,\n Cache: \"no-cache\",\n \"Content-Type\": \"application/json\",\n },\n \n }).then(\n response => {\n if (response.status !== 200) {\n console.log(\"Error post /los/getdocuments/:\", response)\n return;\n }\n setHandleTransitionOpen(true)\n }\n \n ).catch((err) => {\n console.log(err)\n })\n }\n const showCoborrower = () => {\n if (props.application.hascoborrower === \"withcoborrower\" && props.application.married) return true\n return false\n }\n const mergeTasks = (list) => {\n let updatedTaskList = []\n let tasksByType = {}\n list.forEach(task => {\n if (!(task.TaskType in tasksByType)) {\n tasksByType[task.TaskType] = []\n }\n tasksByType[task.TaskType].push(task)\n })\n for (let taskType in tasksByType) {\n let tasks = tasksByType[taskType]\n\n tasks.sort((a, b) => b.ID - a.ID)\n\n for (let i = 0; i < tasks.length; i++) {\n let currentTask = tasks[i]\n let mergedTask = { ...currentTask }\n\n if (taskType === 'action') {\n for (let j = i + 1; j < tasks.length; j++) {\n let nextTask = tasks[j]\n mergedTask.Items.push(...nextTask.Items)\n }\n }else {\n for (let j = i + 1; j < tasks.length; j++) {\n let nextTask = tasks[j]\n mergedTask.Documents.push(...nextTask.Documents)\n }\n }\n updatedTaskList.push(mergedTask)\n i = tasks.length\n }\n }\n return updatedTaskList\n }\n const getusertasks = () => {\n let token = sessionStorage.getItem(\"ZeitroA\")\n setTasksLoading(true)\n fetch('/los/getusertasks/'+props.loanid, {\n method: 'GET',\n headers: {\n Authorization: \"Bearer \" + token,\n Cache: \"no-cache\",\n \"Content-Type\": \"application/json\",\n },\n \n }).then(\n response => {\n setTasksLoading(false)\n if (response.status !== 200) {\n console.log(\"Error post /los/getusertasks/:\", response)\n return;\n }\n response.json().then(data => {\n const filterData = data.filter(item => item.TaskType !== 'upload')\n const tasks = filterData.length > 0 ? mergeTasks(filterData) : []\n const taskTypes = ['action', 'sign']\n const missingTaskTypes = taskTypes.filter(type => !tasks.some(task => task.TaskType === type))\n missingTaskTypes.forEach(type => {\n tasks.push({ Created: '', Deadline: '', Documents: [], ForWhom: '', ID: '', Items: [], Status: 'open', TaskID: 'other', TaskType: type, name: `New ${type} Task` });\n })\n console.log(tasks, 'tasks')\n setTaskList(tasks)\n })\n }\n \n ).catch((err) => {\n setTasksLoading(false)\n console.log(err)\n })\n }\n \n const deleteuserdocument = (id, type) => {\n let token = sessionStorage.getItem(\"ZeitroA\")\n let api = type === 'action' ? '/los/deleteuseractionitem/' : '/los/deleteuserdocument/'\n fetch(api + id, {\n method: 'GET',\n headers: {\n Authorization: \"Bearer \" + token,\n Cache: \"no-cache\",\n \"Content-Type\": \"application/json\",\n },\n }).then(\n response => {\n if (response.status !== 200) {\n return;\n }\n message.success({\n type: 'success',\n content: 'Delete successful!',\n })\n getusertasks()\n }\n ).catch((err) => {\n console.log(err)\n });\n }\n \n const mapType = (type) => {\n let map = {\n upload: 'Document upload',\n sign: 'Document sign',\n action: 'Customized task'\n }\n return map[type]\n }\n const noTasks = (item) => {\n if (item.TaskType === 'action') {\n return item.Items.length === 0\n } else {\n return item.Documents.length === 0\n }\n }\n const showCurrentTasks = () => {\n \n const customHeader = (item) => {\n let percent = 0\n let completed = 0\n if (item.TaskType === 'upload') {\n completed = item.Documents.filter(file => file.Data).length\n percent = (completed / item.Documents.length) * 100\n } else {\n if (item.TaskType === 'action') {\n completed = item.Status === 'closed' ? item.Items.length : 0\n } else {\n completed = item.Status === 'closed' ? item.Documents.length : 0\n }\n percent = item.Status === 'closed' ? 100 : 0\n }\n return (\n
{childNode} | \n }\n try {\n if (editing) {\n let ele = ;\n if (type === \"inputdollar\") {\n ele = (\n \n );\n } else if (type === \"inputdollarmonth\") {\n ele = (\n \n );\n } else if (type === \"select\") {\n ele = (\n \n );\n }\n childNode = (\n{childNode} | ;\n } catch (error) {\n returnNo data | ;\n }\n\n};\n\nconst IncomeSourcesTable = (props) => {\n const [dataSource, setDataSource] = useState(\n props.assetsandliabilities.accounts === null\n ? []\n : props.assetsandliabilities.accounts.map((a, i) => ({\n key: a.key,\n accounttype: a.accounttype,\n institution: a.bankname,\n accountnumber: a.account,\n balance: a.balance,\n }))\n );\n const handleDelete = (key) => {\n const newData = dataSource.filter((item) => item.key !== key);\n setDataSource(newData);\n sendData(newData)\n };\n const defaultColumns = [\n {\n title: \"ACCOUNT TYPE\",\n dataIndex: \"accounttype\",\n // width: \"30%\",\n type: \"select\",\n options: com.bankaccounttypes.map((c) => {\n return {\n value: c[0],\n label: c[1],\n };\n }),\n },\n {\n title: \"FINANCIAL INSTITUTION\",\n dataIndex: \"institution\",\n type: \"input\",\n },\n {\n title: \"ACCOUNT NUMBER\",\n dataIndex: \"accountnumber\",\n type: \"input\",\n },\n {\n title: \"CASH/MARKET VALUE\",\n dataIndex: \"balance\",\n type: \"inputdollar\",\n },\n {\n title: \"Delete\",\n dataIndex: \"operation\",\n fixed: 'right',\n width: 80,\n type: \"operation\",\n render: (_, record) =>\n dataSource.length >= 1 ? (\n