Y3:0
This commit is contained in:
parent
eadd939aa9
commit
3cc225deb0
|
|
@ -29,6 +29,15 @@ export default [
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
rules: {
|
||||
'react-hooks/set-state-in-effect': 'off',
|
||||
'react-hooks/static-components': 'off',
|
||||
'react-hooks/refs': 'off',
|
||||
'react-hooks/incompatible-library': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: ['vendor', 'node_modules', 'public', 'bootstrap/ssr', 'tailwind.config.js'],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ export function RuleBuilder({ value, onChange, error }: RuleBuilderProps) {
|
|||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
{structure.groups.map((group, groupIndex) => (
|
||||
{structure.groups.map((group) => (
|
||||
<div key={group.id}>
|
||||
<Card className="gap-2 p-4">
|
||||
<div className="flex items-center justify-between">
|
||||
|
|
@ -145,8 +145,7 @@ export function RuleBuilder({ value, onChange, error }: RuleBuilderProps) {
|
|||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
{group.conditions.map(
|
||||
(condition, conditionIndex) => (
|
||||
{group.conditions.map((condition) => (
|
||||
<div key={condition.id}>
|
||||
<ConditionRow
|
||||
condition={condition}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useEncryptionKey } from '@/contexts/encryption-key-context';
|
||||
import { decrypt, importKey } from '@/lib/crypto';
|
||||
import { getStoredKey } from '@/lib/key-storage';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
|
||||
type Length = number | { min: number; max: number } | null;
|
||||
|
||||
|
|
@ -48,6 +48,14 @@ function generateMaskedText(targetLength: number): string {
|
|||
return result;
|
||||
}
|
||||
|
||||
function getInitialDisplayState(isKeySet: boolean): DisplayState {
|
||||
if (!isKeySet) {
|
||||
return 'encrypted';
|
||||
}
|
||||
const keyString = getStoredKey();
|
||||
return keyString ? 'loading' : 'encrypted';
|
||||
}
|
||||
|
||||
export function EncryptedText(props: EncryptedTextProps) {
|
||||
const { encryptedText, iv, className = '', length = null } = props;
|
||||
const { isKeySet } = useEncryptionKey();
|
||||
|
|
@ -57,49 +65,42 @@ export function EncryptedText(props: EncryptedTextProps) {
|
|||
);
|
||||
const maskedValue = useMemo(
|
||||
() => generateMaskedText(targetLength),
|
||||
[targetLength, encryptedText, iv],
|
||||
[targetLength],
|
||||
);
|
||||
const [cachedDecryption, setCachedDecryption] = useState<{
|
||||
encryptedText: string;
|
||||
iv: string;
|
||||
value: string;
|
||||
} | null>(null);
|
||||
const [displayState, setDisplayState] = useState<DisplayState>(() => {
|
||||
if (!isKeySet) {
|
||||
return 'encrypted';
|
||||
}
|
||||
|
||||
const keyString = getStoredKey();
|
||||
return keyString ? 'loading' : 'encrypted';
|
||||
});
|
||||
const [displayState, setDisplayState] = useState<DisplayState>(() => getInitialDisplayState(isKeySet));
|
||||
const prevIsKeySetRef = useRef(isKeySet);
|
||||
|
||||
useEffect(() => {
|
||||
const wasKeySet = prevIsKeySetRef.current;
|
||||
prevIsKeySetRef.current = isKeySet;
|
||||
|
||||
if (!isKeySet) {
|
||||
if (wasKeySet) {
|
||||
setCachedDecryption(null);
|
||||
setDisplayState('encrypted');
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
cachedDecryption &&
|
||||
cachedDecryption.encryptedText === encryptedText &&
|
||||
cachedDecryption.iv === iv
|
||||
) {
|
||||
setDisplayState((current) =>
|
||||
current === 'decrypted' ? current : 'decrypted',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const keyString = getStoredKey();
|
||||
if (!keyString) {
|
||||
if (wasKeySet !== isKeySet) {
|
||||
setCachedDecryption(null);
|
||||
setDisplayState('encrypted');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
if (!wasKeySet && isKeySet) {
|
||||
setDisplayState('loading');
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
|
||||
importKey(keyString)
|
||||
.then((key) => decrypt(encryptedText, key, iv))
|
||||
|
|
|
|||
|
|
@ -13,13 +13,22 @@ import {
|
|||
} from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { type Category, getCategoryColorClasses } from '@/types/category';
|
||||
import { Check, ChevronsUpDown, HelpCircle } from 'lucide-react';
|
||||
import { Check, ChevronsUpDown, HelpCircle, type LucideIcon } from 'lucide-react';
|
||||
import * as Icons from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { memo, useState } from 'react';
|
||||
|
||||
function resolveIconComponent(iconName?: string): Icons.LucideIcon {
|
||||
const icon = Icons[iconName as keyof typeof Icons];
|
||||
return icon as Icons.LucideIcon;
|
||||
const iconCache = new Map<string, LucideIcon>();
|
||||
|
||||
function getIconComponent(iconName?: string): LucideIcon | null {
|
||||
if (!iconName) return null;
|
||||
if (iconCache.has(iconName)) {
|
||||
return iconCache.get(iconName)!;
|
||||
}
|
||||
const icon = Icons[iconName as keyof typeof Icons] as LucideIcon | undefined;
|
||||
if (icon) {
|
||||
iconCache.set(iconName, icon);
|
||||
}
|
||||
return icon ?? null;
|
||||
}
|
||||
|
||||
interface CategoryComboboxProps {
|
||||
|
|
@ -144,9 +153,9 @@ export function CategoryCombobox({
|
|||
);
|
||||
}
|
||||
|
||||
function CategoryIcon({ category }: { category: Category }) {
|
||||
const CategoryIcon = memo(function CategoryIcon({ category }: { category: Category }) {
|
||||
const colorClasses = getCategoryColorClasses(category.color);
|
||||
const IconComponent = resolveIconComponent(category.icon);
|
||||
const iconName = category.icon;
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
@ -155,8 +164,14 @@ function CategoryIcon({ category }: { category: Category }) {
|
|||
colorClasses.bg,
|
||||
)}
|
||||
>
|
||||
<IconComponent className={cn('h-3 w-3', colorClasses.text)} />
|
||||
<DynamicIcon name={iconName} className={cn('h-3 w-3', colorClasses.text)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const DynamicIcon = memo(function DynamicIcon({ name, className }: { name?: string; className?: string }) {
|
||||
const Icon = getIconComponent(name);
|
||||
if (!Icon) return null;
|
||||
return <Icon className={className} />;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
DrawerTitle,
|
||||
} from '@/components/ui/drawer';
|
||||
import { useEncryptionKey } from '@/contexts/encryption-key-context';
|
||||
import { decrypt, importKey } from '@/lib/crypto';
|
||||
import { importKey } from '@/lib/crypto';
|
||||
import {
|
||||
autoDetectColumns,
|
||||
convertRowsToTransactions,
|
||||
|
|
@ -18,10 +18,7 @@ import {
|
|||
saveImportConfig,
|
||||
} from '@/lib/import-config-storage';
|
||||
import { getStoredKey } from '@/lib/key-storage';
|
||||
import {
|
||||
evaluateRules,
|
||||
evaluateRulesForNewTransaction,
|
||||
} from '@/lib/rule-engine';
|
||||
import { evaluateRulesForNewTransaction } from '@/lib/rule-engine';
|
||||
import { accountBalanceSyncService } from '@/services/account-balance-sync';
|
||||
import { accountSyncService } from '@/services/account-sync';
|
||||
import { automationRuleSyncService } from '@/services/automation-rule-sync';
|
||||
|
|
@ -34,7 +31,7 @@ import {
|
|||
type ImportState,
|
||||
} from '@/types/import';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Check, Loader2 } from 'lucide-react';
|
||||
import { Check } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { toast } from 'sonner';
|
||||
import { ImportStepAccount } from './import-step-account';
|
||||
|
|
@ -320,7 +317,7 @@ export function ImportTransactionsDrawer({
|
|||
return;
|
||||
}
|
||||
|
||||
const createdTransactions: any[] = [];
|
||||
const createdTransactions: unknown[] = [];
|
||||
const errors: ImportError[] = [];
|
||||
const keyString = getStoredKey();
|
||||
const key = keyString ? await importKey(keyString) : null;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
import { Button } from '@/components/ui/button';
|
||||
import { RefreshCw } from 'lucide-react';
|
||||
|
||||
interface DataTablePaginationProps {
|
||||
rowCountLabel?: string;
|
||||
displayedCount?: number;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ import { useRef } from 'react';
|
|||
import {
|
||||
ColumnDef,
|
||||
flexRender,
|
||||
Row,
|
||||
Table as TableType,
|
||||
} from '@tanstack/react-table';
|
||||
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||
import { useVirtualizer, VirtualItem, Virtualizer } from '@tanstack/react-virtual';
|
||||
|
||||
import {
|
||||
Table,
|
||||
|
|
@ -19,7 +20,7 @@ interface DataTableProps<TData, TValue> {
|
|||
table: TableType<TData>;
|
||||
columns: ColumnDef<TData, TValue>[];
|
||||
emptyMessage?: string;
|
||||
renderRow?: (row: any, virtualRow: any, rowVirtualizer: any) => React.ReactNode;
|
||||
renderRow?: (row: Row<TData>, virtualRow: VirtualItem, rowVirtualizer: Virtualizer<HTMLDivElement, Element>) => React.ReactNode;
|
||||
}
|
||||
|
||||
export function DataTable<TData, TValue>({
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export function useAppearance() {
|
|||
'appearance',
|
||||
) as Appearance | null;
|
||||
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||
|
||||
updateAppearance(savedAppearance || 'system');
|
||||
|
||||
return () =>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export interface PendingChange {
|
|||
id?: number;
|
||||
store: string;
|
||||
operation: 'create' | 'update' | 'delete';
|
||||
data: any;
|
||||
data: Record<string, unknown>;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,9 @@ export const OPERATOR_LABELS: Record<Operator, string> = {
|
|||
is_not_empty: 'is not empty',
|
||||
};
|
||||
|
||||
function buildConditionJsonLogic(condition: Condition): Record<string, any> {
|
||||
type JsonLogicRule = Record<string, unknown>;
|
||||
|
||||
function buildConditionJsonLogic(condition: Condition): JsonLogicRule {
|
||||
const { field, operator, value } = condition;
|
||||
|
||||
switch (operator) {
|
||||
|
|
@ -100,7 +102,7 @@ function buildConditionJsonLogic(condition: Condition): Record<string, any> {
|
|||
}
|
||||
}
|
||||
|
||||
function buildGroupJsonLogic(group: ConditionGroup): Record<string, any> {
|
||||
function buildGroupJsonLogic(group: ConditionGroup): JsonLogicRule {
|
||||
if (group.conditions.length === 0) {
|
||||
return {};
|
||||
}
|
||||
|
|
@ -113,7 +115,7 @@ function buildGroupJsonLogic(group: ConditionGroup): Record<string, any> {
|
|||
return { [group.operator]: conditions };
|
||||
}
|
||||
|
||||
export function buildJsonLogic(structure: RuleStructure): Record<string, any> {
|
||||
export function buildJsonLogic(structure: RuleStructure): JsonLogicRule {
|
||||
const validGroups = structure.groups.filter(
|
||||
(group) => group.conditions.length > 0,
|
||||
);
|
||||
|
|
@ -131,7 +133,7 @@ export function buildJsonLogic(structure: RuleStructure): Record<string, any> {
|
|||
}
|
||||
|
||||
function parseConditionFromJsonLogic(
|
||||
jsonLogic: Record<string, any>,
|
||||
jsonLogic: JsonLogicRule,
|
||||
): Condition | null {
|
||||
const id = crypto.randomUUID();
|
||||
|
||||
|
|
@ -211,7 +213,7 @@ function parseConditionFromJsonLogic(
|
|||
return null;
|
||||
}
|
||||
|
||||
export function parseJsonLogic(jsonLogic: Record<string, any>): RuleStructure {
|
||||
export function parseJsonLogic(jsonLogic: JsonLogicRule): RuleStructure {
|
||||
const defaultStructure: RuleStructure = {
|
||||
groups: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@ export interface IndexedDBRecord {
|
|||
user_id?: UUID | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
[key: string]: any;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface SyncOptions {
|
||||
storeName: StoreName;
|
||||
endpoint: string;
|
||||
transformFromServer?: (data: any) => any;
|
||||
transformToServer?: (data: any) => any;
|
||||
transformFromServer?: (data: Record<string, unknown>) => Record<string, unknown>;
|
||||
transformToServer?: (data: Record<string, unknown>) => Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface SyncResult {
|
||||
|
|
@ -99,7 +99,7 @@ export class SyncManager {
|
|||
private async syncFromServer(result: SyncResult): Promise<void> {
|
||||
const lastSync = await this.getLastSyncTime();
|
||||
|
||||
const params: any = {};
|
||||
const params: Record<string, string> = {};
|
||||
if (lastSync) {
|
||||
params.since = lastSync;
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ export class SyncManager {
|
|||
|
||||
const table = db[this.options.storeName];
|
||||
const localRecords = await table.toArray();
|
||||
const localMap = new Map(localRecords.map((r: any) => [r.id, r]));
|
||||
const localMap = new Map(localRecords.map((r) => [(r as IndexedDBRecord).id, r as IndexedDBRecord]));
|
||||
|
||||
for (const serverRecord of serverData) {
|
||||
const transformed = this.options.transformFromServer
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Head, router } from '@inertiajs/react';
|
||||
import axios from 'axios';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import InputError from '@/components/input-error';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
|
@ -27,6 +27,21 @@ import {
|
|||
import { storeKey } from '@/lib/key-storage';
|
||||
import { dashboard } from '@/routes';
|
||||
|
||||
function isCryptoAvailable(): boolean {
|
||||
if (typeof window === 'undefined') return true;
|
||||
return !!(window.crypto && window.crypto.subtle);
|
||||
}
|
||||
|
||||
function getInitialErrors(): { password?: string; confirmPassword?: string; general?: string } {
|
||||
if (typeof window === 'undefined') return {};
|
||||
if (!window.crypto || !window.crypto.subtle) {
|
||||
return {
|
||||
general: 'Web Crypto API is not available. Please ensure you are accessing this page via HTTPS or localhost.',
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
export default function SetupEncryption() {
|
||||
const { refreshKeyState } = useEncryptionKey();
|
||||
const [password, setPassword] = useState('');
|
||||
|
|
@ -35,22 +50,12 @@ export default function SetupEncryption() {
|
|||
'session' | 'persistent'
|
||||
>('session');
|
||||
const [processing, setProcessing] = useState(false);
|
||||
const [cryptoAvailable, setCryptoAvailable] = useState(true);
|
||||
const [cryptoAvailable] = useState(isCryptoAvailable);
|
||||
const [errors, setErrors] = useState<{
|
||||
password?: string;
|
||||
confirmPassword?: string;
|
||||
general?: string;
|
||||
}>({});
|
||||
|
||||
useEffect(() => {
|
||||
if (!window.crypto || !window.crypto.subtle) {
|
||||
setCryptoAvailable(false);
|
||||
setErrors({
|
||||
general:
|
||||
'Web Crypto API is not available. Please ensure you are accessing this page via HTTPS or localhost.',
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
}>(getInitialErrors);
|
||||
|
||||
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
||||
e.preventDefault();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Head } from '@inertiajs/react';
|
||||
import {
|
||||
Cell,
|
||||
ColumnDef,
|
||||
ColumnFiltersState,
|
||||
flexRender,
|
||||
|
|
@ -7,6 +8,7 @@ import {
|
|||
getFilteredRowModel,
|
||||
getPaginationRowModel,
|
||||
getSortedRowModel,
|
||||
Row,
|
||||
SortingState,
|
||||
useReactTable,
|
||||
VisibilityState,
|
||||
|
|
@ -109,7 +111,7 @@ function AccountActions({
|
|||
);
|
||||
}
|
||||
|
||||
function AccountRow({ row, onSuccess }: { row: any; onSuccess?: () => void }) {
|
||||
function AccountRow({ row, onSuccess }: { row: Row<Account>; onSuccess?: () => void }) {
|
||||
const account = row.original;
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
|
@ -127,7 +129,7 @@ function AccountRow({ row, onSuccess }: { row: any; onSuccess?: () => void }) {
|
|||
>
|
||||
{row
|
||||
.getVisibleCells()
|
||||
.map((cell: any) => (
|
||||
.map((cell: Cell<Account, unknown>) => (
|
||||
<TableCell
|
||||
key={cell.id}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import { Head } from '@inertiajs/react';
|
||||
import {
|
||||
Cell,
|
||||
ColumnDef,
|
||||
ColumnFiltersState,
|
||||
flexRender,
|
||||
getCoreRowModel,
|
||||
getFilteredRowModel,
|
||||
getSortedRowModel,
|
||||
Row,
|
||||
SortingState,
|
||||
useReactTable,
|
||||
VisibilityState,
|
||||
|
|
@ -101,7 +103,7 @@ function AutomationRuleActions({ rule }: { rule: AutomationRule }) {
|
|||
);
|
||||
}
|
||||
|
||||
function AutomationRuleRow({ row }: { row: any }) {
|
||||
function AutomationRuleRow({ row }: { row: Row<AutomationRule> }) {
|
||||
const rule = row.original;
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
|
@ -119,7 +121,7 @@ function AutomationRuleRow({ row }: { row: any }) {
|
|||
>
|
||||
{row
|
||||
.getVisibleCells()
|
||||
.map((cell: any) => (
|
||||
.map((cell: Cell<AutomationRule, unknown>) => (
|
||||
<TableCell
|
||||
key={cell.id}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import { Head } from '@inertiajs/react';
|
||||
import {
|
||||
Cell,
|
||||
ColumnDef,
|
||||
ColumnFiltersState,
|
||||
flexRender,
|
||||
getCoreRowModel,
|
||||
getFilteredRowModel,
|
||||
getSortedRowModel,
|
||||
Row,
|
||||
SortingState,
|
||||
useReactTable,
|
||||
VisibilityState,
|
||||
|
|
@ -101,7 +103,7 @@ function CategoryActions({ category }: { category: Category }) {
|
|||
);
|
||||
}
|
||||
|
||||
function CategoryRow({ row }: { row: any }) {
|
||||
function CategoryRow({ row }: { row: Row<Category> }) {
|
||||
const category = row.original;
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
|
@ -119,7 +121,7 @@ function CategoryRow({ row }: { row: any }) {
|
|||
>
|
||||
{row
|
||||
.getVisibleCells()
|
||||
.map((cell: any) => (
|
||||
.map((cell: Cell<Category, unknown>) => (
|
||||
<TableCell
|
||||
key={cell.id}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import { Head } from '@inertiajs/react';
|
||||
import {
|
||||
Cell,
|
||||
ColumnFiltersState,
|
||||
Row,
|
||||
SortingState,
|
||||
VisibilityState,
|
||||
flexRender,
|
||||
|
|
@ -9,6 +11,7 @@ import {
|
|||
getSortedRowModel,
|
||||
useReactTable,
|
||||
} from '@tanstack/react-table';
|
||||
import { VirtualItem, Virtualizer } from '@tanstack/react-virtual';
|
||||
import { isWithinInterval, parseISO } from 'date-fns';
|
||||
import { useLiveQuery } from 'dexie-react-hooks';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
|
|
@ -77,6 +80,64 @@ interface Props {
|
|||
|
||||
const COLUMN_VISIBILITY_KEY = 'transactions-column-visibility';
|
||||
|
||||
interface TransactionRowProps {
|
||||
row: Row<DecryptedTransaction>;
|
||||
virtualRow: VirtualItem;
|
||||
rowVirtualizer: Virtualizer<HTMLDivElement, Element>;
|
||||
onEdit: (transaction: DecryptedTransaction) => void;
|
||||
onReEvaluateRules: (transaction: DecryptedTransaction) => void;
|
||||
onDelete: (transaction: DecryptedTransaction) => void;
|
||||
}
|
||||
|
||||
function TransactionRowComponent({
|
||||
row,
|
||||
virtualRow,
|
||||
rowVirtualizer,
|
||||
onEdit,
|
||||
onReEvaluateRules,
|
||||
onDelete,
|
||||
}: TransactionRowProps) {
|
||||
const transaction = row.original;
|
||||
const [contextMenuOpen, setContextMenuOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<ContextMenu key={row.id} onOpenChange={setContextMenuOpen}>
|
||||
<ContextMenuTrigger asChild>
|
||||
{ }
|
||||
<TableRow
|
||||
ref={rowVirtualizer.measureElement}
|
||||
data-state={(row.getIsSelected() || contextMenuOpen) && 'selected'}
|
||||
data-index={virtualRow.index}
|
||||
>
|
||||
{row.getVisibleCells().map((cell: Cell<DecryptedTransaction, unknown>) => (
|
||||
<TableCell key={cell.id}>
|
||||
{flexRender(
|
||||
cell.column.columnDef.cell,
|
||||
cell.getContext(),
|
||||
)}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent>
|
||||
<ContextMenuLabel>Actions</ContextMenuLabel>
|
||||
<ContextMenuItem onClick={() => onEdit(transaction)}>
|
||||
Edit
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem onClick={() => onReEvaluateRules(transaction)}>
|
||||
Re-evaluate rules
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem
|
||||
onClick={() => onDelete(transaction)}
|
||||
variant="destructive"
|
||||
>
|
||||
Delete
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
);
|
||||
}
|
||||
|
||||
function getInitialColumnVisibility(): VisibilityState {
|
||||
try {
|
||||
const stored = localStorage.getItem(COLUMN_VISIBILITY_KEY);
|
||||
|
|
@ -950,66 +1011,21 @@ export default function Transactions({ categories, accounts, banks }: Props) {
|
|||
setRowSelection({});
|
||||
}
|
||||
|
||||
const TransactionRow = useCallback(
|
||||
({ row, virtualRow, rowVirtualizer }: { row: any; virtualRow: any; rowVirtualizer: any }) => {
|
||||
const transaction = row.original;
|
||||
const [contextMenuOpen, setContextMenuOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<ContextMenu key={row.id} onOpenChange={setContextMenuOpen}>
|
||||
<ContextMenuTrigger asChild>
|
||||
<TableRow
|
||||
ref={rowVirtualizer.measureElement}
|
||||
data-state={(row.getIsSelected() || contextMenuOpen) && 'selected'}
|
||||
data-index={virtualRow.index}
|
||||
>
|
||||
{row.getVisibleCells().map((cell: any) => (
|
||||
<TableCell key={cell.id}>
|
||||
{flexRender(
|
||||
cell.column.columnDef.cell,
|
||||
cell.getContext(),
|
||||
)}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent>
|
||||
<ContextMenuLabel>Actions</ContextMenuLabel>
|
||||
<ContextMenuItem
|
||||
onClick={() => setEditTransaction(transaction)}
|
||||
>
|
||||
Edit
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem
|
||||
onClick={() => handleReEvaluateRules(transaction)}
|
||||
>
|
||||
Re-evaluate rules
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem
|
||||
onClick={() => setDeleteTransaction(transaction)}
|
||||
variant="destructive"
|
||||
>
|
||||
Delete
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
);
|
||||
},
|
||||
[handleReEvaluateRules],
|
||||
);
|
||||
|
||||
const renderTransactionRow = useCallback(
|
||||
(row: any, virtualRow: any, rowVirtualizer: any) => {
|
||||
(row: Row<DecryptedTransaction>, virtualRow: VirtualItem, rowVirtualizer: Virtualizer<HTMLDivElement, Element>) => {
|
||||
return (
|
||||
<TransactionRow
|
||||
<TransactionRowComponent
|
||||
key={row.id}
|
||||
row={row}
|
||||
virtualRow={virtualRow}
|
||||
rowVirtualizer={rowVirtualizer}
|
||||
onEdit={setEditTransaction}
|
||||
onReEvaluateRules={handleReEvaluateRules}
|
||||
onDelete={setDeleteTransaction}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[TransactionRow],
|
||||
[handleReEvaluateRules],
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { Form, Head, Link, usePage } from '@inertiajs/react';
|
|||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import InputError from '@/components/input-error';
|
||||
import { Avatar, AvatarImage } from '@/components/ui/avatar';
|
||||
import {
|
||||
LockIcon,
|
||||
ShieldCheckIcon,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class AccountSyncService {
|
|||
}
|
||||
|
||||
async create(data: Omit<Account, 'id'>): Promise<Account> {
|
||||
return await this.syncManager.createLocal<Account>(data as any);
|
||||
return await this.syncManager.createLocal<Account>(data as Omit<Account, 'id' | 'created_at' | 'updated_at'>);
|
||||
}
|
||||
|
||||
async update(id: UUID, data: Partial<Account>): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class CategorySyncService {
|
|||
}
|
||||
|
||||
async create(data: Omit<Category, 'id'>): Promise<Category> {
|
||||
return await this.syncManager.createLocal<Category>(data as any);
|
||||
return await this.syncManager.createLocal<Category>(data as Omit<Category, 'id' | 'created_at' | 'updated_at'>);
|
||||
}
|
||||
|
||||
async update(id: UUID, data: Partial<Category>): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export interface AutomationRule {
|
|||
user_id: UUID;
|
||||
title: string;
|
||||
priority: number;
|
||||
rules_json: Record<string, any>;
|
||||
rules_json: Record<string, unknown>;
|
||||
action_category_id: UUID | null;
|
||||
action_note: string | null;
|
||||
action_note_iv: string | null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue