2024-09-02 15:44:49 +00:00
|
|
|
import { Layout, LayoutContent, LayoutHeader, ProtectedRoute } from "@/components";
|
2024-06-29 19:39:25 +00:00
|
|
|
import { PropsWithChildren } from "react";
|
2024-09-02 15:44:49 +00:00
|
|
|
import { Outlet, useLocation } from "react-router-dom";
|
2024-06-29 19:39:25 +00:00
|
|
|
import { QuotesProvider } from "./QuotesContext";
|
|
|
|
|
|
|
|
|
|
export const QuotesLayout = ({ children }: PropsWithChildren) => {
|
2024-09-02 15:44:49 +00:00
|
|
|
const location = useLocation();
|
|
|
|
|
|
|
|
|
|
const isEditing = location.pathname.includes("/edit");
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ProtectedRoute>
|
|
|
|
|
<QuotesProvider>
|
|
|
|
|
<Layout>
|
|
|
|
|
<LayoutHeader />
|
|
|
|
|
<LayoutContent>
|
|
|
|
|
{" "}
|
|
|
|
|
<div className={`layout ${isEditing ? "editing" : ""}`}>
|
|
|
|
|
<div className='quotes-list'>
|
|
|
|
|
<Outlet />
|
|
|
|
|
</div>
|
|
|
|
|
{isEditing && (
|
|
|
|
|
<div className='quotes-editor'>
|
|
|
|
|
<Outlet />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</LayoutContent>
|
|
|
|
|
</Layout>
|
|
|
|
|
</QuotesProvider>
|
|
|
|
|
</ProtectedRoute>
|
|
|
|
|
);
|
|
|
|
|
|
2024-06-29 19:39:25 +00:00
|
|
|
return (
|
|
|
|
|
<QuotesProvider>
|
|
|
|
|
<Layout>
|
|
|
|
|
<LayoutHeader />
|
|
|
|
|
<LayoutContent>{children}</LayoutContent>
|
|
|
|
|
</Layout>
|
|
|
|
|
</QuotesProvider>
|
|
|
|
|
);
|
|
|
|
|
};
|