mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
feat: add basic admin dashboard
This commit is contained in:
@@ -2,6 +2,7 @@ import type Link from '#models/link';
|
||||
import styled from '@emotion/styled';
|
||||
import LinkItem from '~/components/dashboard/link/link_item';
|
||||
import { NoLink } from '~/components/dashboard/link/no_item';
|
||||
import { sortByCreationDate } from '~/lib/array';
|
||||
|
||||
const LinkListStyle = styled.ul({
|
||||
height: '100%',
|
||||
@@ -23,11 +24,9 @@ export default function LinkList({ links }: { links: Link[] }) {
|
||||
|
||||
return (
|
||||
<LinkListStyle>
|
||||
{links
|
||||
.sort((a, b) => (a.created_at > b.created_at ? 1 : -1))
|
||||
.map((link) => (
|
||||
<LinkItem link={link} key={link.id} showUserControls />
|
||||
))}
|
||||
{sortByCreationDate(links).map((link) => (
|
||||
<LinkItem link={link} key={link.id} showUserControls />
|
||||
))}
|
||||
</LinkListStyle>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Item, ItemLink } from '~/components/dashboard/side_nav/nav_item';
|
||||
import UserCard from '~/components/dashboard/side_nav/user_card';
|
||||
import ModalSettings from '~/components/settings/modal';
|
||||
import useActiveCollection from '~/hooks/use_active_collection';
|
||||
import useUser from '~/hooks/use_user';
|
||||
import { rgba } from '~/lib/color';
|
||||
import { appendCollectionId } from '~/lib/navigation';
|
||||
|
||||
@@ -19,7 +20,7 @@ const SideMenu = styled.nav({
|
||||
flexDirection: 'column',
|
||||
});
|
||||
|
||||
const AdminButton = styled(Item)(({ theme }) => ({
|
||||
const AdminButton = styled(ItemLink)(({ theme }) => ({
|
||||
color: theme.colors.lightRed,
|
||||
'&:hover': {
|
||||
backgroundColor: `${rgba(theme.colors.lightRed, 0.1)}!important`,
|
||||
@@ -43,15 +44,18 @@ const AddButton = styled(ItemLink)(({ theme }) => ({
|
||||
const SearchButton = AddButton.withComponent(Item);
|
||||
|
||||
export default function SideNavigation() {
|
||||
const { user } = useUser();
|
||||
const { t } = useTranslation('common');
|
||||
const { activeCollection } = useActiveCollection();
|
||||
return (
|
||||
<SideMenu>
|
||||
<div css={{ paddingInline: '10px' }}>
|
||||
<UserCard />
|
||||
<AdminButton>
|
||||
<IoShieldHalfSharp /> {t('admin')}
|
||||
</AdminButton>
|
||||
{user!.isAdmin && (
|
||||
<AdminButton href={route('admin.dashboard').url}>
|
||||
<IoShieldHalfSharp /> {t('admin')}
|
||||
</AdminButton>
|
||||
)}
|
||||
<ModalSettings openItem={SettingsButton} />
|
||||
<SearchModal openItem={SearchButton} />
|
||||
<AddButton
|
||||
|
||||
Reference in New Issue
Block a user