Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Pull Request

## Related Issue
<!-- Please link to the issue this PR addresses, e.g. #123 -->

## Description of Changes
<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. -->

## Type of Change
<!-- Please delete options that are not relevant. -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] UI/UX Improvement (Visual or interaction changes)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Refactor (code restructuring without changing external behavior)
- [ ] Documentation update

## Checklist
- [ ] Component usage checked
- [ ] Responsive design verified
- [ ] Unit tests added/updated
- [ ] Code builds successfully
- [ ] Linter checks pass

## Special Notes
<!-- Any other information that the reviewer should know about. -->
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Web CI

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
- 'feature/*'

jobs:
check-web:
name: Check Web Code
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run Linter
run: npm run lint

- name: Build
run: npm run build

- name: Run Tests
run: npm run test
3 changes: 1 addition & 2 deletions src/components/auth/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useGlobal } from '@/context/GlobalContext';
import { useLogin } from '@/lib/hooks';
import { useTranslation, Trans } from 'react-i18next';
import { useTranslation } from 'react-i18next';
import { Turnstile } from '@marsidev/react-turnstile';
import {
Wallet,
CheckCircle2,
Sparkles,
Mail,
Lock,
MessageCircle,
Expand Down
10 changes: 5 additions & 5 deletions src/components/features/Accounts.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React, { useState, useMemo } from 'react';
import { useAllAccountsSuspense, AccountType, Account } from '@/lib/hooks';
import { useAllAccountsSuspense, Account } from '@/lib/hooks';
import { useTranslation } from 'react-i18next';
import { ACCOUNT_TYPES, EXCHANGE_RATES } from '@/lib/data';
import {
Expand All @@ -26,14 +26,14 @@ const Accounts = () => {
const [activeTab, setActiveTab] = useState('ALL');
const [page, setPage] = useState(1);
const [searchQuery, setSearchQuery] = useState('');
const [editAccount, setEditAccount] = useState<any>(null);
const [editAccount, setEditAccount] = useState<Account | null>(null);
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
const itemsPerPage = 10;

const formatCurrency = (amount: number, currency = 'CNY') => {
try {
return new Intl.NumberFormat('zh-CN', { style: 'currency', currency }).format(amount);
} catch (e) {
} catch {
return `${currency} ${amount.toFixed(2)}`;
}
};
Expand Down Expand Up @@ -73,7 +73,7 @@ const Accounts = () => {
{ id: 'EXPENSE', label: t('common:expense') }
];

const AccountRow = ({ account, isChild = false, groupBalance, hasChildren = false }: { account: any, isChild?: boolean, groupBalance?: number, hasChildren?: boolean }) => {
const AccountRow = ({ account, isChild = false, groupBalance, hasChildren = false }: { account: Account, isChild?: boolean, groupBalance?: number, hasChildren?: boolean }) => {
const TypeIcon = ACCOUNT_TYPES[account.type].icon;
const typeMeta = ACCOUNT_TYPES[account.type];

Expand Down Expand Up @@ -141,7 +141,7 @@ const Accounts = () => {
);
};

const renderAccountCard = (parentAccount: any) => {
const renderAccountCard = (parentAccount: Account) => {
const children = accounts.filter(a => a.parentId === parentAccount.id);
const groupBalance = children.reduce((sum, child) => {
const rate = EXCHANGE_RATES[child.currency] || 1;
Expand Down
10 changes: 4 additions & 6 deletions src/components/features/AddAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from '@/components/ui/select';
import { Checkbox } from '@/components/ui/checkbox';
import { Plus, Trash2, CornerDownRight, Crown } from 'lucide-react';
import { Separator } from '@/components/ui/separator';
import { toast } from "sonner";
import {
Tooltip,
Expand Down Expand Up @@ -54,7 +53,7 @@ const AddAccountModal = ({ isOpen, onClose }: AddAccountModalProps) => {
const [balance, setBalance] = useState('0');

// Group account state
const [children, setChildren] = useState([
const [children, setChildren] = useState(() => [
{ id: Date.now().toString(), name: '', currency: 'CNY', balance: '0', isDefault: true }
]);

Expand Down Expand Up @@ -91,7 +90,7 @@ const AddAccountModal = ({ isOpen, onClose }: AddAccountModalProps) => {
}
};

const handleChildChange = (id: string, field: string, value: any) => {
const handleChildChange = (id: string, field: string, value: string) => {
setChildren(children.map(c => {
if (c.id === id) {
return { ...c, [field]: value };
Expand Down Expand Up @@ -167,13 +166,12 @@ const AddAccountModal = ({ isOpen, onClose }: AddAccountModalProps) => {
if (!saveAndContinue) {
onClose();
}
} catch (error) {
} catch {
// Error is already handled by the hook with toast
}
};

const isPro = user.plan === 'PRO';
const canBeGroup = isPro && (type === AccountType.ASSET || type === AccountType.LIABILITY);
const isPending = createAccount.isPending;

return (
Expand Down Expand Up @@ -311,7 +309,7 @@ const AddAccountModal = ({ isOpen, onClose }: AddAccountModalProps) => {
</div>

<div className="space-y-3">
{children.map((child, index) => (
{children.map((child) => (
<div key={child.id} className="flex gap-3 items-start animate-in slide-in-from-left-2">
<div className="pt-3 text-[var(--text-muted)]"><CornerDownRight size={16} /></div>
<div className="grid grid-cols-12 gap-2 flex-1">
Expand Down
2 changes: 1 addition & 1 deletion src/components/features/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Dashboard = () => {
try {
const locale = currency === 'CNY' ? 'zh-CN' : 'en-US';
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(amount);
} catch (e) {
} catch {
return `${currency} ${amount.toFixed(2)}`;
}
};
Expand Down
Loading