X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fcomponents%2Fpages%2FTechniques.js;fp=resources%2Fjs%2Fcomponents%2Fpages%2FTechniques.js;h=9334155a92ae284310726e8baa650d7f6e4592e7;hb=6c51a1601e74bc822ccafe984d525d0e9a35ca28;hp=0000000000000000000000000000000000000000;hpb=0407853837c323428d122a027fbdb574025824db;p=alttp.git
diff --git a/resources/js/components/pages/Techniques.js b/resources/js/components/pages/Techniques.js
new file mode 100644
index 0000000..9334155
--- /dev/null
+++ b/resources/js/components/pages/Techniques.js
@@ -0,0 +1,61 @@
+import axios from 'axios';
+import React from 'react';
+import { withTranslation } from 'react-i18next';
+
+import NotFound from './NotFound';
+import ErrorBoundary from '../common/ErrorBoundary';
+import ErrorMessage from '../common/ErrorMessage';
+import Loading from '../common/Loading';
+import Overview from '../techniques/Overview';
+import { compareTranslation } from '../../helpers/Technique';
+import i18n from '../../i18n';
+
+const Techniques = () => {
+ const [error, setError] = React.useState(null);
+ const [loading, setLoading] = React.useState(true);
+ const [techniques, setTechniques] = React.useState([]);
+
+ React.useEffect(() => {
+ const ctrl = new AbortController();
+ setLoading(true);
+ window.document.title = i18n.t('techniques.heading');
+ axios
+ .get(`/api/tech`, { signal: ctrl.signal })
+ .then(response => {
+ setError(null);
+ setLoading(false);
+ setTechniques(response.data.sort(compareTranslation('title', i18n.language)));
+ })
+ .catch(error => {
+ setError(error);
+ setLoading(false);
+ setTechniques([]);
+ });
+ return () => {
+ ctrl.abort();
+ };
+ }, []);
+
+ React.useEffect(() => {
+ window.document.title = i18n.t('techniques.heading');
+ setTechniques(t => [...t].sort(compareTranslation('title', i18n.language)));
+ }, [i18n.language]);
+
+ if (loading) {
+ return ;
+ }
+
+ if (error) {
+ return ;
+ }
+
+ if (!techniques || !techniques.length) {
+ return ;
+ }
+
+ return
+
+ ;
+};
+
+export default withTranslation()(Techniques);