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 [data, setData] = useState<User[]>([]);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const [loading, setLoading] = useState(false);
|
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);
|
const refreshTrigger = useUsersStore((state) => state.refreshTrigger);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -16,7 +16,9 @@ export function CreditTransactionsPageClient() {
|
|||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
const [data, setData] = useState<CreditTransaction[]>([]);
|
const [data, setData] = useState<CreditTransaction[]>([]);
|
||||||
const [total, setTotal] = useState(0);
|
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 [loading, setLoading] = useState(false);
|
||||||
const { refreshTrigger } = useTransactionStore();
|
const { refreshTrigger } = useTransactionStore();
|
||||||
|
|
||||||
@ -40,7 +42,10 @@ export function CreditTransactionsPageClient() {
|
|||||||
setTotal(0);
|
setTotal(0);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('CreditTransactions, fetch credit transactions error:', error);
|
console.error(
|
||||||
|
'CreditTransactions, fetch credit transactions error:',
|
||||||
|
error
|
||||||
|
);
|
||||||
toast.error(t('error'));
|
toast.error(t('error'));
|
||||||
setData([]);
|
setData([]);
|
||||||
setTotal(0);
|
setTotal(0);
|
||||||
|
@ -63,7 +63,7 @@ import { Badge } from '../../ui/badge';
|
|||||||
import { Label } from '../../ui/label';
|
import { Label } from '../../ui/label';
|
||||||
|
|
||||||
// Define the credit transaction interface
|
// Define the credit transaction interface
|
||||||
interface CreditTransaction {
|
export interface CreditTransaction {
|
||||||
id: string;
|
id: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
type: string;
|
type: string;
|
||||||
@ -265,7 +265,7 @@ export function CreditTransactionsTable({
|
|||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2 pl-3">
|
<div className="flex items-center gap-2 pl-3">
|
||||||
{transaction.remainingAmount !== null ? (
|
{transaction.remainingAmount !== null ? (
|
||||||
<span className="font-medium text-gray-600">
|
<span className="font-medium">
|
||||||
{transaction.remainingAmount.toLocaleString()}
|
{transaction.remainingAmount.toLocaleString()}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
Reference in New Issue
Block a user