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GC,UAAU,YAAYK,MAAO,CAACC,SAAU,QAAQR,SAAEmC,EAAMI,WAAWC,MAAM,KAAK,GAAGC,MAAM,EAAG,OAFZL,UAQjGtC,EAAAA,EAAAA,MAAA,OAAKI,UAAU,aAAYF,SAAA,EACvBC,EAAAA,EAAAA,KAAA,YAAUC,UAAU,kBAAkBwC,aAAcnG,EAAQoG,IAAKxF,EAAayF,SAAWvC,GAAM7D,EAAW6D,EAAErC,OAAOmE,UACnHlC,EAAAA,EAAAA,KAAA,UAAQG,QAjFrBlC,UACXmC,EAAEC,iBAEF,IAAIuC,GAAU,EAQd,GANgB,KAAZtG,IACAsG,GAAU,GAKXA,EAAS,CAER,GAAsB,KADCtG,EAAQuG,OACL,CACtB,MAAMC,EAAa,CACfV,KAAM,QACNC,YAAa/F,EACbgG,WAAYzD,KAKhBxC,EAAY,IAAID,EAAU0G,IAG1B,IACI,MAAM3E,QAAY4E,EAAAA,EAAAA,IAAuB,CACrCC,OAAQC,aAAaC,QAAQ,MAC7BC,WAAYlH,EAAiByC,UAC7B0D,KAAM,QACNC,YAAa/F,EACb8G,UAAW,KAGG,MAAfjF,EAAIQ,QAAkBR,EAAIM,KAAK4E,SAAS,+BACvC9G,EAAW,IACXW,EAAYoG,QAAQpB,MAAQ,GA1E5C3F,EAAW,IA4EKI,GAAY4G,GAAWA,EAAU,IAEzC,CAAE,MAAOC,GACT,CACJ,CACJ,GAsCgDzD,UACpBC,EAAAA,EAAAA,KAAA,KAAGC,UAAU,sCAOrCD,EAAAA,EAAAA,KAACyD,EAAAA,EAAY,CAACC,QAASlH,EAASmH,YAAY,qBAGxD,C","sources":["views/riwayat/tanya-tim.js"],"sourcesContent":["import { useEffect, useState, useRef } from \"react\";\r\nimport { Link, useLocation, useNavigate } from \"react-router-dom\";\r\nimport { getDetailRiwayatOrder, getDataHelpDesk, createQuestionHelpDesk } from \"../../services/API\";\r\nimport LoadingAlert from \"../../component/alert/loadingAlert\";\r\nimport ScrollToBottom from 'react-scroll-to-bottom';\r\nimport useDetectKeyboardOpen from \"use-detect-keyboard-open\";\r\n\r\nfunction Chat() {\r\n const [dataRiwayatOrder, setDataRiwayatOrder] = useState([])\r\n const [dataChat, setDataChat] = useState([])\r\n const [message, setMessage] = useState('')\r\n const [loading, setLoading] = useState(true)\r\n const [inputKey, setInputKey] = useState(0)\r\n const [keyboardHeight, setKeyboardHeight] = useState(0)\r\n const maxRows = 1\r\n const location = useLocation()\r\n const navigate = useNavigate()\r\n const textareaRef = useRef(null)\r\n\r\n useEffect(() => {\r\n getDataRiwayatOrder()\r\n\r\n if('virtualKeyboard' in navigator) {\r\n navigator.virtualKeyboard.overlaysContent = true\r\n \r\n navigator.virtualKeyboard.addEventListener(\"geometrychange\", (event) => {\r\n const { x, y, width, height } = event.target.boundingRect;\r\n setKeyboardHeight(height)\r\n })\r\n }\r\n }, []); \r\n\r\n const getDataRiwayatOrder = async () => {\r\n setLoading(true)\r\n const res = await getDetailRiwayatOrder(location.state?.id)\r\n const response = await getDataHelpDesk(res.data.requestNo)\r\n setLoading(false)\r\n if (res.status === 200 && response.status === 200) {\r\n setDataRiwayatOrder(res.data)\r\n setDataChat(response.data.Table)\r\n }\r\n }\r\n\r\n const getNameRequestType = () => {\r\n if (dataRiwayatOrder && dataRiwayatOrder.requestd) {\r\n return dataRiwayatOrder.requestd.map((item) => item.namarequesttype).join(\", \")\r\n } else {\r\n return \"\"\r\n }\r\n }\r\n const clearInput = () => {\r\n setMessage('')\r\n }\r\n\r\n const createFormattedDate = () => {\r\n const currentDate = new Date();\r\n console.log(currentDate)\r\n const year = currentDate.getFullYear();\r\n const month = String(currentDate.getMonth() + 1).padStart(2, '0');\r\n const date = String(currentDate.getDate()).padStart(2, '0');\r\n const hours = String(currentDate.getHours()).padStart(2, '0');\r\n const minutes = String(currentDate.getMinutes()).padStart(2, '0');\r\n const seconds = String(currentDate.getSeconds()).padStart(2, '0');\r\n const milliseconds = String(currentDate.getMilliseconds()).padStart(3, '0');\r\n\r\n return `${year}-${month}-${date}T${hours}:${minutes}:${seconds}.${milliseconds}`;\r\n }\r\n\r\n const formatDate = (val) => {\r\n var date = new Date(val)\r\n\r\n var day = date.getDate().toLocaleString('en-US', { minimumIntegerDigits: 2, useGrouping: false })\r\n var month = (date.getMonth() + 1).toLocaleString('en-US', { minimumIntegerDigits: 2, useGrouping: false })\r\n var year = date.getFullYear().toLocaleString('en-US', { minimumIntegerDigits: 2, useGrouping: false })\r\n var hours = date.getHours().toLocaleString('en-US', { minimumIntegerDigits: 2, useGrouping: false })\r\n var minutes = date.getMinutes().toLocaleString('en-US', { minimumIntegerDigits: 2, useGrouping: false })\r\n var ampm = (date.getHours() >= 12) ? 'PM' : 'AM'\r\n \r\n hours = (hours % 12 === 0) ? 12 : hours % 12\r\n return `${ day }/${ month }/${ year } ${ hours }:${ minutes } ${ ampm }`\r\n }\r\n\r\n const handleGoBack = (e) => {\r\n e.preventDefault()\r\n \r\n navigate(-1)\r\n }\r\n\r\n\r\n const submit = async (e) => {\r\n e.preventDefault()\r\n\r\n let isValid = true\r\n\r\n if (message === \"\"){\r\n isValid = false\r\n }\r\n\r\n \r\n\r\n if(isValid) {\r\n const trimmedMessage = message.trim()\r\n if(trimmedMessage !== '') {\r\n const newMessage = {\r\n type: 'Tanya',\r\n Description: message,\r\n CreateDate: createFormattedDate()\r\n }\r\n\r\n \r\n\r\n setDataChat([...dataChat, newMessage]) \r\n // chatRef.current.scrollTop = chatRef.current.scrollHeight\r\n\r\n try {\r\n const res = await createQuestionHelpDesk({\r\n UserId: localStorage.getItem('id'),\r\n tRequestId: dataRiwayatOrder.requestNo,\r\n type: 'Tanya',\r\n Description: message,\r\n UserAgent: ''\r\n })\r\n \r\n if(res.status === 200 && res.data.includes('Succes submit Tanya Jawab')) {\r\n setMessage('')\r\n textareaRef.current.value = ''\r\n clearInput()\r\n setInputKey(prevKey => prevKey + 1)\r\n }\r\n } catch (error) {\r\n }\r\n }\r\n }\r\n }\r\n\r\n const isKeyboardOpen = useDetectKeyboardOpen()\r\n\r\n return (\r\n <>\r\n
{formatDate(dataRiwayatOrder?.createdate)}
\r\n{dataRiwayatOrder?.requestNo}
\r\nEQ : {dataRiwayatOrder?.equipment}
\r\n{getNameRequestType()}
\r\n{value.Description}
\r\n{value.CreateDate.split('T')[1].slice(0, 5)}
\r\n