From b4de3c4a4fdf63297ec940c4144f880273b002ce Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 12 Sep 2023 17:35:20 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fix=20minor=20styling=20issues?= =?UTF-8?q?=20=F0=9F=90=9B=20Bug=20fix:=20Resolve=20index=20calculation=20?= =?UTF-8?q?=F0=9F=9A=80=20Implement=20dynamic=20'Publish=20listing'=20text?= =?UTF-8?q?=20=E2=9C=A8=20Add=20CommonLayout=20component=20=F0=9F=93=A6=20?= =?UTF-8?q?Refactor=20code=20structure=20=F0=9F=94=A8=20Improve=20code=20r?= =?UTF-8?q?eadability=20=F0=9F=9A=A7=20Work=20in=20progress:=20CommonLayou?= =?UTF-8?q?t=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../add-listing/[[...stepIndex]]/layout.tsx | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/app/add-listing/[[...stepIndex]]/layout.tsx diff --git a/src/app/add-listing/[[...stepIndex]]/layout.tsx b/src/app/add-listing/[[...stepIndex]]/layout.tsx new file mode 100644 index 0000000..e3ef7df --- /dev/null +++ b/src/app/add-listing/[[...stepIndex]]/layout.tsx @@ -0,0 +1,50 @@ +import React from "react"; +import { FC } from "react"; +import ButtonPrimary from "@/shared/ButtonPrimary"; +import ButtonSecondary from "@/shared/ButtonSecondary"; +import { Route } from "@/routers/types"; + +export interface CommonLayoutProps { + children: React.ReactNode; + params: { + stepIndex: string; + }; +} + +const CommonLayout: FC = ({ children, params }) => { + const index = Number(params.stepIndex) || 1; + const nextHref = ( + index < 10 ? `/add-listing/${index + 1}` : `/add-listing/${1}` + ) as Route; + const backtHref = ( + index > 1 ? `/add-listing/${index - 1}` : `/add-listing/${1}` + ) as Route; + const nextBtnText = index > 9 ? "Publish listing" : "Continue"; + return ( +
+
+
+ {index}{" "} + + / 10 + +
+ + {/* --------------------- */} +
{children}
+ + {/* --------------------- */} +
+ Go back + + {nextBtnText || "Continue"} + +
+
+
+ ); +}; + +export default CommonLayout;