|
|
@ -1,10 +1,36 @@ |
|
|
|
import React from 'react'; |
|
|
|
import React, { useEffect, useState } from 'react'; |
|
|
|
|
|
|
|
import { useHistory } from 'react-router-dom'; |
|
|
|
import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; |
|
|
|
import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; |
|
|
|
|
|
|
|
|
|
|
|
const GanttFrame = React.memo((props) => { |
|
|
|
const GanttFrame = React.memo((props) => { |
|
|
|
|
|
|
|
const history = useHistory(); |
|
|
|
const { versionGanttId, idProject, token, ro, timestamp } = props; |
|
|
|
const { versionGanttId, idProject, token, ro, timestamp } = props; |
|
|
|
const iframeSrc = `https://adw-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}`; |
|
|
|
const iframeSrc = `https://adw-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}`; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [batchEntityData, setBatchEntityData] = useState(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
const handleMessage = (event) => { |
|
|
|
|
|
|
|
if (event.data && event.data.batchEntity) { |
|
|
|
|
|
|
|
setBatchEntityData(event.data.batchEntity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('message', handleMessage); |
|
|
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
|
|
|
|
const handleNavigation = (event) => { |
|
|
|
|
|
|
|
if (batchEntityData && batchEntityData !== '') { |
|
|
|
|
|
|
|
const message = 'You have unsaved changes. Are you sure you want to leave this page?'; |
|
|
|
|
|
|
|
return message; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
history.block(handleNavigation); |
|
|
|
|
|
|
|
}, [batchEntityData]) |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<iframe |
|
|
|
<iframe |
|
|
|
id="frame-gantt" |
|
|
|
id="frame-gantt" |
|
|
|