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=0000000000000000000000000000000000000000;hb=16662be0b3432d67307ae8c2bb798362d77bab99;hp=c2d7aec80627aaec51f6344d113ecbfccb55530d;hpb=d8ca13d8ccb5efe181198d0e5243a26c9f807aa1;p=alttp.git
diff --git a/resources/js/components/pages/Techniques.js b/resources/js/components/pages/Techniques.js
deleted file mode 100644
index c2d7aec..0000000
--- a/resources/js/components/pages/Techniques.js
+++ /dev/null
@@ -1,100 +0,0 @@
-import axios from 'axios';
-import PropTypes from 'prop-types';
-import React from 'react';
-import { Helmet } from 'react-helmet';
-import { withTranslation } from 'react-i18next';
-
-import NotFound from './NotFound';
-import CanonicalLinks from '../common/CanonicalLinks';
-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 = ({ namespace, type }) => {
- const [error, setError] = React.useState(null);
- const [filter, setFilter] = React.useState({});
- const [loading, setLoading] = React.useState(true);
- const [techniques, setTechniques] = React.useState([]);
-
- React.useEffect(() => {
- const savedFilter = localStorage.getItem(`content.filter.${type}`);
- if (savedFilter) {
- setFilter(JSON.parse(savedFilter));
- } else {
- setFilter(filter => filter ? {} : filter);
- }
- }, [type]);
-
- const updateFilter = React.useCallback(newFilter => {
- localStorage.setItem(`content.filter.${type}`, JSON.stringify(newFilter));
- setFilter(newFilter);
- }, [type]);
-
- React.useEffect(() => {
- const ctrl = new AbortController();
- if (!techniques.length) {
- setLoading(true);
- }
- axios
- .get(`/api/pages/${type}`, {
- params: filter,
- signal: ctrl.signal
- })
- .then(response => {
- setError(null);
- setLoading(false);
- setTechniques(response.data.sort(compareTranslation('title', i18n.language)));
- })
- .catch(error => {
- if (!axios.isCancel(error)) {
- setError(error);
- setLoading(false);
- setTechniques([]);
- }
- });
- return () => {
- ctrl.abort();
- };
- }, [filter, namespace, type]);
-
- React.useEffect(() => {
- setTechniques(t => [...t].sort(compareTranslation('title', i18n.language)));
- }, [namespace, i18n.language]);
-
- if (loading) {
- return ;
- }
-
- if (error) {
- return ;
- }
-
- if (!techniques || !techniques.length) {
- return ;
- }
-
- return
-
- {i18n.t(`${namespace}.heading`)}
-
-
-
-
- ;
-};
-
-Techniques.propTypes = {
- namespace: PropTypes.string,
- type: PropTypes.string,
-};
-
-export default withTranslation()(Techniques);