Просмотр исходного кода

RHL-021 feat(view): add layout components for day, month, year, and branch with validation

Code_Uwe 1 месяц назад
Родитель
Сommit
841f1f5211

+ 14 - 0
app/(protected)/[branch]/[year]/[month]/[day]/layout.jsx

@@ -0,0 +1,14 @@
+import React from "react";
+import { notFound } from "next/navigation";
+
+import { isValidDayParam } from "@/lib/frontend/params";
+
+export default async function DayLayout({ children, params }) {
+	const { day } = await params;
+
+	if (!isValidDayParam(day)) {
+		notFound();
+	}
+
+	return children;
+}

+ 14 - 0
app/(protected)/[branch]/[year]/[month]/layout.jsx

@@ -0,0 +1,14 @@
+import React from "react";
+import { notFound } from "next/navigation";
+
+import { isValidMonthParam } from "@/lib/frontend/params";
+
+export default async function MonthLayout({ children, params }) {
+	const { month } = await params;
+
+	if (!isValidMonthParam(month)) {
+		notFound();
+	}
+
+	return children;
+}

+ 14 - 0
app/(protected)/[branch]/[year]/layout.jsx

@@ -0,0 +1,14 @@
+import React from "react";
+import { notFound } from "next/navigation";
+
+import { isValidYearParam } from "@/lib/frontend/params";
+
+export default async function YearLayout({ children, params }) {
+	const { year } = await params;
+
+	if (!isValidYearParam(year)) {
+		notFound();
+	}
+
+	return children;
+}

+ 15 - 0
app/(protected)/[branch]/layout.jsx

@@ -0,0 +1,15 @@
+import React from "react";
+import { notFound } from "next/navigation";
+
+import BranchGuard from "@/components/auth/BranchGuard";
+import { isValidBranchParam } from "@/lib/frontend/params";
+
+export default async function BranchLayout({ children, params }) {
+	const { branch } = await params;
+
+	if (!isValidBranchParam(branch)) {
+		notFound();
+	}
+
+	return <BranchGuard branch={branch}>{children}</BranchGuard>;
+}