Refactor TodoItem and CreateModal to simplify state management and remove unused code
This commit is contained in:
@@ -5,7 +5,7 @@ import { useTemplateRef } from 'vue'
|
|||||||
import { useTasks } from '../composables/useTasks.ts'
|
import { useTasks } from '../composables/useTasks.ts'
|
||||||
import { router } from '../router.ts'
|
import { router } from '../router.ts'
|
||||||
|
|
||||||
const { createTask, tasks } = useTasks()
|
const { createTask } = useTasks()
|
||||||
|
|
||||||
async function handleSubmit(e: Event) {
|
async function handleSubmit(e: Event) {
|
||||||
const data = new FormData(e.target as HTMLFormElement)
|
const data = new FormData(e.target as HTMLFormElement)
|
||||||
|
|||||||
@@ -2,14 +2,11 @@
|
|||||||
import type { Task } from '../types.ts'
|
import type { Task } from '../types.ts'
|
||||||
import { PhCheckSquare, PhFlag, PhPlay, PhSquare } from '@phosphor-icons/vue'
|
import { PhCheckSquare, PhFlag, PhPlay, PhSquare } from '@phosphor-icons/vue'
|
||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import { computed, ref } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useTasks } from '../composables/useTasks.ts'
|
|
||||||
import { TaskStatus } from '../types.ts'
|
import { TaskStatus } from '../types.ts'
|
||||||
|
|
||||||
const { task } = defineProps<{ task: Task }>()
|
const { task } = defineProps<{ task: Task }>()
|
||||||
|
|
||||||
const { updateTask } = useTasks()
|
|
||||||
|
|
||||||
const dueColor = computed(() => {
|
const dueColor = computed(() => {
|
||||||
const dueDiff = task.dueDate ? DateTime.fromMillis(task.dueDate).diffNow('days').days : undefined
|
const dueDiff = task.dueDate ? DateTime.fromMillis(task.dueDate).diffNow('days').days : undefined
|
||||||
if (!dueDiff)
|
if (!dueDiff)
|
||||||
@@ -27,13 +24,6 @@ const dueColor = computed(() => {
|
|||||||
return 'text-neutral'
|
return 'text-neutral'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const statusSelectVisible = ref(false)
|
|
||||||
|
|
||||||
async function handleClick(update: Partial<Task>) {
|
|
||||||
updateTask({ ...task, ...update })
|
|
||||||
statusSelectVisible.value = false
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ export default function useHistory() {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
store.value = await getValue('history') || []
|
store.value = await getValue('history') || []
|
||||||
resetHistoryIndex()
|
resetHistoryIndex()
|
||||||
console.log({ s: store.value })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const pushHistory = (item: string) => {
|
const pushHistory = (item: string) => {
|
||||||
|
|||||||
2
src/vite-env.d.ts
vendored
2
src/vite-env.d.ts
vendored
@@ -3,7 +3,7 @@
|
|||||||
declare module '*.vue' {
|
declare module '*.vue' {
|
||||||
import type { DefineComponent } from 'vue'
|
import type { DefineComponent } from 'vue'
|
||||||
|
|
||||||
const component: DefineComponent<{}, {}, any>
|
const component: DefineComponent<object, object, any>
|
||||||
export default component
|
export default component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user