Skip to content

Commit

Permalink
Merge pull request #33 from Glider6014:S1-29_Wymog_logowania_na_stron…
Browse files Browse the repository at this point in the history
…ie_glownej

wymog logowania na stronie glownej
  • Loading branch information
Glider6014 authored Nov 22, 2024
2 parents 3e0a2f1 + 8a3680a commit b9d8b46
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
33 changes: 15 additions & 18 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
"use client";
import { Navbar } from "@/components/Navbar";
import SearchPanel from "@/components/SearchPanel";
import { RecipesList } from "@/components/RecipesList";
import { useState } from "react";
import { RecipeType } from "@/models/Recipe";
import ListIngredientsAndListRecipesSection from "@/components/sections/ListIngredientsAndListRecipesSection";
import { getServerSession } from "next-auth";
import { redirect } from "next/navigation";
import authOptions from "@/lib/nextauth";

export default async function Home() {
const session = await getServerSession(authOptions);

if (!session) {
redirect("/user/signin");
}

export default function Home() {
const [recipes, setRecipes] = useState<RecipeType[]>([]);
return (
<>
<div className="container mx-auto p-4">
<Navbar />
<div className="flex flex-col md:flex-row gap-4">
<SearchPanel setRecipes={setRecipes} />
<div className="w-full md:w-3/5 mt-4 md:mt-0">
<RecipesList recipes={recipes} />
</div>
</div>
</div>
</>
<div className="container mx-auto p-4">
<Navbar />
<ListIngredientsAndListRecipesSection />
</div>
);
}
1 change: 1 addition & 0 deletions components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { Navbar as DropdownMenu } from "@/components/ui/dropdown-menu";
import {
NavigationMenu,
Expand Down
18 changes: 18 additions & 0 deletions components/sections/ListIngredientsAndListRecipesSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use client";
import SearchPanel from "@/components/SearchPanel";
import { RecipesList } from "@/components/RecipesList";
import { RecipeType } from "@/models/Recipe";
import { useState } from "react";

export default function ListIngredientsAndListRecipesSection() {
const [recipes, setRecipes] = useState<RecipeType[]>([]);

return (
<div className="flex flex-col md:flex-row gap-4">
<SearchPanel setRecipes={setRecipes} />
<div className="w-full md:w-3/5 mt-4 md:mt-0">
<RecipesList recipes={recipes} />
</div>
</div>
);
}

0 comments on commit b9d8b46

Please sign in to comment.