|
1 | 1 | <script lang="ts"> |
2 | 2 | import { getHMSStringFromSeconds } from '../lib/utils' |
| 3 | + import { |
| 4 | + Store, |
| 5 | + Hourglass, |
| 6 | + CalendarDays, |
| 7 | + Folder, |
| 8 | + SquareCheckBig, |
| 9 | + } from '@lucide/svelte' |
3 | 10 |
|
4 | 11 | export let pdfDocument: PDFQueryResult[] |
5 | | -
|
6 | | - type PDFTotalObject = { |
7 | | - [companyName: string]: { |
8 | | - [projectName: string]: { |
9 | | - [taskName: string]: number |
10 | | - } |
11 | | - } |
12 | | - } |
13 | | -
|
14 | | - $: total = (() => { |
15 | | - const result: PDFTotalObject = {} |
16 | | - pdfDocument.forEach((item: PDFQueryResult) => { |
17 | | - if (!result[item.companyName]) { |
18 | | - result[item.companyName] = {} |
19 | | - } |
20 | | - if (!result[item.companyName][item.projectName]) { |
21 | | - result[item.companyName][item.projectName] = {} |
22 | | - } |
23 | | - if (!result[item.companyName][item.projectName][item.name]) { |
24 | | - result[item.companyName][item.projectName][item.name] = 0 |
25 | | - } |
26 | | - result[item.companyName][item.projectName][item.name] += item.seconds |
27 | | - }) |
28 | | - return result |
29 | | - })() |
30 | 12 | </script> |
31 | 13 |
|
32 | 14 | <div class="space-y-2"> |
33 | 15 | <!-- Tasks List --> |
34 | 16 | {#each pdfDocument as item (item.id)} |
35 | | - <div class="card shadow-xl border"> |
36 | | - <div class="card-body p-4"> |
37 | | - <h3 class="font-semibold text-xs"> |
38 | | - {item.companyName} |
39 | | - </h3> |
40 | | - <h2 class="card-title text-xl">{item.projectName}</h2> |
41 | | - <p class="font-semibold text-base">{item.name}</p> |
| 17 | + <div class="shadow-xl border rounded-lg"> |
| 18 | + <div class="p-4"> |
| 19 | + <div |
| 20 | + class="font-semibold text-xs grid grid-cols-[max-content_1fr] content-start gap-2 w-fit p-1" |
| 21 | + > |
| 22 | + <span class="w-fit"> |
| 23 | + <Store size="16" class="text-info" /> |
| 24 | + </span> |
| 25 | + <span class="w-fit">{item.companyName}</span> |
| 26 | + </div> |
| 27 | + <div |
| 28 | + class="text-xl grid grid-cols-[max-content_1fr] content-start gap-2 w-fit p-1" |
| 29 | + > |
| 30 | + <span> |
| 31 | + <Folder size="24" class="text-success" /> |
| 32 | + </span> |
| 33 | + <span>{item.projectName}</span> |
| 34 | + </div> |
| 35 | + <div |
| 36 | + class="font-semibold text-base grid grid-cols-[max-content_1fr] content-start gap-2 w-fit p-1" |
| 37 | + > |
| 38 | + <div class="w-fit"> |
| 39 | + <SquareCheckBig size="24" class="text-warning" /> |
| 40 | + </div> |
| 41 | + <div class="w-fit">{item.name}</div> |
| 42 | + </div> |
42 | 43 | {#if item.description} |
43 | | - <div class="prose max-w-none markdown-content text-sm"> |
| 44 | + <div class="prose max-w-none markdown-content text-sm p-1"> |
44 | 45 | <!-- eslint-disable-next-line svelte/no-at-html-tags --> |
45 | 46 | {@html item.description} |
46 | 47 | </div> |
47 | 48 | {/if} |
48 | | - <div class="flex gap-4 mt-2 text-sm"> |
| 49 | + <div class="flex gap-4 mt-2 text-sm p-1"> |
49 | 50 | <div class="flex items-center gap-2"> |
50 | | - <i class="fa-solid fa-calendar hidden"></i> |
| 51 | + <CalendarDays size="16" class="text-info" /> |
51 | 52 | <time datetime={item.date}>{item.date}</time> |
52 | 53 | </div> |
53 | 54 | <div class="flex items-center gap-2"> |
54 | | - <i class="fa-solid fa-clock hidden"></i> |
| 55 | + <Hourglass size="16" class="text-secondary" /> |
55 | 56 | <span>Time spent: {getHMSStringFromSeconds(item.seconds)}</span> |
56 | 57 | </div> |
57 | 58 | </div> |
58 | 59 | </div> |
59 | 60 | </div> |
60 | 61 | {/each} |
61 | 62 |
|
62 | | - <!-- Total View --> |
63 | | - <section class="hero rounded-lg p-4 mt-8"> |
64 | | - <div class="hero-content"> |
65 | | - <div> |
66 | | - <h2 class="font-bold text-xl">Total Time</h2> |
67 | | - <p class="mt-2 text-sm"> |
68 | | - Total time spent on projects and tasks combined. |
69 | | - </p> |
70 | | - </div> |
71 | | - </div> |
72 | | - </section> |
| 63 | + <!-- Stats View --> |
73 | 64 |
|
74 | | - {#each Object.keys(total) as companyName (companyName)} |
75 | | - <div class="card shadow-xl border"> |
76 | | - <div class="card-body p-4"> |
77 | | - <h2 class="card-title text-xl">{companyName}</h2> |
78 | | - {#each Object.keys(total[companyName]) as projectName (projectName)} |
79 | | - <div class="mt-4"> |
80 | | - <h3 class="font-semibold text-base mb-2"> |
81 | | - {projectName} |
82 | | - </h3> |
83 | | - <div class="space-y-2 text-sm ml-4"> |
84 | | - {#each Object.keys(total[companyName][projectName]) as taskName (taskName)} |
85 | | - <div class="flex justify-between items-center"> |
86 | | - <span class="font-semibold">{taskName}</span> |
87 | | - <span class="badge badge-primary badge-sm text-base"> |
88 | | - {getHMSStringFromSeconds( |
89 | | - total[companyName][projectName][taskName], |
90 | | - )} |
91 | | - </span> |
92 | | - </div> |
93 | | - {/each} |
94 | | - </div> |
95 | | - </div> |
96 | | - {/each} |
97 | | - </div> |
98 | | - </div> |
99 | | - {/each} |
| 65 | + <div role="alert" class="alert"> |
| 66 | + <CalendarDays size="16" class="text-info" /> |
| 67 | + <span> |
| 68 | + The tasks shown are between <strong>{pdfDocument[0]?.date}</strong> and |
| 69 | + <strong>{pdfDocument[pdfDocument.length - 1]?.date}</strong> |
| 70 | + </span> |
| 71 | + </div> |
| 72 | + <div role="alert" class="alert"> |
| 73 | + <Hourglass size="16" class="text-secondary" /> |
| 74 | + <span> |
| 75 | + All tasks combined have a total time of |
| 76 | + <strong> |
| 77 | + {getHMSStringFromSeconds( |
| 78 | + pdfDocument.reduce((acc, item) => acc + item.seconds, 0), |
| 79 | + )} |
| 80 | + </strong> |
| 81 | + </span> |
| 82 | + </div> |
100 | 83 |
|
101 | 84 | <!-- Powered by header --> |
102 | 85 | <section class="hero rounded-lg p-4"> |
|
0 commit comments