Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.0.1 #28

Merged
merged 12 commits into from
Mar 11, 2024
3 changes: 3 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const nextConfig = {
return config;
},
output: 'standalone',
env: {
appVersion: process.env.npm_package_version,
},
};

export default nextConfig;
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "next-finances",
"description": "A finances application to keep track of my personal spendings",
"homepage": "https://github.com/MarkusThielker/next-finances",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"author": {
"name": "Markus Thielker"
Expand Down
52 changes: 34 additions & 18 deletions src/app/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,25 @@ export default async function AccountPage() {
}

let paymentCount = 0;
paymentCount = await prismaClient.payment.count({
where: {
userId: user.id,
},
});

let entityCount = 0;
let categoryCount = 0;
entityCount = await prismaClient.entity.count({
where: {
userId: user.id,
},
});

if (process.env.NODE_ENV === 'development') {
paymentCount = await prismaClient.payment.count({
where: {
userId: user.id,
},
});
entityCount = await prismaClient.entity.count({
where: {
userId: user.id,
},
});
categoryCount = await prismaClient.category.count({
where: {
userId: user.id,
},
});
}
let categoryCount = 0;
categoryCount = await prismaClient.category.count({
where: {
userId: user.id,
},
});

return (
<div className="flex flex-col items-center">
Expand Down Expand Up @@ -91,6 +90,23 @@ export default async function AccountPage() {
<SignOutForm onSubmit={signOut}/>
</CardFooter>
</Card>
<div className="flex w-full items-center justify-between max-w-md mt-2 text-neutral-600">
<p>Version {process.env.appVersion}</p>
<div className="flex items-center justify-between space-x-4">
<a
target="_blank"
className="hover:text-neutral-500 duration-100"
href="https://github.com/MarkusThielker/next-finances">
Source Code
</a>
<a
target="_blank"
className="hover:text-neutral-500 duration-100"
href="https://github.com/MarkusThielker/next-finances/releases">
Changelog
</a>
</div>
</div>
</div>
);
}
10 changes: 9 additions & 1 deletion src/app/payments/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ export const columns = (
header: 'Category',
cell: ({row}) => {
const category = categories.find((category) => category.id === row.original.categoryId);
return category?.name ?? '-';
return (
<div className="flex items-center space-x-4">
<svg className="h-5" fill={category?.color} viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg">
<circle cx="10" cy="10" r="10"/>
</svg>
<p>{category?.name ?? '-'}</p>
</div>
);
},
},
{
Expand Down
105 changes: 67 additions & 38 deletions src/components/ui/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { ColumnDef, flexRender, getCoreRowModel, getPaginationRowModel, useReact

import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
import { Button } from '@/components/ui/button';
import React from 'react';
import React, { useEffect, useState } from 'react';
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';

interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
Expand All @@ -20,13 +21,21 @@ export function DataTable<TData, TValue>({
pagination,
className,
}: DataTableProps<TData, TValue>) {

const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: pagination ? getPaginationRowModel() : undefined,
});

const [pageSize, setPageSize] = useState(50);
useEffect(() => {
if (pagination) {
table.setPageSize(pageSize);
}
}, [table, pagination, pageSize]);

return (
<div className={className}>
<div className="rounded-md border">
Expand Down Expand Up @@ -57,7 +66,8 @@ export function DataTable<TData, TValue>({
data-state={row.getIsSelected() && 'selected'}
>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}>
<TableCell key={cell.id}
className={cell.id.endsWith('actions') ? 'w-[120px]' : ''}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
Expand All @@ -75,43 +85,62 @@ export function DataTable<TData, TValue>({
</div>
{
pagination && (
<div className="flex items-center justify-end space-x-2 py-4">
<Button
variant="outline"
size="icon"
onClick={() => table.firstPage()}
disabled={!table.getCanPreviousPage()}
>
<span className="sr-only">First page</span>
<ChevronsLeft/>
</Button>
<Button
variant="outline"
size="icon"
onClick={() => table.previousPage()}
disabled={!table.getCanPreviousPage()}
<div className="flex items-center justify-between py-4">
<Select
onValueChange={(value) => {
setPageSize(parseInt(value));
}}
value={pageSize.toString()}
>
<span className="sr-only">Previous page</span>
<ChevronLeft/>
</Button>
<Button
variant="outline"
size="icon"
onClick={() => table.nextPage()}
disabled={!table.getCanNextPage()}
>
<span className="sr-only">Next page</span>
<ChevronRight/>
</Button>
<Button
variant="outline"
size="icon"
onClick={() => table.lastPage()}
disabled={!table.getCanNextPage()}
>
<span className="sr-only">Last page</span>
<ChevronsRight/>
</Button>
<SelectTrigger className="w-[150px]">
<SelectValue placeholder="Select a scope"/>
</SelectTrigger>
<SelectContent>
<SelectItem value={'25'} key={'25'}>25</SelectItem>
<SelectItem value={'50'} key={'50'}>50</SelectItem>
<SelectItem value={'75'} key={'75'}>75</SelectItem>
<SelectItem value={'100'} key={'100'}>100</SelectItem>
</SelectContent>
</Select>

<div className="flex flex-row items-center space-x-2">
<Button
variant="outline"
size="icon"
onClick={() => table.firstPage()}
disabled={!table.getCanPreviousPage()}
>
<span className="sr-only">First page</span>
<ChevronsLeft/>
</Button>
<Button
variant="outline"
size="icon"
onClick={() => table.previousPage()}
disabled={!table.getCanPreviousPage()}
>
<span className="sr-only">Previous page</span>
<ChevronLeft/>
</Button>
<Button
variant="outline"
size="icon"
onClick={() => table.nextPage()}
disabled={!table.getCanNextPage()}
>
<span className="sr-only">Next page</span>
<ChevronRight/>
</Button>
<Button
variant="outline"
size="icon"
onClick={() => table.lastPage()}
disabled={!table.getCanNextPage()}
>
<span className="sr-only">Last page</span>
<ChevronsRight/>
</Button>
</div>
</div>
)
}
Expand Down