Skip to content

Commit

Permalink
feat(frontend)!: Remove themes folder
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Jun 17, 2024
1 parent 4ad73b5 commit ea1f0f2
Show file tree
Hide file tree
Showing 55 changed files with 53 additions and 198 deletions.
15 changes: 2 additions & 13 deletions frontend/app/[locale]/(main)/(container)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import * as React from "react";

import { getSessionData } from "@/graphql/get-session-data";
import { SignInView } from "@/plugins/core/views/views/auth/sign/in/sign-in-view";

export default async function Page() {
const { theme_id } = await getSessionData();
const PageFromTheme: React.LazyExoticComponent<() => JSX.Element> =
React.lazy(async () =>
import(
`../../../../../themes/${theme_id}/core/views/auth/sign/in/sign-in-view`
).catch(
async () =>
import("../../../../../themes/1/core/views/auth/sign/in/sign-in-view")
)
);

return <PageFromTheme />;
return <SignInView />;
}
15 changes: 2 additions & 13 deletions frontend/app/[locale]/(main)/(container)/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import * as React from "react";

import { getSessionData } from "@/graphql/get-session-data";
import { SignUpView } from "@/plugins/core/views/views/auth/sign/up/sign-up-view";

export default async function Page() {
const { theme_id } = await getSessionData();
const PageFromTheme: React.LazyExoticComponent<() => JSX.Element> =
React.lazy(async () =>
import(
`../../../../../themes/${theme_id}/core/views/auth/sign/up/sign-up-view`
).catch(
async () =>
import("../../../../../themes/1/core/views/auth/sign/up/sign-up-view")
)
);

return <PageFromTheme />;
return <SignUpView />;
}
20 changes: 3 additions & 17 deletions frontend/app/[locale]/(main)/(container)/settings/devices/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
Core_Sessions__Devices__ShowQuery,
Core_Sessions__Devices__ShowQueryVariables
} from "@/graphql/hooks";
import { DevicesSettingsViewProps } from "@/themes/1/core/views/settings/views/devices/devices-settings-view";
import { DevicesSettingsView } from "@/plugins/core/views/views/settings/views/devices/devices-settings-view";
import { fetcher } from "@/graphql/fetcher";
import { getSessionData } from "@/graphql/get-session-data";

const getData = async () => {
const { data } = await fetcher<
Expand All @@ -22,26 +21,13 @@ const getData = async () => {
};

export default async function Page() {
const [{ theme_id }, data] = await Promise.all([getSessionData(), getData()]);
const data = await getData();
const cookieStore = cookies();
const loginToken = cookieStore.get("vitnode-login-token")?.value;

if (!loginToken) {
return null;
}

const PageFromTheme: React.LazyExoticComponent<
(props: DevicesSettingsViewProps) => JSX.Element
> = React.lazy(async () =>
import(
`../../../../../../themes/${theme_id}/core/views/settings/views/devices/devices-settings-view`
).catch(
async () =>
import(
"../../../../../../themes/1/core/views/settings/views/devices/devices-settings-view"
)
)
);

return <PageFromTheme {...data} loginToken={loginToken} />;
return <DevicesSettingsView {...data} loginToken={loginToken} />;
}
22 changes: 3 additions & 19 deletions frontend/app/[locale]/(main)/(container)/settings/files/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SearchParamsPagination
} from "@/plugins/core/hooks/utils/use-pagination-api-ssr";
import { fetcher } from "@/graphql/fetcher";
import { getSessionData } from "@/graphql/get-session-data";
import { FilesSettingsView } from "@/plugins/core/views/views/settings/views/files/files-settings-view";

const getData = async (variables: Core_Members__Files__ShowQueryVariables) => {
const { data } = await fetcher<
Expand All @@ -37,23 +37,7 @@ export default async function Page({ searchParams }: Props) {
search: true,
sortByEnum: ShowCoreFilesSortingColumnEnum
});
const [{ theme_id }, data] = await Promise.all([
getSessionData(),
getData(variables)
]);
const data = await getData(variables);

const PageFromTheme: React.LazyExoticComponent<
(props: Core_Members__Files__ShowQuery) => JSX.Element
> = React.lazy(async () =>
import(
`../../../../../../themes/${theme_id}/core/views/settings/views/files/files-settings-view`
).catch(
async () =>
import(
"../../../../../../themes/1/core/views/settings/views/files/files-settings-view"
)
)
);

