]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/pages/Event.js
offload some page chunks
[alttp.git] / resources / js / pages / Event.js
index 70b3beffa021d489bc463697ed2a6aea8612221b..fa5dc2163c30c3432356857dbfa330fa153c28ff 100644 (file)
@@ -3,7 +3,7 @@ import moment from 'moment';
 import React from 'react';
 import { Container } from 'react-bootstrap';
 import { Helmet } from 'react-helmet';
-import { withTranslation } from 'react-i18next';
+import { useTranslation } from 'react-i18next';
 import { useParams } from 'react-router-dom';
 import toastr from 'toastr';
 
@@ -23,10 +23,11 @@ import { getTranslation } from '../helpers/Technique';
 import { useUser } from '../hooks/user';
 import i18n from '../i18n';
 
-const Event = () => {
+export const Component = () => {
        const params = useParams();
        const { name } = params;
        const { user } = useUser();
+       const { t } = useTranslation();
 
        const [error, setError] = React.useState(null);
        const [loading, setLoading] = React.useState(true);
@@ -76,14 +77,14 @@ const Event = () => {
                                parent_id: event.description_id,
                                ...values,
                        });
-                       toastr.success(i18n.t('content.saveSuccess'));
+                       toastr.success(t('content.saveSuccess'));
                        setEvent(event => ({
                                ...event,
                                description: response.data,
                        }));
                        setShowContentDialog(false);
                } catch (e) {
-                       toastr.error(i18n.t('content.saveError'));
+                       toastr.error(t('content.saveError'));
                }
        }, [event && event.description_id]);
 
@@ -149,7 +150,7 @@ const Event = () => {
                        <Detail actions={actions} event={event} />
                        {episodes.length ? <>
                                <h2 className="mt-4">
-                                       {i18n.t(hasConcluded(event)
+                                       {t(hasConcluded(event)
                                                ? 'events.pastEpisodes'
                                                : 'events.upcomingEpisodes'
                                        )}
@@ -166,5 +167,3 @@ const Event = () => {
                />
        </ErrorBoundary>;
 };
-
-export default withTranslation()(Event);