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;