-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinks.tsx
110 lines (99 loc) · 3.47 KB
/
links.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import React, { useMemo } from 'react'
import { Icon } from '@iconify/react'
import timerFlashLine from '@iconify/icons-ri/timer-flash-line'
import checkboxLine from '@iconify/icons-ri/checkbox-line'
import appsLine from '@iconify/icons-ri/apps-line'
import quillPenLine from '@iconify/icons-ri/quill-pen-line'
import fileDocument from '@iconify/icons-gg/file-document'
import searchLine from '@iconify/icons-ri/search-line'
import { ROUTE_PATHS } from '../Hooks/useRouting'
import { useHelpStore } from '../Stores/useHelpStore'
import { NavLinkData } from '../Types/Nav'
import { getNodeidFromPathAndLinks, useLinks } from '../Hooks/useLinks'
import { useDataStore } from '../Stores/useDataStore'
import { useEditorStore } from '../Stores/useEditorStore'
import { useReminderStore } from '../Stores/useReminderStore'
import { useTodoStore } from '../Stores/useTodoStore'
/*
Sidebar links are defined here
*/
// Disabled as IconifyIcon type doesn't work
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const GetIcon = (icon: any): React.ReactNode => <Icon icon={icon} />
const useNavlinks = () => {
const shortcuts = useHelpStore((store) => store.shortcuts)
const nodeid = useEditorStore((store) => store.node.nodeid)
const baseNodeId = useDataStore((store) => store.baseNodeId)
const reminders = useReminderStore((store) => store.reminders)
const ilinks = useDataStore((store) => store.ilinks)
const archive = useDataStore((store) => store.archive)
const tasks = useTodoStore((store) => store.todos)
const { getLinkCount } = useLinks()
const noteId = useMemo(() => {
const currentNotId = nodeid === '__null__' ? getNodeidFromPathAndLinks(ilinks, baseNodeId) : nodeid
return currentNotId
}, [nodeid, ilinks])
const count = useMemo(() => getLinkCount(), [reminders, ilinks, archive, tasks])
const getLinks = () => {
const links: NavLinkData[] = [
{
title: 'Search',
path: ROUTE_PATHS.search,
shortcut: shortcuts.showSearch.keystrokes,
icon: GetIcon(searchLine)
},
// {
// title: 'Dashboard',
// path: ROUTE_PATHS.dashborad,
// icon: GetIcon(dashboardLine),
// isComingSoon: true
// },
{
title: 'Notes',
path: `${ROUTE_PATHS.node}/${noteId}`,
shortcut: shortcuts.showEditor.keystrokes,
icon: GetIcon(fileDocument),
count: count.notes
},
{
title: 'Snippets',
path: ROUTE_PATHS.snippets,
shortcut: shortcuts.showSnippets.keystrokes,
icon: GetIcon(quillPenLine),
count: count.snippets
},
{
title: 'Tasks',
path: ROUTE_PATHS.tasks,
icon: GetIcon(checkboxLine),
shortcut: shortcuts.showTasks.keystrokes,
count: count.tasks
// isComingSoon: true
},
{
title: 'Integrations',
path: ROUTE_PATHS.integrations,
shortcut: shortcuts.showIntegrations.keystrokes,
icon: GetIcon(appsLine)
},
{
title: 'Reminders',
path: ROUTE_PATHS.reminders,
icon: GetIcon(timerFlashLine),
count: count.reminders
// shortcut: shortcuts.showReminder.keystrokes
// isComingSoon: true
}
/*{
title: 'Flows',
path: ROUTE_PATHS.integrations,
// shortcut: shortcuts.showIntegrations.keystrokes,
icon: GetIcon(appsLine),
isComingSoon: true
}*/
]
return links
}
return { getLinks }
}
export default useNavlinks