diff --git a/resources/js/components/Todos.vue b/resources/js/components/Todos.vue index 130d8bf..4eb5a6c 100644 --- a/resources/js/components/Todos.vue +++ b/resources/js/components/Todos.vue @@ -12,7 +12,6 @@ const props = defineProps<{ }>() const todos = ref([]) const emit = defineEmits(['update:modelValue']) -const showCompleted = ref(props.showCompleted) watch(() => props.modelValue, value => { todos.value = value as Todo[]; @@ -55,6 +54,12 @@ const groupedTodos = computed(() => { return groups }) +const todosEmpty = (todos: Todo[]) => { + if (todos.length === 0) return true + if (!props.showCompleted && !todos.some(todo => todo.status?.toLowerCase() !== 'completed')) return true + return false +} + const todoTitle = (title: string) => { // If there's no title, return empty string if (!title) return ''; @@ -82,71 +87,75 @@ const todoBadge = (title: string) => { const shouldDisplay = (todo: Todo) => { if (todo.status?.toLowerCase() !== 'completed') return true - return showCompleted.value; // && moment(todo.dueDate).isSameOrAfter(moment(new Date()), 'day') + return props.showCompleted; } \ No newline at end of file