diff --git a/src/components/modules/calendar/CalendarModule.tsx b/src/components/modules/calendar/CalendarModule.tsx
index 8dcbdae9e..5872539cd 100644
--- a/src/components/modules/calendar/CalendarModule.tsx
+++ b/src/components/modules/calendar/CalendarModule.tsx
@@ -32,8 +32,9 @@ export default function CalendarComponent(props: any) {
const radarrService = filtered.filter((service) => service.type === 'Radarr').at(0);
const nextMonth = new Date(new Date().setMonth(new Date().getMonth() + 2)).toISOString();
if (sonarrService && sonarrService.apiKey) {
+ const baseUrl = new URL(sonarrService.url).origin;
fetch(
- `${sonarrService?.url}api/calendar?apikey=${sonarrService?.apiKey}&end=${nextMonth}`
+ `${baseUrl}api/calendar?apikey=${sonarrService?.apiKey}&end=${nextMonth}`
).then((response) => {
response.ok &&
response.json().then((data) => {
@@ -50,22 +51,23 @@ export default function CalendarComponent(props: any) {
});
}
if (radarrService && radarrService.apiKey) {
- fetch(
- `${radarrService?.url}api/v3/calendar?apikey=${radarrService?.apiKey}&end=${nextMonth}`
- ).then((response) => {
- response.ok &&
- response.json().then((data) => {
- setRadarrMedias(data);
- showNotification({
- title: 'Radarr',
- icon: ,
- color: 'green',
- autoClose: 1500,
- radius: 'md',
- message: `Loaded ${data.length} releases`,
+ const baseUrl = new URL(radarrService.url).origin;
+ fetch(`${baseUrl}api/v3/calendar?apikey=${radarrService?.apiKey}&end=${nextMonth}`).then(
+ (response) => {
+ response.ok &&
+ response.json().then((data) => {
+ setRadarrMedias(data);
+ showNotification({
+ title: 'Radarr',
+ icon: ,
+ color: 'green',
+ autoClose: 1500,
+ radius: 'md',
+ message: `Loaded ${data.length} releases`,
+ });
});
- });
- });
+ }
+ );
}
}, [config.services]);
diff --git a/src/pages/[slug].tsx b/src/pages/[slug].tsx
index 06fe31f8a..3ea48f139 100644
--- a/src/pages/[slug].tsx
+++ b/src/pages/[slug].tsx
@@ -1,8 +1,54 @@
-import { Title } from '@mantine/core';
-import { useRouter } from 'next/router';
+import { GetServerSidePropsContext } from 'next';
+import path from 'path';
+import fs from 'fs';
+import { useEffect } from 'react';
+import AppShelf from '../components/AppShelf/AppShelf';
+import LoadConfigComponent from '../components/Config/LoadConfig';
+import { Config } from '../tools/types';
+import { useConfig } from '../tools/state';
-export default function SlugPage(props: any) {
- const router = useRouter();
- const { slug } = router.query;
- return
ok;
+export async function getServerSideProps(
+ context: GetServerSidePropsContext
+): Promise<{ props: { config: Config } }> {
+ const configByUrl = context.query.slug;
+ const configPath = path.join(process.cwd(), 'data/configs', `${configByUrl}.json`);
+ const configExists = fs.existsSync(configPath);
+ if (!configExists) {
+ // Redirect to 404
+ context.res.writeHead(301, { Location: '/404' });
+ context.res.end();
+ return {
+ props: {
+ config: {
+ name: '',
+ services: [],
+ settings: {
+ enabledModules: [],
+ searchUrl: 'https://www.google.com/search?q=',
+ },
+ },
+ },
+ };
+ }
+ const config = fs.readFileSync(configPath, 'utf8');
+ // Print loaded config
+ return {
+ props: {
+ config: JSON.parse(config),
+ },
+ };
+}
+
+export default function HomePage(props: any) {
+ const { config: initialConfig }: { config: Config } = props;
+ const { setConfig } = useConfig();
+ useEffect(() => {
+ setConfig(initialConfig);
+ }, [initialConfig]);
+ return (
+ <>
+
+
+ >
+ );
}