File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
assets/js/components/ChargingPlans Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,12 @@ export default defineComponent({
144144 base .setSeconds (0 , 0 );
145145 base .setMinutes (base .getMinutes () - (base .getMinutes () % 15 ));
146146
147- return Array .from ({ length: 48 * 4 }, (_ , i ) => {
147+ const endTime = this .getMaxEndTime ([... rates , ... plan ]);
148+ const interval = endTime
149+ ? Math .ceil ((endTime - base .getTime ()) / 1000 / 60 / 15 )
150+ : 48 * 4 ; // Default to 48 hours if no end time
151+
152+ return Array .from ({ length: interval }, (_ , i ) => {
148153 const start = new Date (base .getTime () + quarterHour * i );
149154 const end = new Date (start .getTime () + quarterHour );
150155 const charging = !! this .findSlotInRange (start , end , plan );
@@ -197,6 +202,12 @@ export default defineComponent({
197202 slotHovered(index : number ): void {
198203 this .activeIndex = index ;
199204 },
205+ getMaxEndTime(list : Rate []): Date | null {
206+ if (! list .length ) {
207+ return null ;
208+ }
209+ return Math .max (... list .map ((s ) => s .end .getTime ()));
210+ },
200211 },
201212});
202213 </script >
You can’t perform that action at this time.
0 commit comments