N-FIN-31: add min column width (#38)

Resolves #31
This commit is contained in:
Markus Thielker 2024-03-17 00:08:35 +01:00 committed by GitHub
commit a6c9074490
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 12 additions and 17 deletions

View file

@ -42,7 +42,7 @@ export default async function AccountPage() {
return ( return (
<div className="flex flex-col items-center"> <div className="flex flex-col items-center">
<Card className="w-full max-w-md mt-12"> <Card className="w-full max-w-md md:mt-12">
<CardHeader> <CardHeader>
<CardTitle>Hey, {user?.username}!</CardTitle> <CardTitle>Hey, {user?.username}!</CardTitle>
<CardDescription>This is your account overview.</CardDescription> <CardDescription>This is your account overview.</CardDescription>
@ -81,7 +81,7 @@ export default async function AccountPage() {
</div> </div>
</div> </div>
</CardContent> </CardContent>
<CardFooter className="space-x-4"> <CardFooter className="grid gap-4 grid-cols-1 md:grid-cols-2">
{ {
process.env.NODE_ENV === 'development' && ( process.env.NODE_ENV === 'development' && (
<GenerateSampleDataForm onSubmit={generateSampleData}/> <GenerateSampleDataForm onSubmit={generateSampleData}/>

View file

@ -25,6 +25,7 @@ export const columns = (
</svg> </svg>
); );
}, },
size: 65,
}, },
{ {
accessorKey: 'createdAt', accessorKey: 'createdAt',

View file

@ -17,6 +17,7 @@ export const columns = (
{ {
accessorKey: 'type', accessorKey: 'type',
header: 'Type', header: 'Type',
size: 100,
}, },
{ {
accessorKey: 'createdAt', accessorKey: 'createdAt',

View file

@ -18,6 +18,7 @@ export const columns = (
cell: ({row}) => { cell: ({row}) => {
return format(row.original.date, 'PPP'); return format(row.original.date, 'PPP');
}, },
size: 175,
}, },
{ {
accessorKey: 'amount', accessorKey: 'amount',
@ -28,6 +29,7 @@ export const columns = (
currency: 'EUR', currency: 'EUR',
}).format(row.getValue('amount') as number / 100); }).format(row.getValue('amount') as number / 100);
}, },
size: 70,
}, },
{ {
accessorKey: 'payorId', accessorKey: 'payorId',
@ -36,6 +38,7 @@ export const columns = (
const entity = entities.find((entity) => entity.id === row.original.payorId); const entity = entities.find((entity) => entity.id === row.original.payorId);
return entity?.name ?? '-'; return entity?.name ?? '-';
}, },
size: 200,
}, },
{ {
accessorKey: 'payeeId', accessorKey: 'payeeId',
@ -44,6 +47,7 @@ export const columns = (
const entity = entities.find((entity) => entity.id === row.original.payeeId); const entity = entities.find((entity) => entity.id === row.original.payeeId);
return entity?.name ?? '-'; return entity?.name ?? '-';
}, },
size: 200,
}, },
{ {
accessorKey: 'categoryId', accessorKey: 'categoryId',
@ -60,10 +64,12 @@ export const columns = (
</div> </div>
); );
}, },
size: 200,
}, },
{ {
accessorKey: 'note', accessorKey: 'note',
header: 'Note', header: 'Note',
size: 200,
}, },
{ {
id: 'actions', id: 'actions',

View file

@ -100,20 +100,6 @@ export default function PaymentPageClientContent({
); );
}; };
const entitiesMapped = entities?.map((entity) => {
return {
label: entity.name,
value: entity.id,
};
}) ?? [];
const categoriesMapped = categories?.map((category) => {
return {
label: category.name,
value: category.id,
};
}) ?? [];
return ( return (
<div className={className}> <div className={className}>
<div className="flex items-center justify-between w-full"> <div className="flex items-center justify-between w-full">

View file

@ -45,7 +45,8 @@ export function DataTable<TData, TValue>({
<TableRow key={headerGroup.id}> <TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => { {headerGroup.headers.map((header) => {
return ( return (
<TableHead key={header.id}> <TableHead key={header.id}
style={{minWidth: `${header.column.getSize()}px`}}>
{header.isPlaceholder {header.isPlaceholder
? null ? null
: flexRender( : flexRender(