refactor: initialize sorting state with default value in UsersPage and CreditTransactionsPage components
This commit is contained in:
parent
2aeb027e2f
commit
b75e9eb282
@ -17,7 +17,9 @@ export function UsersPageClient() {
|
||||
const [data, setData] = useState<User[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [sorting, setSorting] = useState<SortingState>([]);
|
||||
const [sorting, setSorting] = useState<SortingState>([
|
||||
{ id: 'createdAt', desc: true },
|
||||
]);
|
||||
const refreshTrigger = useUsersStore((state) => state.refreshTrigger);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -16,7 +16,9 @@ export function CreditTransactionsPageClient() {
|
||||
const [search, setSearch] = useState('');
|
||||
const [data, setData] = useState<CreditTransaction[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [sorting, setSorting] = useState<SortingState>([]);
|
||||
const [sorting, setSorting] = useState<SortingState>([
|
||||
{ id: 'createdAt', desc: true },
|
||||
]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { refreshTrigger } = useTransactionStore();
|
||||
|
||||
@ -40,7 +42,10 @@ export function CreditTransactionsPageClient() {
|
||||
setTotal(0);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('CreditTransactions, fetch credit transactions error:', error);
|
||||
console.error(
|
||||
'CreditTransactions, fetch credit transactions error:',
|
||||
error
|
||||
);
|
||||
toast.error(t('error'));
|
||||
setData([]);
|
||||
setTotal(0);
|
||||
|
@ -63,7 +63,7 @@ import { Badge } from '../../ui/badge';
|
||||
import { Label } from '../../ui/label';
|
||||
|
||||
// Define the credit transaction interface
|
||||
interface CreditTransaction {
|
||||
export interface CreditTransaction {
|
||||
id: string;
|
||||
userId: string;
|
||||
type: string;
|
||||
@ -265,7 +265,7 @@ export function CreditTransactionsTable({
|
||||
return (
|
||||
<div className="flex items-center gap-2 pl-3">
|
||||
{transaction.remainingAmount !== null ? (
|
||||
<span className="font-medium text-gray-600">
|
||||
<span className="font-medium">
|
||||
{transaction.remainingAmount.toLocaleString()}
|
||||
</span>
|
||||
) : (
|
||||
|
Loading…
Reference in New Issue
Block a user