@@ -6,6 +6,11 @@ import Table from '../Utilities/Table'
66import bitsFetch from '../../Utils/bitsFetch'
77import CopyText from '../Utilities/CopyText'
88import noData from '../../resource/img/nodata.svg'
9+ import Button from '../Utilities/Button'
10+ import CloseIcn from '../../Icons/CloseIcn'
11+ import Modal from '../Utilities/Modal'
12+ import { json } from 'react-router'
13+ import EyeIcn from '../Utilities/EyeIcn'
914
1015function Log ( { allIntegURL } ) {
1116 const { id, type } = useParams ( )
@@ -16,6 +21,7 @@ function Log({ allIntegURL }) {
1621 const [ countEntries , setCountEntries ] = useState ( 0 )
1722 const [ isLoading , setIsLoading ] = useState ( false )
1823 const [ refreshLog , setRefreshLog ] = useState ( 0 )
24+ const [ response , setResponse ] = useState ( false )
1925
2026 const [ log , setLog ] = useState ( [ ] )
2127 const [ cols , setCols ] = useState ( [
@@ -36,17 +42,18 @@ function Log({ allIntegURL }) {
3642 minWidth : 200 ,
3743 Header : __ ( 'Response' , 'bit-integrations' ) ,
3844 accessor : 'response_obj' ,
39- Cell : ( val ) => (
40- < CopyText
41- value = { val . row . values . response_obj }
42- setSnackbar = { setSnackbar }
43- className = "cpyTxt"
44- />
45+ Cell : val => (
46+ < >
47+ < CopyText value = { val . row . values . response_obj } setSnackbar = { setSnackbar } className = "cpyTxt" />
48+ < Button className = "icn-btn" onClick = { ( ) => setResponse ( val . row . values . response_obj ) } >
49+ < EyeIcn size = "14" className = "icn-rotate-45" />
50+ </ Button >
51+ </ >
4552 )
4653 } ,
4754 { width : 220 , minWidth : 200 , Header : __ ( 'Date' , 'bit-integrations' ) , accessor : 'created_at' }
4855 ] )
49- const setTableCols = useCallback ( ( newCols ) => {
56+ const setTableCols = useCallback ( newCols => {
5057 setCols ( newCols )
5158 } , [ ] )
5259 // route is info/:id but for redirect uri need to make new/:type
@@ -73,7 +80,7 @@ function Log({ allIntegURL }) {
7380 entries . push ( rows . original . id )
7481 }
7582 const ajaxData = { id : entries }
76- bitsFetch ( ajaxData , 'log/delete' ) . then ( ( res ) => {
83+ bitsFetch ( ajaxData , 'log/delete' ) . then ( res => {
7784 if ( res . success ) {
7885 if ( action && action . fetchData && action . data ) {
7986 action . fetchData ( action . data )
@@ -128,7 +135,7 @@ function Log({ allIntegURL }) {
128135 pageSize
129136 } ,
130137 'log/get'
131- ) . then ( ( res ) => {
138+ ) . then ( res => {
132139 if ( res ?. success ) {
133140 setPageCount ( Math . ceil ( res . data . count / pageSize ) )
134141 setCountEntries ( res . data . count )
@@ -189,8 +196,47 @@ function Log({ allIntegURL }) {
189196 </ div >
190197 ) }
191198 </ div >
199+
200+ { response && (
201+ < Modal
202+ sm
203+ closeIcon
204+ show = { response }
205+ setModal = { setResponse }
206+ style = { { maxWidth : '900px' } }
207+ title = { __ ( 'Response' , 'bit-integrations' ) } >
208+ < div className = "flx flx-around mr-1 mt-1" >
209+ < div
210+ className = "txt-dp"
211+ style = { {
212+ background : '#1e293b' ,
213+ borderRadius : '8px' ,
214+ padding : '16px' ,
215+ color : '#f8fafc' ,
216+ fontFamily : "'Fira Code', monospace" ,
217+ fontSize : '14px' ,
218+ overflow : 'auto' ,
219+ maxWidth : '800px' ,
220+ maxHeight : '500px' ,
221+ boxShadow : '0 2px 8px rgba(0,0,0,0.15)'
222+ } } >
223+ < pre style = { { margin : 0 } } >
224+ < code className = "" > { jsonPrint ( response ) } </ code >
225+ </ pre >
226+ </ div >
227+ </ div >
228+ </ Modal >
229+ ) }
192230 </ >
193231 )
194232}
195233
196234export default memo ( Log )
235+
236+ const jsonPrint = data => {
237+ try {
238+ return JSON . stringify ( JSON . parse ( data ) , null , 2 )
239+ } catch ( e ) {
240+ return data
241+ }
242+ }
0 commit comments