--- /dev/null
+import axios from 'axios';
+import React, { useCallback, useEffect, useState } from 'react';
+
+import Generate from '../aos-generate/Generate';
+import ErrorBoundary from '../common/ErrorBoundary';
+import ErrorMessage from '../common/ErrorMessage';
+import Loading from '../common/Loading';
+import i18n from '../../i18n';
+
+const AosGenerate = () => {
+ const [error, setError] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [presets, setPresets] = useState([]);
+
+ const loadPresets = useCallback(ctrl => {
+ axios
+ .get('/api/aos-presets', { signal: ctrl.signal })
+ .then(response => {
+ setError(null);
+ setLoading(false);
+ setPresets(response.data);
+ })
+ .catch(error => {
+ setError(error);
+ setLoading(false);
+ setPresets([]);
+ });
+ }, []);
+
+ useEffect(() => {
+ setLoading(true);
+ const ctrl = new AbortController();
+ loadPresets(ctrl);
+ return () => {
+ ctrl.abort();
+ };
+ }, []);
+
+ useEffect(() => {
+ window.document.title = i18n.t('aosGenerate.heading');
+ }, [i18n.language]);
+
+ if (loading) {
+ return <Loading />;
+ }
+
+ if (error) {
+ return <ErrorMessage error={error} />;
+ }
+
+ return <ErrorBoundary>
+ <Generate presets={presets} />
+ </ErrorBoundary>;
+};
+
+export default AosGenerate;