return <PageFromTheme {...data} />;
return <FilesSettingsView {...data} />;
}
18 changes: 2 additions & 16 deletions frontend/app/[locale]/(main)/(container)/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Metadata } from "next";
import { getTranslations } from "next-intl/server";

import { getConfigFile } from "@/config/helpers";
import { getSessionData } from "@/graphql/get-session-data";
import { LayoutSettingsView } from "@/plugins/core/views/views/settings/layout-settings-view";

interface Props {
children: React.ReactNode;
Expand All @@ -23,19 +23,5 @@ export async function generateMetadata(): Promise<Metadata> {
}

export default async function Layout({ children }: Props) {
const { theme_id } = await getSessionData();
const LayoutFromLazy: React.LazyExoticComponent<
({ children }: { children: React.ReactNode }) => JSX.Element
> = React.lazy(async () =>
import(
`../../../../../themes/${theme_id}/core/views/settings/layout-settings-view`
).catch(
async () =>
import(
"../../../../../themes/1/core/views/settings/layout-settings-view"
)
)
);

return <LayoutFromLazy>{children}</LayoutFromLazy>;
return <LayoutSettingsView>{children}</LayoutSettingsView>;
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import * as React from "react";

import { getSessionData } from "@/graphql/get-session-data";
import { NotificationsSettingsView } from "@/plugins/core/views/views/settings/views/notifications/notifications-settings-view";

export default async function Page() {
const { theme_id } = await getSessionData();
const PageFromTheme: React.LazyExoticComponent<() => JSX.Element> =
React.lazy(async () =>
import(
`../../../../../../themes/${theme_id}/core/views/settings/views/notifications/notifications-settings-view`
).catch(
async () =>
import(
"../../../../../../themes/1/core/views/settings/views/notifications/notifications-settings-view"
)
)
);

return <PageFromTheme />;
return <NotificationsSettingsView />;
}
17 changes: 2 additions & 15 deletions frontend/app/[locale]/(main)/(container)/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import * as React from "react";

import { getSessionData } from "@/graphql/get-session-data";
import { OverviewSettingsView } from "@/plugins/core/views/views/settings/views/overview/overview-settings-view";

export default async function Page() {
const { theme_id } = await getSessionData();
const PageFromTheme: React.LazyExoticComponent<() => JSX.Element> =
React.lazy(async () =>
import(
`../../../../../themes/${theme_id}/core/views/settings/views/overview/overview-settings-view`
).catch(
async () =>
import(
"../../../../../themes/1/core/views/settings/views/overview/overview-settings-view"
)
)
);

return <PageFromTheme />;
return <OverviewSettingsView />;
}
21 changes: 4 additions & 17 deletions frontend/app/[locale]/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { isRedirectError } from "next/dist/client/components/redirect";
import { redirect } from "@vitnode/frontend/navigation";

import { SessionProvider } from "./session-provider";
import { TextLanguage } from "@/graphql/hooks";
import { InternalErrorView } from "@/plugins/admin/global/internal-error/internal-error-view";
import { getSessionData } from "@/graphql/get-session-data";
import { Layout as LayoutCore } from "@/plugins/core/views/layout/layout";

interface Props {
children: React.ReactNode;
Expand All @@ -14,29 +14,16 @@ interface Props {

export default async function Layout({ children }: Props) {
try {
const { data, theme_id } = await getSessionData();
const { data } = await getSessionData();
if (data.core_languages__show.edges.length === 0) {
redirect("/admin/install");
}

const Layout: React.LazyExoticComponent<
({
children
}: {
children: React.ReactNode;
copyright?: TextLanguage[];
}) => JSX.Element
> = React.lazy(async () =>
import(`../../../themes/${theme_id}/core/layout/layout`).catch(
async () => import("../../../themes/1/core/layout/layout")
)
);

return (
<SessionProvider data={data}>
<Layout copyright={data.core_settings__show.site_copyright}>
<LayoutCore copyright={data.core_settings__show.site_copyright}>
{children}
</Layout>
</LayoutCore>
</SessionProvider>
);
} catch (error) {
Expand Down
7 changes: 2 additions & 5 deletions frontend/app/[locale]/(main)/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { ErrorViewSSR } from "@/components/views/error-view-ssr";
import { getSessionData } from "@/graphql/get-session-data";

export default async function NotFoundPage() {
const { theme_id } = await getSessionData();

export default function NotFoundPage() {
return (
<div className="container">
<ErrorViewSSR theme_id={theme_id} code="404" />
<ErrorViewSSR code="404" />
</div>
);
}
11 changes: 4 additions & 7 deletions frontend/app/[locale]/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ export async function generateMetadata({
}

export default async function Page() {
const { default_plugin, theme_id } = await getSessionData();
const { default_plugin } = await getSessionData();
const PageFromTheme: React.LazyExoticComponent<() => JSX.Element> =
React.lazy(async () =>
import(
`../../../themes/${theme_id}/${default_plugin}/default-page`
).catch(
async () => import(`../../../themes/1/${default_plugin}/default-page`)
)
React.lazy(
async () =>
import(`../../../plugins/${default_plugin}/views/default-page`)
);

return <PageFromTheme />;
Expand Down
17 changes: 2 additions & 15 deletions frontend/app/[locale]/(main)/profile/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { Metadata } from "next";
import { notFound } from "next/navigation";
import * as React from "react";

import { ProfileViewProps } from "@/themes/1/core/views/profile/profile-view";
import { ProfileView } from "@/plugins/core/views/views/profile/profile-view";
import {
Core_Members__Profiles,
Core_Members__ProfilesQuery,
Core_Members__ProfilesQueryVariables
} from "@/graphql/hooks";
import { fetcher } from "@/graphql/fetcher";
import { getSessionData } from "@/graphql/get-session-data";

const getData = async ({ id }: { id: string }) => {
const { data } = await fetcher<
Expand Down Expand Up @@ -50,17 +49,5 @@ export default async function Page({ params: { id } }: Props) {
notFound();
}

const { theme_id } = await getSessionData();
const PageFromTheme: React.LazyExoticComponent<
(props: ProfileViewProps) => JSX.Element
> = React.lazy(async () =>
import(
`../../../../../themes/${theme_id}/core/views/profile/profile-view`
).catch(
async () =>
import("../../../../../themes/1/core/views/profile/profile-view")
)
);

return <PageFromTheme data={data} />;
return <ProfileView data={data} />;
}
16 changes: 3 additions & 13 deletions frontend/components/views/error-view-ssr.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import * as React from "react";

import { ErrorView } from "@/plugins/core/views/views/global/error/error-view";

export interface ErrorViewProps {
code: string | "403" | "404" | "500";
className?: string;
}

interface Props extends ErrorViewProps {
theme_id: number;
}

export const ErrorViewSSR = ({ theme_id, ...props }: Props) => {
const ErrorView: React.LazyExoticComponent<
(props: ErrorViewProps) => JSX.Element
> = React.lazy(async () =>
import(`../../themes/${theme_id}/core/views/global/error/error-view`).catch(
async () => import("../../themes/1/core/views/global/error/error-view")
)
);

export const ErrorViewSSR = (props: ErrorViewProps) => {
return <ErrorView {...props} />;
};
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Props {
copyright?: TextLanguage[];
}

export default function Layout({ children, copyright }: Props) {
export const Layout = ({ children, copyright }: Props) => {
const { convertText } = useTextLang();

/**
Expand All @@ -38,4 +38,4 @@ export default function Layout({ children, copyright }: Props) {
<QuickMenu />
</>
);
}
};
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@/components/ui/card";
import { FormSignIn } from "./form/form-sign-in";

export default function SignInView() {
export const SignInView = () => {
const t = useTranslations("core.sign_in");

return (
Expand All @@ -27,4 +27,4 @@ export default function SignInView() {
</Card>
</div>
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@/components/ui/card";
import { FormSignUp } from "./form/form-sign-up";

export default function SignUpView() {
export const SignUpView = () => {
const t = useTranslations("core.sign_up");

return (
Expand All @@ -28,4 +28,4 @@ export default function SignUpView() {
</Card>
</div>
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { buttonVariants } from "@/components/ui/button";
import { ErrorViewProps } from "@/components/views/error-view-ssr";

export default function ErrorView({ className, code }: ErrorViewProps) {
export const ErrorView = ({ className, code }: ErrorViewProps) => {
const t = useTranslations("core");

return (
Expand Down Expand Up @@ -47,4 +47,4 @@ export default function ErrorView({ className, code }: ErrorViewProps) {
</div>
</div>
);
}
};
Loading

0 comments on commit ea1f0f2

Please sign in to comment.