]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/pages/User.js
improved directory structure
[alttp.git] / resources / js / components / pages / User.js
diff --git a/resources/js/components/pages/User.js b/resources/js/components/pages/User.js
deleted file mode 100644 (file)
index 144e4c0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-import axios from 'axios';
-import React, { useEffect, useState } from 'react';
-import { Helmet } from 'react-helmet';
-import { useParams } from 'react-router-dom';
-
-import CanonicalLinks from '../common/CanonicalLinks';
-import ErrorBoundary from '../common/ErrorBoundary';
-import ErrorMessage from '../common/ErrorMessage';
-import Loading from '../common/Loading';
-import NotFound from '../pages/NotFound';
-import Profile from '../users/Profile';
-
-const User = () => {
-       const params = useParams();
-       const { id } = params;
-
-       const [error, setError] = useState(null);
-       const [loading, setLoading] = useState(true);
-       const [user, setUser] = useState(null);
-
-       useEffect(() => {
-               setLoading(true);
-               const ctrl = new AbortController();
-               axios
-                       .get(`/api/users/${id}`, { signal: ctrl.signal })
-                       .then(response => {
-                               setError(null);
-                               setLoading(false);
-                               setUser(response.data);
-                       })
-                       .catch(error => {
-                               setError(error);
-                               setLoading(false);
-                               setUser(null);
-                       });
-               return () => {
-                       ctrl.abort();
-               };
-       }, [id]);
-
-       useEffect(() => {
-               const cb = (e) => {
-                       if (e.user) {
-                               setUser(user => e.user.id === user.id ? { ...user, ...e.user } : user);
-                       }
-               };
-               window.Echo.channel('App.Control')
-                       .listen('UserChanged', cb);
-               return () => {
-                       window.Echo.channel('App.Control')
-                               .stopListening('UserChanged', cb);
-               };
-       }, []);
-
-       if (loading) {
-               return <Loading />;
-       }
-
-       if (error) {
-               return <ErrorMessage error={error} />;
-       }
-
-       if (!user) {
-               return <NotFound />;
-       }
-
-       return <ErrorBoundary>
-               <Helmet>
-                       <title>{user.nickname || user.username}</title>
-               </Helmet>
-               <CanonicalLinks base={`/users/${user.id}`} />
-               <Profile user={user} />
-       </ErrorBoundary>;
-};
-
-export default User;