mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
Revert "Add: tRPC + register on first time login"
This reverts commit cb5f9017a9a3e1e0886bfa67b9b9f5554f527d35.
This commit is contained in:
@@ -13,64 +13,67 @@ import { prisma } from "../utils/back";
|
||||
import { config } from "../config";
|
||||
|
||||
interface HomeProps {
|
||||
categories: Category[];
|
||||
favorites: Link[];
|
||||
categories: Category[];
|
||||
favorites: Link[];
|
||||
}
|
||||
|
||||
function Home({ categories, favorites }: HomeProps) {
|
||||
const { data } = useSession({ required: true });
|
||||
const [categoryActive, setCategoryActive] = useState<Category | null>(
|
||||
categories?.[0]
|
||||
);
|
||||
const { data } = useSession({ required: true });
|
||||
const [categoryActive, setCategoryActive] = useState<Category | null>(
|
||||
categories?.[0]
|
||||
);
|
||||
|
||||
const handleSelectCategory = (category: Category) =>
|
||||
setCategoryActive(category);
|
||||
const handleSelectCategory = (category: Category) =>
|
||||
setCategoryActive(category);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{config.siteName}</title>
|
||||
</Head>
|
||||
<div className="App">
|
||||
<Menu
|
||||
categories={categories}
|
||||
favorites={favorites}
|
||||
handleSelectCategory={handleSelectCategory}
|
||||
categoryActive={categoryActive}
|
||||
session={data}
|
||||
/>
|
||||
<Links category={categoryActive} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{config.siteName}</title>
|
||||
</Head>
|
||||
<div className="App">
|
||||
<Menu
|
||||
categories={categories}
|
||||
favorites={favorites}
|
||||
handleSelectCategory={handleSelectCategory}
|
||||
categoryActive={categoryActive}
|
||||
session={data}
|
||||
/>
|
||||
<Links category={categoryActive} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
const categoriesDB = await prisma.category.findMany({
|
||||
include: { links: true },
|
||||
});
|
||||
const categoriesDB = await prisma.category.findMany({
|
||||
include: { links: true },
|
||||
});
|
||||
|
||||
const favorites = [] as Link[];
|
||||
const categories = categoriesDB.map((categoryDB) => {
|
||||
const category = BuildCategory(categoryDB);
|
||||
category.links.map((link) => (link.favorite ? favorites.push(link) : null));
|
||||
return category;
|
||||
});
|
||||
const favorites = [] as Link[];
|
||||
const categories = categoriesDB.map((categoryDB) => {
|
||||
const category = BuildCategory(categoryDB);
|
||||
category.links.map((link) =>
|
||||
link.favorite ? favorites.push(link) : null
|
||||
);
|
||||
return category;
|
||||
});
|
||||
|
||||
if (categories.length === 0) {
|
||||
return {
|
||||
redirect: {
|
||||
destination:
|
||||
"/category/create?info=Veuillez créer une catégorie",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (categories.length === 0) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/category/create",
|
||||
},
|
||||
props: {
|
||||
categories: JSON.parse(JSON.stringify(categories)),
|
||||
favorites: JSON.parse(JSON.stringify(favorites)),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
categories: JSON.parse(JSON.stringify(categories)),
|
||||
favorites: JSON.parse(JSON.stringify(favorites)),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Home.authRequired = true;
|
||||
|
||||
Reference in New Issue
Block a user