-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgetbooks.js
77 lines (68 loc) · 2.23 KB
/
getbooks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import Layout from '@theme/Layout';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Link from '@docusaurus/Link';
import useBaseUrl from '@docusaurus/useBaseUrl';
import {Helmet} from "react-helmet";
import CodeBlock from '@theme/CodeBlock';
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
class GetBooksInfo extends React.Component {
constructor(props) {
super(props);
this.state = {
error: null,
isLoaded: false,
result: []
};
}
componentDidMount() {
window.toast = toast;
fetch("https://api.xn--c1asakg.xn--p1ai/html.php?url="+encodeURIComponent(window.location.href))
.then(res => res.text())
.then(
(result) => {
this.setState({
isLoaded: true,
result: result
});
},
(error) => {
this.setState({
isLoaded: true,
error
});
}
);
}
render() {
const { error, isLoaded, result } = this.state;
if (error) {
return <div>Ошибка: {error.message}. Попробуйте перезагрузить страницу. Если это не помогло, пожалуйста, напишите на [email protected].</div>;
} else if (!isLoaded) {
return <div>Загрузка...</div>;
} else {
var uri = encodeURIComponent(window.location.href);
return (<div><Helmet><script src={"https://api.xn--c1asakg.xn--p1ai/js.php?url=" + uri} async></script></Helmet>
<div dangerouslySetInnerHTML={{__html: result}} ></div></div>
);
}
}
}
function GetBooks() {
//const context = useDocusaurusContext();
return (
<Layout
title="Получить экземпляр"
permalink="/"
description="Получить бесплатный трёхтомник «Гарри Поттера и методов рационального мышления»."><ToastContainer />
<main className="container margin-vert--lg">
<GetBooksInfo />
<div className="col col--3"></div>
</main>
</Layout>
);
}
export default GetBooks;