Skip to content

Commit

Permalink
fix last tracked tasks empty state
Browse files Browse the repository at this point in the history
  • Loading branch information
Onatcer committed Apr 17, 2024
1 parent 5b86c85 commit 4400741
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 7 deletions.
1 change: 1 addition & 0 deletions resources/js/Components/Common/Project/ProjectBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const props = withDefaults(
border: boolean;
}>(),
{
name: '',
size: 'base',
tag: 'div',
color: 'var(--theme-color-icon-default)',
Expand Down
1 change: 1 addition & 0 deletions resources/js/Components/Common/Task/TaskCreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async function submit() {
project_id: props.projectId,
});
show.value = false;
taskName.value = '';
}
const taskNameInput = ref<HTMLInputElement | null>(null);
Expand Down
5 changes: 3 additions & 2 deletions resources/js/Components/Dashboard/DashboardCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<CardTitle :title="title" :icon="icon"></CardTitle>

<div
class="rounded-lg bg-card-background border border-card-border flex-1 flex items-center">
<div class="divide-y divide-card-background-separator w-full">
class="rounded-lg bg-card-background border border-card-border flex-1 flex items-stretch">
<div
class="divide-y divide-card-background-separator w-full flex flex-col">
<slot></slot>
</div>
</div>
Expand Down
29 changes: 28 additions & 1 deletion resources/js/Components/Dashboard/RecentlyTrackedTasksCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import RecentlyTrackedTasksCardEntry from '@/Components/Dashboard/RecentlyTrackedTasksCardEntry.vue';
import DashboardCard from '@/Components/Dashboard/DashboardCard.vue';
import { CheckCircleIcon } from '@heroicons/vue/20/solid';
import SecondaryButton from '@/Components/SecondaryButton.vue';
import { PlusCircleIcon } from '@heroicons/vue/24/solid';
import { router } from '@inertiajs/vue3';
const props = defineProps<{
latestTasks: {
id: string;
Expand All @@ -17,7 +21,30 @@ const props = defineProps<{
<RecentlyTrackedTasksCardEntry
v-for="lastTask in props.latestTasks"
:key="lastTask.id"
:project="lastTask.project_name"
:project_id="lastTask.project_id"
:task_id="lastTask.id"
:title="lastTask.name"></RecentlyTrackedTasksCardEntry>
<div v-if="props.latestTasks.length === 0" class="text-center">
<PlusCircleIcon
class="w-8 text-icon-default inline pb-2"></PlusCircleIcon>
<h3 class="text-white font-semibold">No recent tasks found</h3>
<p class="pb-5">Create tasks inside of a project!</p>
<SecondaryButton @click="router.visit(route('projects'))"
>Go to Projects
</SecondaryButton>
</div>
<div
v-if="props.latestTasks.length === 1"
class="text-center flex flex-1 justify-center items-center">
<div>
<PlusCircleIcon
class="w-8 text-icon-default inline pb-2"></PlusCircleIcon>
<h3 class="text-white font-semibold">Add more tasks</h3>
<p class="pb-5">Create tasks inside of a project!</p>
<SecondaryButton @click="router.visit(route('projects'))"
>Go to Projects
</SecondaryButton>
</div>
</div>
</DashboardCard>
</template>
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
<script setup lang="ts">
import ProjectBadge from '@/Components/Common/Project/ProjectBadge.vue';
import TimeTrackerStartStop from '@/Components/Common/TimeTrackerStartStop.vue';
import { useProjectsStore } from '@/utils/useProjects';
import { storeToRefs } from 'pinia';
import { computed } from 'vue';
import dayjs from 'dayjs';
import { useCurrentTimeEntryStore } from '@/utils/useCurrentTimeEntry';
defineProps<{
const props = defineProps<{
title: string;
project: string;
project_id: string;
task_id: string;
}>();
const { projects } = storeToRefs(useProjectsStore());
const project = computed(() => {
return projects.value.find((project) => project.id === props.project_id);
});
const { currentTimeEntry } = storeToRefs(useCurrentTimeEntryStore());
const { stopTimer, startTimer } = useCurrentTimeEntryStore();
async function startTaskTimer() {
if (currentTimeEntry.value.id) {
await stopTimer();
}
currentTimeEntry.value.project_id = props.project_id;
currentTimeEntry.value.task_id = props.task_id;
currentTimeEntry.value.start = dayjs().utc().format();
await startTimer();
useCurrentTimeEntryStore().fetchCurrentTimeEntry();
}
</script>

<template>
Expand All @@ -14,10 +40,13 @@ defineProps<{
<p class="font-semibold text-white text-sm pb-1">
{{ title }}
</p>
<ProjectBadge :name="project"></ProjectBadge>
<ProjectBadge
:name="project?.name"
:color="project?.color"></ProjectBadge>
</div>
<div class="flex items-center justify-center">
<TimeTrackerStartStop></TimeTrackerStartStop>
<TimeTrackerStartStop
@changed="startTaskTimer"></TimeTrackerStartStop>
</div>
</div>
</template>

0 comments on commit 4400741

Please sign in to comment.