Skip to content

Commit bee5b34

Browse files
authored
Fixed nested a tags (#346)
1 parent f874af5 commit bee5b34

2 files changed

Lines changed: 39 additions & 30 deletions

File tree

src/app/admin/streck/strecklist-table.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ const StreckListTable = async ({
7373
: streckList.transactions.every((t) => t.pricePer > 0)
7474
? 'deposit'
7575
: 'unknown';
76+
const link = `/admin/streck/view/${streckList.id}`;
7677
return (
77-
<Link
78-
href={`/admin/streck/view/${streckList.id}`}
78+
<div
7979
key={streckList.id}
80-
className='table-row divide-x divide-y divide-solid whitespace-nowrap hover:bg-red-300/5 dark:divide-neutral-800'
80+
className='table-row divide-x divide-y divide-solid whitespace-nowrap hover:cursor-pointer hover:bg-red-300/5 dark:divide-neutral-800'
8181
>
8282
<div className='table-cell border-t px-2 align-middle dark:border-neutral-800'>
8383
{listType === 'strecklist'
@@ -88,15 +88,18 @@ const StreckListTable = async ({
8888
? lang('Intäkt', 'Income')
8989
: lang('Blandat', 'Mixed')}
9090
</div>
91-
<div className='table-cell px-2 align-middle'>
91+
<Link href={link} className='table-cell px-2 align-middle'>
9292
{dayjs(streckList.time).format(dateFormat)}
93-
</div>
94-
<div className='table-cell px-2 align-middle'>
93+
</Link>
94+
<Link href={link} className='table-cell px-2 align-middle'>
9595
{numberAndFullName(streckList.createdBy)}
96-
</div>
97-
<div className='table-cell px-2 text-right align-middle'>
96+
</Link>
97+
<Link
98+
href={link}
99+
className='table-cell px-2 text-right align-middle'
100+
>
98101
{streckList.totalChange}
99-
</div>
102+
</Link>
100103
<Restricted permissions='manageStreck'>
101104
<div className='table-cell'>
102105
<Tooltip text={lang('Uppdatera', 'Edit')}>
@@ -159,7 +162,7 @@ const StreckListTable = async ({
159162
</div>
160163
)}
161164
</Restricted>
162-
</Link>
165+
</div>
163166
);
164167
})}
165168
</div>

src/app/admin/streck/view/transactions-summary.tsx

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { api } from 'trpc/server';
3+
import { lang } from 'utils/language';
34

45
interface TransactionsSummaryProps {
56
start?: Date;
@@ -18,33 +19,38 @@ const TransactionsSummary = async ({
1819
take,
1920
});
2021

22+
let sum = 0;
23+
24+
const summary = transactions.items.map((item) => {
25+
const summary = transactions.summary[item];
26+
if (!summary) {
27+
return null;
28+
}
29+
sum += summary.totalPrice;
30+
return (
31+
<tr key={item} className='divide-x divide-solid dark:divide-neutral-800'>
32+
<td className='px-2'>{item}</td>
33+
<td className='px-2 text-right'>{summary.amount}</td>
34+
<td className='px-2 text-right'>{summary.totalPrice}</td>
35+
</tr>
36+
);
37+
});
38+
2139
return (
22-
<div>
40+
<div className='flex max-w-min flex-col gap-2'>
41+
<h5>
42+
{lang('Summa:', 'Sum:')} {sum}
43+
</h5>
2344
<table className='table text-sm'>
2445
<thead>
2546
<tr className='text-left'>
26-
<th className='px-1'>Artikel</th>
27-
<th className='px-1'>Antal</th>
28-
<th className='px-1'>Totalpris</th>
47+
<th className='px-1'>{lang('Artikel', 'Item')}</th>
48+
<th className='px-1'>{lang('Antal', 'Amount')}</th>
49+
<th className='px-1'>{lang('Totalpris', 'Total price')}</th>
2950
</tr>
3051
</thead>
3152
<tbody className='gap-1 divide-y divide-solid dark:divide-neutral-800'>
32-
{transactions.items.map((item) => {
33-
const summary = transactions.summary[item];
34-
if (!summary) {
35-
return null;
36-
}
37-
return (
38-
<tr
39-
key={item}
40-
className='divide-x divide-solid dark:divide-neutral-800'
41-
>
42-
<td className='px-2'>{item}</td>
43-
<td className='px-2 text-right'>{summary.amount}</td>
44-
<td className='px-2 text-right'>{summary.totalPrice}</td>
45-
</tr>
46-
);
47-
})}
53+
{summary}
4854
</tbody>
4955
</table>
5056
</div>

0 commit comments

Comments
 (0)