11<script setup lang="ts">
22import MainContainer from ' @/packages/ui/src/MainContainer.vue' ;
3- import { PencilSquareIcon , TrashIcon } from ' @heroicons/vue/20/solid' ;
3+ import { PencilSquareIcon , TrashIcon , DocumentTextIcon } from ' @heroicons/vue/20/solid' ;
44import TimeEntryMassUpdateModal from ' @/packages/ui/src/TimeEntry/TimeEntryMassUpdateModal.vue' ;
55import type {
66 Client ,
@@ -15,6 +15,8 @@ import type {
1515import { ref } from ' vue' ;
1616import { twMerge } from ' tailwind-merge' ;
1717import { Checkbox , InputLabel } from ' @/packages/ui/src' ;
18+ import dayjs from ' dayjs' ;
19+ import { getCurrentRole } from ' @/utils/useUser' ;
1820
1921const props = defineProps <{
2022 selectedTimeEntries: TimeEntry [];
@@ -41,6 +43,18 @@ const emit = defineEmits<{
4143}>();
4244
4345const showMassUpdateModal = ref (false );
46+
47+ async function markAsInvoiced() {
48+ if (props .selectedTimeEntries .length === 0 ) return ;
49+ await props .updateTimeEntries ({
50+ invoiced_at: dayjs ().utc ().format (' YYYY-MM-DDTHH:mm:ss[Z]' ),
51+ });
52+ emit (' submit' );
53+ }
54+
55+ const canMarkAsInvoiced = [' owner' , ' administrator' , ' manager' ].includes (
56+ (getCurrentRole () || ' ' ).toString ()
57+ );
4458 </script >
4559
4660<template >
@@ -87,6 +101,13 @@ const showMassUpdateModal = ref(false);
87101 <PencilSquareIcon class =" w-4" ></PencilSquareIcon >
88102 <span > Edit </span >
89103 </button >
104+ <button
105+ v-if =" selectedTimeEntries.length && canMarkAsInvoiced"
106+ class =" text-emerald-500 h-full px-2 space-x-1 items-center flex hover:text-emerald-600 transition focus-visible:ring-2 outline-0 focus-visible:text-emerald-600 focus-visible:ring-ring rounded"
107+ @click =" markAsInvoiced" >
108+ <DocumentTextIcon class =" w-4" ></DocumentTextIcon >
109+ <span > Mark as invoiced </span >
110+ </button >
90111 <button
91112 v-if =" selectedTimeEntries.length"
92113 class =" text-red-400 h-full px-2 space-x-1 items-center flex hover:text-red-500 transition focus-visible:ring-2 outline-0 focus-visible:text-red-500 focus-visible:ring-ring rounded"
0 commit comments