|
2 | 2 | import Bike from '$lib/components/Bike.svelte'; |
3 | 3 | import BikeSkeleton from '$lib/components/BikeSkeleton.svelte'; |
4 | 4 | import { getStationInfo } from '$lib/gira-api/api'; |
| 5 | + import { IdToSerial } from '$lib/gira-api/bikeMapping'; |
5 | 6 | import { currentPos } from '$lib/location'; |
6 | 7 | import { selectedStation, stations } from '$lib/map.svelte'; |
7 | 8 | import { t } from '$lib/translations'; |
|
49 | 50 | return undefined; |
50 | 51 | }); |
51 | 52 |
|
52 | | - let bikeInfo:({type:'electric'|'classic', id:string, battery:number|null, dock:string, serial:string}|{id:string})[] = $state([]); |
| 53 | + let bikeInfo:({type:'electric'|'classic', id:string, battery:number|null, dock:string, serial:string}|{id:string, serial: string})[] = $state([]); |
53 | 54 | function isRealBike(bike: typeof bikeInfo[number]): bike is {type:'electric'|'classic', id:string, battery:number|null, dock:string, serial:string} { |
54 | 55 | return 'type' in bike === true; |
55 | 56 | } |
|
182 | 183 | const makeExtraBikeFunction = (dismiss: () => void) => { |
183 | 184 | return async () => { |
184 | 185 | await tick(); |
185 | | - if (bikeIdNumber === null || bikeIdNumber > 10000 || bikeIdNumber < 0) { |
| 186 | + if (bikeId === null) { |
186 | 187 | errorMessages.add( |
187 | 188 | $t('bike_unlock_invalid_id_error'), |
188 | 189 | 2000, |
189 | 190 | ); |
190 | 191 | return; |
191 | 192 | } |
192 | | - if (bikeId) bikeInfo.push({ id: bikeId }); |
| 193 | + let serial = IdToSerial.get(bikeId); |
| 194 | + if (serial) bikeInfo.push({ id: bikeId, serial: serial }); |
193 | 195 | else { |
194 | 196 | errorMessages.add( |
195 | 197 | $t('bike_unlock_no_serial_error'), |
196 | 198 | 3000, |
197 | 199 | ); |
| 200 | + return; |
198 | 201 | } |
199 | 202 | dismiss(); |
200 | 203 | await tick(); |
|
282 | 285 | {#if isRealBike(bike)} |
283 | 286 | <Bike type={bike.type} id={bike.id} battery={bike.battery} dock={bike.dock} serial={bike.serial} disabled={isScrolling} station={station} /> |
284 | 287 | {:else} |
285 | | - <Bike type={null} id={bike.id} battery={null} dock={null} serial={null} disabled={isScrolling} station={station} /> |
| 288 | + <Bike type={null} id={bike.id} battery={null} dock={null} serial={bike.serial} disabled={isScrolling} station={station} /> |
286 | 289 | {/if} |
287 | 290 |
|
288 | 291 | {/each} |
|
0 commit comments