@@ -110,14 +110,57 @@ permalink: /favoriteLocations/
110110
111111<!-- Main Content (hidden until access verified) -->
112112<div id =" main-content " style =" display : none ;" >
113+ <!-- Usage Display Header -->
114+ <div id =" usage-header " class =" usage-header " style =" display : none ;" >
115+ <div class="usage-info">
116+ <span id="usage-display" class="usage-text"></span>
117+ <a href="{{site.baseurl}}/pricing" id="upgrade-link" class="upgrade-link" style="display: none;">Upgrade for more</a>
118+ </div>
119+ </div >
113120 <div id =" locations-grid " ></div >
114121 <button id =" new-location-button " class =" new-location-button " >New</button >
115122</div >
116123
124+ <style >
125+ .usage-header {
126+ padding : 12px 20px ;
127+ margin-bottom : 20px ;
128+ background : linear-gradient (135deg , #1e293b 0% , #0f172a 100% );
129+ border-radius : 12px ;
130+ border : 1px solid #334155 ;
131+ }
132+ .usage-info {
133+ display : flex ;
134+ justify-content : space-between ;
135+ align-items : center ;
136+ }
137+ .usage-text {
138+ font-size : 14px ;
139+ font-weight : 600 ;
140+ }
141+ .usage-text.text-green-400 { color : #4ade80 ; }
142+ .usage-text.text-yellow-400 { color : #facc15 ; }
143+ .usage-text.text-red-400 { color : #f87171 ; }
144+ .upgrade-link {
145+ font-size : 13px ;
146+ color : #22c55e ;
147+ text-decoration : none ;
148+ font-weight : 600 ;
149+ transition : all 0.2s ;
150+ }
151+ .upgrade-link :hover {
152+ color : #4ade80 ;
153+ text-decoration : underline ;
154+ }
155+ </style >
156+
117157<!-- Subscription Access Check (runs first) -->
118158<script type =" module " >
119159 import { pythonURI , fetchOptions } from ' {{site.baseurl}}/assets/js/api/config.js' ;
120160
161+ let currentTier = ' free' ;
162+ let locationLimit = 0 ;
163+
121164 async function checkAccess () {
122165 try {
123166 // Check if user is logged in
@@ -131,6 +174,8 @@ permalink: /favoriteLocations/
131174
132175 // Admins have full access
133176 if (user .role === ' Admin' ) {
177+ currentTier = ' admin' ;
178+ locationLimit = Infinity ;
134179 showContent ();
135180 return ;
136181 }
@@ -139,7 +184,14 @@ permalink: /favoriteLocations/
139184 const subResponse = await fetch (` ${ pythonURI} /api/subscription` , fetchOptions);
140185 if (subResponse .ok ) {
141186 const subscription = await subResponse .json ();
142- if (subscription .tier === ' plus' || subscription .tier === ' pro' ) {
187+ currentTier = subscription .tier || ' free' ;
188+
189+ if (currentTier === ' plus' ) {
190+ locationLimit = 10 ;
191+ showContent ();
192+ return ;
193+ } else if (currentTier === ' pro' ) {
194+ locationLimit = Infinity ;
143195 showContent ();
144196 return ;
145197 }
@@ -158,8 +210,19 @@ permalink: /favoriteLocations/
158210 document .getElementById (' access-loading' ).style .display = ' none' ;
159211 document .getElementById (' access-denied' ).style .display = ' none' ;
160212 document .getElementById (' main-content' ).style .display = ' block' ;
161- // Load the main functionality
162- import (' {{site.baseurl}}/navigation/favoriteLocations/favoriteLocations.js' );
213+
214+ // Show usage header
215+ document .getElementById (' usage-header' ).style .display = ' block' ;
216+
217+ // Load the main functionality and then update usage display
218+ import (' {{site.baseurl}}/navigation/favoriteLocations/favoriteLocations.js' ).then (() => {
219+ // Wait a bit for locations to load, then update display
220+ setTimeout (updateUsageDisplay, 500 );
221+ });
222+
223+ // Store tier info globally for the usage display
224+ window .favoriteLocationsTier = currentTier;
225+ window .favoriteLocationsLimit = locationLimit;
163226 }
164227
165228 function showAccessDenied () {
@@ -168,5 +231,35 @@ permalink: /favoriteLocations/
168231 document .getElementById (' main-content' ).style .display = ' none' ;
169232 }
170233
234+ // Update the usage display based on current locations count
235+ window .updateUsageDisplay = function () {
236+ const grid = document .getElementById (' locations-grid' );
237+ const usageDisplay = document .getElementById (' usage-display' );
238+ const upgradeLink = document .getElementById (' upgrade-link' );
239+ const tier = window .favoriteLocationsTier ;
240+ const limit = window .favoriteLocationsLimit ;
241+
242+ // Count current locations
243+ const locationCount = grid ? grid .querySelectorAll (' .location-square' ).length : 0 ;
244+
245+ if (tier === ' admin' || tier === ' pro' || limit === Infinity ) {
246+ usageDisplay .textContent = ` 📍 ${ locationCount} locations saved • Unlimited` ;
247+ usageDisplay .className = ' usage-text text-green-400' ;
248+ upgradeLink .style .display = ' none' ;
249+ } else if (tier === ' plus' ) {
250+ const remaining = limit - locationCount;
251+ const colorClass = remaining <= 2 ? ' text-red-400' : remaining <= 5 ? ' text-yellow-400' : ' text-green-400' ;
252+ usageDisplay .textContent = ` 📍 ${ locationCount} /${ limit} locations saved` ;
253+ usageDisplay .className = ` usage-text ${ colorClass} ` ;
254+
255+ if (remaining <= 3 ) {
256+ upgradeLink .style .display = ' inline' ;
257+ upgradeLink .textContent = remaining <= 0 ? ' Upgrade for unlimited' : ' Upgrade for unlimited' ;
258+ } else {
259+ upgradeLink .style .display = ' none' ;
260+ }
261+ }
262+ };
263+
171264 checkAccess ();
172265</script >
0 commit comments