This commit is contained in:
@@ -17,9 +17,9 @@ export const Dashboard: React.FC = () => {
|
||||
searchCounters(query);
|
||||
};
|
||||
|
||||
const totalCounters = counters.length;
|
||||
const totalValue = counters.reduce((sum, counter) => sum + counter.total_value, 0);
|
||||
const todayValue = counters.reduce((sum, counter) => sum + counter.today_value, 0);
|
||||
const totalCounters = counters?.length || 0;
|
||||
const totalValue = counters?.reduce((sum, counter) => sum + counter.total_value, 0) || 0;
|
||||
const todayValue = counters?.reduce((sum, counter) => sum + counter.today_value, 0) || 0;
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
@@ -109,7 +109,7 @@ export const Dashboard: React.FC = () => {
|
||||
<div className="flex justify-center items-center py-12">
|
||||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"></div>
|
||||
</div>
|
||||
) : counters.length === 0 ? (
|
||||
) : (counters?.length || 0) === 0 ? (
|
||||
<div className="text-center py-12">
|
||||
<TrendingUp className="mx-auto h-12 w-12 text-gray-400" />
|
||||
<h3 className="mt-2 text-sm font-medium text-gray-900">No counters</h3>
|
||||
@@ -128,7 +128,7 @@ export const Dashboard: React.FC = () => {
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{counters.map((counter) => (
|
||||
{counters?.map((counter) => (
|
||||
<CounterCard key={counter.id} counter={counter} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user