Skip to content

Commit

Permalink
✨ Open note action for icebox items
Browse files Browse the repository at this point in the history
  • Loading branch information
homostellaris committed Jul 19, 2024
1 parent ef24dc6 commit deee727
Showing 1 changed file with 44 additions and 25 deletions.
69 changes: 44 additions & 25 deletions components/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,44 @@ export const Important = ({ todos }: { todos: any[] }) => {
}

export const Icebox = ({ todos }: { todos: any[] }) => {
const [present] = useTodoActionSheet()
const onClick = useCallback(
todo => {
present(todo as CreatedTodo, {
buttons: [
{
text: 'Move to ranked',
data: {
action: 'ranked',
},
handler: async () => {
db.transaction('rw', db.lists, async () => {
const list = await db.lists.get('#important')
db.lists.update('#important', {
order: [...list!.order, todo.id],
})
})
},
},
...(todo.note
? [
{
text: 'Open note',
data: {
action: 'open-note',
},
handler: () => {
window.open(todo.note.uri)
},
},
]
: []),
],
})
},
[present],
)

return (
<>
<IonGrid>
Expand All @@ -655,6 +693,7 @@ export const Icebox = ({ todos }: { todos: any[] }) => {
{todos.map(todo => (
<IceboxItem
key={todo.id}
onClick={onClick}
todo={todo}
/>
))}
Expand All @@ -665,37 +704,17 @@ export const Icebox = ({ todos }: { todos: any[] }) => {
}

export const IceboxItem = ({
onClick,
todo,
}: {
todo: {
id: string
title: string
}
onClick: (todo: CreatedTodo) => void
todo: CreatedTodo
}) => {
const [present] = useTodoActionSheet()

return (
<IonCard
className="cursor-pointer"
onClick={() => {
present(todo as CreatedTodo, {
buttons: [
{
text: 'Move to ranked',
data: {
action: 'ranked',
},
handler: async () => {
db.transaction('rw', db.lists, async () => {
const list = await db.lists.get('#important')
db.lists.update('#important', {
order: [...list!.order, todo.id],
})
})
},
},
],
})
onClick={_event => {
onClick(todo)
}}
>
<IonCardHeader>
Expand Down

0 comments on commit deee727

Please sign in to comment.