Skip to content

Commit 9020daf

Browse files
committed
Update AnalyticsDashboardPage.tsx.diff
1 parent a0de7e9 commit 9020daf

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

opensaas-sh/app_diff/src/admin/dashboards/analytics/AnalyticsDashboardPage.tsx.diff

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,28 @@
77
import { useQuery, getDailyStats } from 'wasp/client/operations';
88
import TotalSignupsCard from './TotalSignupsCard';
99
import TotalPageViewsCard from './TotalPageViewsCard';
10-
@@ -10,12 +12,54 @@
11-
import { useRedirectHomeUnlessUserIsAdmin } from '../../useRedirectHomeUnlessUserIsAdmin';
10+
@@ -11,16 +13,58 @@
11+
import { cn } from '../../../client/cn';
1212

1313
const Dashboard = ({ user }: { user: AuthUser }) => {
1414
+ const [isDemoInfoVisible, setIsDemoInfoVisible] = useState(false);
1515
useRedirectHomeUnlessUserIsAdmin({ user });
1616

1717
const { data: stats, isLoading, error } = useQuery(getDailyStats);
1818

19+
+ const didUserCloseDemoInfo = localStorage.getItem('didUserCloseDemoInfo') === 'true';
20+
+
1921
+ useEffect(() => {
20-
+ try {
21-
+ if (localStorage.getItem('isStripeDemoInfoVisible') === 'false') {
22-
+ // do nothing
23-
+ } else {
24-
+ setIsDemoInfoVisible(true);
25-
+ }
26-
+ } catch (error) {
27-
+ console.error(error);
22+
+ if (didUserCloseDemoInfo || !stats) {
23+
+ setIsDemoInfoVisible(false);
24+
+ } else if (!didUserCloseDemoInfo && stats) {
25+
+ setIsDemoInfoVisible(true);
2826
+ }
29-
+ }, []);
27+
+ }, [stats]);
3028
+
3129
+ const handleDemoInfoClose = () => {
3230
+ try {
33-
+ localStorage.setItem('isStripeDemoInfoVisible', 'false');
31+
+ localStorage.setItem('didUserCloseDemoInfo', 'true');
3432
+ setIsDemoInfoVisible(false);
3533
+ } catch (error) {
3634
+ console.error(error);
@@ -60,9 +58,18 @@
6058
+ </div>
6159
+ )}
6260
<div className='relative'>
63-
<div className={`${!stats ? 'opacity-25' : ''}`}>
61+
- <div className={cn({
62+
- 'opacity-25': !stats,
63+
- })}>
64+
+ <div
65+
+ className={cn({
66+
+ 'opacity-25': !stats,
67+
+ })}
68+
+ >
6469
<div className='grid grid-cols-1 gap-4 md:grid-cols-2 md:gap-6 xl:grid-cols-4 2xl:gap-7.5'>
65-
@@ -36,7 +80,7 @@
70+
<TotalPageViewsCard
71+
totalPageViews={stats?.dailyStats.totalViews}
72+
@@ -39,7 +83,7 @@
6673
<RevenueAndProfitChart weeklyStats={stats?.weeklyStats} isLoading={isLoading} />
6774

6875
<div className='col-span-12 xl:col-span-8'>
@@ -71,3 +78,14 @@
7178
</div>
7279
</div>
7380
</div>
81+
@@ -47,9 +91,7 @@
82+
{!stats && (
83+
<div className='absolute inset-0 flex items-start justify-center bg-white/50 dark:bg-boxdark-2/50'>
84+
<div className='rounded-lg bg-white p-8 shadow-lg dark:bg-boxdark'>
85+
- <p className='text-2xl font-bold text-boxdark dark:text-white'>
86+
- No daily stats generated yet
87+
- </p>
88+
+ <p className='text-2xl font-bold text-boxdark dark:text-white'>No daily stats generated yet</p>
89+
<p className='mt-2 text-sm text-bodydark2'>
90+
Stats will appear here once the daily stats job has run
91+
</p>

0 commit comments

Comments
 (0)