diff --git a/src/features/app_bar/index.tsx b/src/features/app_bar/index.tsx
index b06ac9d..f290489 100644
--- a/src/features/app_bar/index.tsx
+++ b/src/features/app_bar/index.tsx
@@ -2,6 +2,7 @@ import Link from "next/link";
import styles from "./app_bar.module.scss";
import { MenuRounded } from "@mui/icons-material";
import { useState } from "react";
+import { IndexPageTemplate } from "@/lib/types/website_page_templates/index_page_template";
export function AppBar({
home,
diff --git a/src/features/landing_page_view/index.tsx b/src/features/landing_page_view/index.tsx
index 564a038..5114383 100644
--- a/src/features/landing_page_view/index.tsx
+++ b/src/features/landing_page_view/index.tsx
@@ -4,6 +4,7 @@ import { WelcomeSection } from "./welcome_section/welcome_section";
import { Footer } from "../footer";
import { ReactNode } from "react";
import { ThemeMetaDTO } from "@/lib/theme/theme_meta_dto";
+import { IndexPageTemplate } from "@/lib/types/website_page_templates/index_page_template";
export function LandingPageView({
themePreviews,
diff --git a/src/features/landing_page_view/welcome_section/welcome_section.tsx b/src/features/landing_page_view/welcome_section/welcome_section.tsx
index a9cfc61..d486cd5 100644
--- a/src/features/landing_page_view/welcome_section/welcome_section.tsx
+++ b/src/features/landing_page_view/welcome_section/welcome_section.tsx
@@ -1,3 +1,4 @@
+import { IndexPageTemplate } from "@/lib/types/website_page_templates/index_page_template";
import styles from "./welcome_section.module.scss";
export function WelcomeSection({
diff --git a/src/features/theme_page/index.tsx b/src/features/theme_page/index.tsx
index 56b7620..1746723 100644
--- a/src/features/theme_page/index.tsx
+++ b/src/features/theme_page/index.tsx
@@ -2,19 +2,22 @@ import ITheme from "@/lib/theme/theme";
import { View } from "./view";
import { ViewModel } from "./view_model";
import { ReactNode } from "react";
+import { IndexPageTemplate } from "@/lib/types/website_page_templates/index_page_template";
export default function ThemePage({
theme,
home,
adminTools,
+ pageTemplate,
}: {
theme: ITheme;
home: "/admin" | "/";
adminTools?: ReactNode;
+ pageTemplate: IndexPageTemplate;
}) {
return (
-
+
);
}
diff --git a/src/features/theme_page/view/index.tsx b/src/features/theme_page/view/index.tsx
index 50a526c..d5c257d 100644
--- a/src/features/theme_page/view/index.tsx
+++ b/src/features/theme_page/view/index.tsx
@@ -9,6 +9,7 @@ import { Footer } from "@/features/footer";
import { TabBar } from "./tab_bar";
import { ReactNode } from "react";
import dynamic from "next/dynamic";
+import { IndexPageTemplate } from "@/lib/types/website_page_templates/index_page_template";
const ActivityDialog = dynamic(() => import("./activity_dialog"), {
ssr: false,
@@ -17,9 +18,11 @@ const ActivityDialog = dynamic(() => import("./activity_dialog"), {
export function View({
home,
adminTools,
+ pageTemplate,
}: {
home: "/admin" | "/";
adminTools?: ReactNode;
+ pageTemplate: IndexPageTemplate;
}) {
const {
isActivityDialogOpen,
@@ -42,7 +45,7 @@ export function View({
key="image"
/>
-
+
diff --git a/src/pages/admin/index.tsx b/src/pages/admin/index.tsx
index 8559252..8b7c89a 100644
--- a/src/pages/admin/index.tsx
+++ b/src/pages/admin/index.tsx
@@ -1,14 +1,17 @@
import { LandingPageView } from "@/features/landing_page_view";
+import { DynamoDBWebsitePageTemplateRepository } from "@/lib/repositories/website_page_template/dynamodb_website_page_template_repository";
import ThemeAdminService from "@/lib/services/theme/theme_admin_service";
import ThemeApiService from "@/lib/services/theme/theme_api_service";
import { defaultTheme } from "@/lib/theme/default_theme";
import { ThemeMetaDTO } from "@/lib/theme/theme_meta_dto";
+import { IndexPageTemplate } from "@/lib/types/website_page_templates/index_page_template";
import Head from "next/head";
import { useEffect, useRef, useState } from "react";
export default function AdminPage() {
const adminService = useRef(new ThemeAdminService());
const [themeMetas, setThemeMetas] = useState
();
+ const [pageTemplate, setPageTemplate] = useState();
const [stalling, setStalling] = useState(false);
const fetchThemeMetas = async () => {
@@ -21,8 +24,18 @@ export default function AdminPage() {
}
};
+ const fetchPageTemplate = async () => {
+ const dynamodbWebsiteTemplateRepo =
+ new DynamoDBWebsitePageTemplateRepository();
+ const res = await dynamodbWebsiteTemplateRepo.getIndexPageTemplate();
+ if (res.status === "success" && res.data) {
+ setPageTemplate(res.data);
+ }
+ };
+
useEffect(() => {
fetchThemeMetas();
+ fetchPageTemplate();
}, []);
const createTheme = async () => {
@@ -32,7 +45,7 @@ export default function AdminPage() {
setStalling(false);
};
- if (!themeMetas) {
+ if (!themeMetas || !pageTemplate) {
return (
Merhaba Admin!
@@ -48,6 +61,7 @@ export default function AdminPage() {
import("@/features/admin_tools"), {
ssr: false,
@@ -13,20 +15,38 @@ export default function ThemePage() {
const pathname = usePathname();
const adminService = useRef(new ThemeAdminService());
const [themeData, setThemeData] = useState();
+ const [pageTemplate, setPageTemplate] = useState();
const fetchTheme = async (pathName: string) => {
setThemeData(await adminService.current.fetchTheme(pathName));
};
+ const fetchPageTemplate = async () => {
+ const dynamodbWebsiteTemplateRepo =
+ new DynamoDBWebsitePageTemplateRepository();
+ const res = await dynamodbWebsiteTemplateRepo.getIndexPageTemplate();
+ if (res.status === "success" && res.data) {
+ setPageTemplate(res.data);
+ }
+ };
+
useEffect(() => {
if (!pathname) return;
const splitPathname = pathname.split("/");
const themePathName = splitPathname[splitPathname.length - 1];
fetchTheme(themePathName);
+ fetchPageTemplate();
}, [pathname]);
- if (themeData) {
- return } />;
+ if (themeData && pageTemplate) {
+ return (
+ }
+ pageTemplate={pageTemplate}
+ />
+ );
}
return (
diff --git a/src/pages/temalar/[theme].tsx b/src/pages/temalar/[theme].tsx
index a813837..346dbe2 100644
--- a/src/pages/temalar/[theme].tsx
+++ b/src/pages/temalar/[theme].tsx
@@ -3,9 +3,17 @@ import TP from "@/features/theme_page";
import { DynamoDBThemeRepository } from "@/lib/repositories/theme/dynamodb_theme_repository";
import ITheme from "@/lib/theme/theme";
import ThemeApiService from "@/lib/services/theme/theme_api_service";
+import { DynamoDBWebsitePageTemplateRepository } from "@/lib/repositories/website_page_template/dynamodb_website_page_template_repository";
+import { IndexPageTemplate } from "@/lib/types/website_page_templates/index_page_template";
-export default function ThemePage({ themeData }: { themeData: ITheme }) {
- return ;
+export default function ThemePage({
+ themeData,
+ pageTemplate,
+}: {
+ themeData: ITheme;
+ pageTemplate: IndexPageTemplate;
+}) {
+ return ;
}
export async function getStaticProps(context: GetServerSidePropsContext) {
@@ -14,10 +22,21 @@ export async function getStaticProps(context: GetServerSidePropsContext) {
const adminThemeRepoService = new ThemeApiService(themeRepo);
const res = await adminThemeRepoService.getTheme(path.theme);
- if (res.status === "success" && res.data) {
+ const dynamodbWebsiteTemplateRepo =
+ new DynamoDBWebsitePageTemplateRepository();
+ const websiteTemplate =
+ await dynamodbWebsiteTemplateRepo.getIndexPageTemplate();
+
+ if (
+ res.status === "success" &&
+ res.data &&
+ websiteTemplate.status === "success" &&
+ websiteTemplate.data
+ ) {
return {
props: {
themeData: res.data,
+ pageTemplate: websiteTemplate.data,
},
revalidate: 60 * 15,
};