-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowOpenToasts.tsx
44 lines (40 loc) · 1.3 KB
/
showOpenToasts.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
import React from 'react'
import InteractiveToast from '@ui/components/InteractiveToast'
import toast from 'react-hot-toast'
import { useNavigation } from '@hooks/useNavigation'
import { NavigationType, ROUTE_PATHS, useRouting } from '@views/routes/urls'
import { useSnippetStore } from '@store/useSnippetStore'
export const useOpenToast = () => {
const { push } = useNavigation()
const { goTo } = useRouting()
const loadSnippet = useSnippetStore((store) => store.loadSnippet)
const openNoteToast = (nodeid: string, title: string) => {
toast.custom((t) => (
<InteractiveToast
tid={t.id}
message={`Created new note: ${title}`}
actionName="Open"
onClick={() => {
push(nodeid)
goTo(ROUTE_PATHS.node, NavigationType.push, nodeid)
// console.log('We are here')
}}
/>
))
}
const openSnippetToast = (snippetid: string, title: string) => {
toast.custom((t) => (
<InteractiveToast
tid={t.id}
message={`Created new snippet: ${title}`}
actionName="Open"
onClick={() => {
loadSnippet(snippetid)
goTo(ROUTE_PATHS.snippet, NavigationType.push, snippetid)
// console.log('We are here')
}}
/>
))
}
return { openNoteToast, openSnippetToast }
}