Поправил схему, добавил инфу поля в навбар если пользователь админ
This commit is contained in:
parent
f721d16ace
commit
a287fec381
4 changed files with 32 additions and 10 deletions
|
|
@ -1,4 +1,10 @@
|
|||
---
|
||||
export interface Props {
|
||||
is_user_admin: boolean;
|
||||
}
|
||||
|
||||
const { is_user_admin } = Astro.props;
|
||||
|
||||
const items = [
|
||||
{
|
||||
href: "/",
|
||||
|
|
@ -8,6 +14,14 @@ const items = [
|
|||
href: "/timetable",
|
||||
title: "Расписание",
|
||||
},
|
||||
];
|
||||
if (is_user_admin) {
|
||||
items.push({
|
||||
href: "/users",
|
||||
title: "Пользователи",
|
||||
});
|
||||
}
|
||||
const itemsRight = [
|
||||
{
|
||||
href: "/logout",
|
||||
title: "Выйти",
|
||||
|
|
@ -28,5 +42,17 @@ const items = [
|
|||
))
|
||||
}
|
||||
</ul>
|
||||
<div class="flex-grow-1"></div>
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0 text-white">
|
||||
{
|
||||
itemsRight.map((e) => (
|
||||
<li class="nav-item">
|
||||
<a href={e.href} class="active nav-link text-white" aria-current="page">
|
||||
{e.title}
|
||||
</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ if (articleId) {
|
|||
|
||||
<Layout title="Создание новости">
|
||||
<main data-article={article?.message} data-articleId={articleId}>
|
||||
<Navbar />
|
||||
<Navbar is_user_admin={user.is_admin} />
|
||||
<div class="container mt-5" style="max-width: 650px;">
|
||||
<div class="d-flex">
|
||||
<button type="button" class="btn btn-sm btn-success flex-fill" id="saveBtn">Сохранить</button>
|
||||
|
|
|
|||
|
|
@ -17,17 +17,13 @@ if (Astro.cookies.has("session")) {
|
|||
return Astro.redirect("/login");
|
||||
}
|
||||
|
||||
const { news, alerts } = await getNewsAndAlerts();
|
||||
|
||||
const items: NavbarItemType[] = [
|
||||
{ text: "Новости", href: "/" },
|
||||
{ text: "Расписание", href: "/timetable" },
|
||||
];
|
||||
const sessId = Astro.cookies.get("session").value!;
|
||||
const user = (await getSessionUser(sessId))!;
|
||||
---
|
||||
|
||||
<Layout title="Новости">
|
||||
<main>
|
||||
<Navbar />
|
||||
<Navbar is_user_admin={user.is_admin} />
|
||||
<NewsBlock />
|
||||
</main>
|
||||
</Layout>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue