Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/api/endpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ export const patchTerm = async (group, termID, term) => {
});
}

export const getRawData = async (group, termID, format) => {
const {getEndpointsIlx} = useApi();

/** Call Endpoint */
return getEndpointsIlx(group, termID, format).then((data) => {
return data;
})
.catch((error) => {
return error;
});
}

export const addTerm = async (group, term) => {
const { postPrivEntityNew } = useApi();

Expand Down
13 changes: 6 additions & 7 deletions src/components/SingleTermView/OverView/RawDataViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import PropTypes from 'prop-types';
import { useState, useEffect } from 'react';
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter';
import { a11yLight } from 'react-syntax-highlighter/dist/esm/styles/hljs';
import * as mockApi from './../../../api/endpoints/interLexURIStructureAPI';
import { getRawData } from "../../../api/endpoints";
import { GlobalDataContext } from "../../../contexts/DataContext";
import { useContext } from "react";

import { vars } from '../../../theme/variables';
const { gray25, gray200, gray500 } = vars;

const useMockApi = () => mockApi;

const customStyle = {
fontSize: '1rem',
backgroundColor: '#fff',
Expand All @@ -18,7 +18,6 @@ const customStyle = {
padding: 0
};

// eslint-disable-next-line no-unused-vars
const formatExtensions = {
'JSON-LD': 'jsonld',
'Turtle': 'ttl',
Expand All @@ -31,10 +30,10 @@ const RawDataViewer = ({ dataId, dataFormat }) => {
const [formattedData, setFormattedData] = useState(null);
// eslint-disable-next-line no-unused-vars
const [loading, setLoading] = useState(true);
const { getEndpointsIlxGet } = useMockApi();
const { user } = useContext(GlobalDataContext);

useEffect(() => {
getEndpointsIlxGet("base",dataId, dataFormat).then( rawResponse => {
getRawData(user?.name || "base",dataId, formatExtensions[dataFormat]).then( rawResponse => {
setFormattedData(JSON.stringify(rawResponse, null, 2));
setLoading(false)
})
Expand Down