@movvjs/svelte-schedule-view 0.2.4 → 0.2.6-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.svelte-kit/__package__/i18n/locales/en.json +3 -1
  2. package/.svelte-kit/__package__/i18n/locales/ko.json +3 -1
  3. package/.svelte-kit/__package__/i18n/locales/vi.json +3 -1
  4. package/.svelte-kit/__package__/i18n/locales/zh-cn.json +3 -1
  5. package/.svelte-kit/__package__/i18n/locales/zh-tw.json +3 -1
  6. package/.svelte-kit/__package__/schedule-view/BookingInfo.svelte +49 -14
  7. package/.svelte-kit/__package__/schedule-view/PlaceSearch.svelte +21 -2
  8. package/.svelte-kit/__package__/schedule-view/api/common/index.d.ts +5 -1
  9. package/.svelte-kit/__package__/schedule-view/api/common/index.js +17 -3
  10. package/.svelte-kit/__package__/schedule-view/assets/scss/indie_booking.scss +58 -1
  11. package/.svelte-kit/__package__/schedule-view/components/flight-search/FlightSearch.svelte +193 -120
  12. package/.svelte-kit/__package__/schedule-view/components/flight-search/FlightSearch.svelte.d.ts +10 -2
  13. package/.svelte-kit/__package__/schedule-view/stores/booking.d.ts +2 -0
  14. package/.svelte-kit/__package__/schedule-view/stores/booking.js +2 -0
  15. package/.svelte-kit/__package__/schedule-view/types/flight.d.ts +1 -1
  16. package/.svelte-kit/ambient.d.ts +4 -0
  17. package/.svelte-kit/generated/server/internal.js +1 -1
  18. package/dist/i18n/locales/en.json +3 -1
  19. package/dist/i18n/locales/ko.json +3 -1
  20. package/dist/i18n/locales/vi.json +3 -1
  21. package/dist/i18n/locales/zh-cn.json +3 -1
  22. package/dist/i18n/locales/zh-tw.json +3 -1
  23. package/dist/schedule-view/BookingInfo.svelte +49 -14
  24. package/dist/schedule-view/PlaceSearch.svelte +21 -2
  25. package/dist/schedule-view/api/common/index.d.ts +5 -1
  26. package/dist/schedule-view/api/common/index.js +17 -3
  27. package/dist/schedule-view/assets/scss/indie_booking.scss +58 -1
  28. package/dist/schedule-view/components/flight-search/FlightSearch.svelte +193 -120
  29. package/dist/schedule-view/components/flight-search/FlightSearch.svelte.d.ts +10 -2
  30. package/dist/schedule-view/stores/booking.d.ts +2 -0
  31. package/dist/schedule-view/stores/booking.js +2 -0
  32. package/dist/schedule-view/types/flight.d.ts +1 -1
  33. package/package.json +3 -1
  34. package/src/lib/i18n/locales/en.json +3 -1
  35. package/src/lib/i18n/locales/ko.json +3 -1
  36. package/src/lib/i18n/locales/vi.json +3 -1
  37. package/src/lib/i18n/locales/zh-cn.json +3 -1
  38. package/src/lib/i18n/locales/zh-tw.json +3 -1
  39. package/src/lib/schedule-view/BookingInfo.svelte +51 -15
  40. package/src/lib/schedule-view/PlaceSearch.svelte +24 -1
  41. package/src/lib/schedule-view/api/common/index.ts +21 -3
  42. package/src/lib/schedule-view/assets/scss/indie_booking.scss +58 -1
  43. package/src/lib/schedule-view/components/flight-search/FlightSearch.svelte +208 -126
  44. package/src/lib/schedule-view/stores/booking.ts +6 -0
  45. package/src/lib/schedule-view/types/flight.ts +1 -1
  46. package/yarn.lock +334 -6
@@ -8,14 +8,14 @@
8
8
  import { dayjs } from '$lib/dayjs'
9
9
 
10
10
  import type { Flight, FlightAuto, FlightManual } from '$scheduleView/types'
11
- import { BookingAPI } from '$scheduleView/api'
11
+ import { BookingAPI, CommonAPI } from '$scheduleView/api'
12
12
 
13
13
  import { alert } from '$scheduleView/components/notifications'
14
14
 
15
15
  let on = false
16
- let type: 'AUTO' | 'MANUAL' = 'AUTO'
16
+ let type: 'AUTO' | 'MANUAL' | 'TERMINAL' = 'AUTO'
17
17
  let dateTime: string // YYYY-MM-DD HH:mm
18
- let iata: string
18
+ let airport: { iata: string; code: string } = { iata: null, code: null }
19
19
  let loading = false
20
20
  let resolveFn: (flight: Flight) => void
21
21
 
@@ -40,16 +40,26 @@
40
40
  let hour = 0
41
41
  let minute = 0
42
42
 
43
- export async function open(options: { dateTime: string; iata: string }): Promise<Flight> {
43
+ // TERMINAL
44
+ let terminals: string[] = []
45
+ let arrivalTerminal: string
46
+
47
+ export async function open(options: { dateTime: string; airport: { iata: string; code: string }; terminalOnly: boolean }): Promise<Flight> {
44
48
  return new Promise(async (resolve, reject) => {
45
49
  if (!options?.dateTime) {
46
50
  reject(new Error($t('flight.pleaseSelectDate')))
47
51
  return
48
52
  }
49
53
 
54
+ if (!options?.airport?.iata && !options?.airport?.code) {
55
+ reject(new Error($t('flight.pleaseSelectAnAirport')))
56
+ return
57
+ }
58
+
50
59
  resolveFn = resolve
51
60
  dateTime = options.dateTime
52
- iata = options.iata
61
+ airport.iata = options.airport?.iata
62
+ airport.code = options.airport?.code
53
63
 
54
64
  // Manual 데이터 셋팅
55
65
  manualInput = ''
@@ -62,18 +72,34 @@
62
72
  page = 1
63
73
  arrivalDate = dayjs(dateTime).minute(0)
64
74
 
65
- // iata 없으면 AUTO 검색이 불가능함.
66
- if (iata) {
67
- type = 'AUTO'
68
- fetchFlights()
75
+ // 터미널 데이터 셋팅
76
+ terminals = []
77
+ arrivalTerminal = null
78
+
79
+ if (options.terminalOnly) {
80
+ changeType('TERMINAL')
69
81
  } else {
70
- type = 'MANUAL'
82
+ // iata 가 없으면 AUTO 검색이 불가능함.
83
+ if (airport.iata) {
84
+ changeType('AUTO')
85
+ } else {
86
+ changeType('MANUAL')
87
+ }
71
88
  }
72
89
 
73
90
  on = true
74
91
  })
75
92
  }
76
93
 
94
+ function changeType(value: typeof type) {
95
+ type = value
96
+ if (type === 'TERMINAL' || type === 'MANUAL') {
97
+ fetchTerminals()
98
+ } else if (type === 'AUTO') {
99
+ fetchFlights()
100
+ }
101
+ }
102
+
77
103
  function close() {
78
104
  on = false
79
105
  }
@@ -82,7 +108,7 @@
82
108
  loading = true
83
109
  try {
84
110
  flights = await BookingAPI.searchFlights({
85
- iata,
111
+ iata: airport.iata,
86
112
  ymd: arrivalDate.format('YYYY-MM-DD'),
87
113
  time: arrivalDate.hour()
88
114
  })
@@ -94,6 +120,18 @@
94
120
  }
95
121
  }
96
122
 
123
+ async function fetchTerminals() {
124
+ try {
125
+ loading = true
126
+ terminals = await CommonAPI.getPoiTerminals(airport.code)
127
+ } catch (e) {
128
+ alert.open({ text: e.message })
129
+ terminals = []
130
+ } finally {
131
+ loading = false
132
+ }
133
+ }
134
+
97
135
  async function subtractHour() {
98
136
  arrivalDate = arrivalDate.subtract(1, 'hour')
99
137
  fetchFlights()
@@ -135,13 +173,29 @@
135
173
  }
136
174
 
137
175
  const manualFlight: FlightManual = {
138
- iata,
176
+ iata: airport.iata ?? null,
139
177
  ymd: estimateDate.format('YYYY-MM-DD HH:mm:ss'),
140
178
  name: manualInput,
141
- selectType: 'MANUAL'
179
+ selectType: 'MANUAL',
180
+ arrivalTerminal
142
181
  }
143
182
 
144
183
  resolveFn(manualFlight)
184
+ } else if (type === 'TERMINAL') {
185
+ if (!arrivalTerminal) {
186
+ alert.open({ text: $t('flight.selectTerminal') })
187
+ return
188
+ }
189
+
190
+ const terminalFlight: FlightManual = {
191
+ iata: airport.iata ?? null,
192
+ ymd: estimateDate.format('YYYY-MM-DD HH:mm:ss'),
193
+ name: null,
194
+ selectType: 'MANUAL',
195
+ arrivalTerminal
196
+ }
197
+
198
+ resolveFn(terminalFlight)
145
199
  }
146
200
 
147
201
  close()
@@ -159,132 +213,160 @@
159
213
  </div>
160
214
 
161
215
  <div class="contents pdMg">
162
- <div class="indie_tab_square_01_wrapper">
163
- <ul class="indie_tab_square_01">
164
- {#if iata}
165
- <li class:on={type === 'AUTO'}><a href={null} on:click={() => (type = 'AUTO')}>{$t('flight.selectFlightNo')}</a></li>
166
- {/if}
167
- <li class:on={type === 'MANUAL'}><a href={null} on:click={() => (type = 'MANUAL')}>{$t('flight.editManually')}</a></li>
168
- </ul>
169
- </div>
170
-
171
- {#if type === 'AUTO'}
172
- <div class="indie_flight_name_top_infos">
173
- <div class="infos">
174
- <p class="sbj">{$t('flight.arrivalDate')}</p>
175
- <p class="date">
176
- <span>{dayjs(arrivalDate).format('ll')}</span>
177
- <span>{dayjs(arrivalDate).format('HH:mm')}~{dayjs(arrivalDate).add(1, 'hour').format('HH:mm')}</span>
178
- </p>
179
- </div>
180
- <div class="btns">
181
- <button type="button" class="indie_btn_squre only prev" on:click={() => subtractHour()}>이전</button>
182
- <button type="button" class="indie_btn_squre only next" on:click={() => addHour()}>다음</button>
183
- </div>
184
- </div>
185
-
216
+ {#if type === 'TERMINAL'}
186
217
  {#if loading}
187
218
  <div class="indie_loading_common_box">
188
219
  <div class="indie_loader" />
189
220
  </div>
190
- {:else if !loading && flights.length === 0}
191
- <div class="indie_search_none_common_box">
192
- <p>{$t('flight.noFlightsWereFound')}</p>
193
- </div>
194
221
  {:else}
195
- <div bind:this={contentsEl$} class="indie_tab_squre_01_cont" in:fade={{ duration: 100, delay: 100 }}>
196
- <!-- 항공편 선택 -->
197
- <ul class="indie_flight_name_select_list">
198
- {#each flightsByPaging as item (item.name)}
199
- <li in:fade={{ duration: 100, delay: 100 }}>
200
- <div class="check">
201
- <input
202
- bind:group={flight}
203
- value={item}
204
- type="radio"
205
- class="indie_radio_box xs flight_b"
206
- name="f_choice"
207
- id="ch_{item.name}" />
208
- <label for="ch_{item.name}">
209
- <p class="flight">{item.name}</p>
210
- <div class="flight_time_box">
211
- <dl class="start">
212
- <dt>{item.departureAirport}</dt>
213
- <dd>
214
- <!-- TODO: 검색일 이전날짜인 경우 표현 -->
215
- {#if dayjs(item.departure).isBefore(arrivalDate, 'day')}
216
- <b>D-{arrivalDate.diff(dayjs(item.departure).format('YYYY-MM-DD'), 'd')}</b>
217
- {/if}
218
- {dayjs(item.departure).format('HH:mm')}
219
- </dd>
220
- </dl>
221
-
222
- <dl class="end">
223
- <dt>{item.arrivalAirport}</dt>
224
- <dd>{dayjs(item.arrive).format('HH:mm')}</dd>
225
- </dl>
226
- </div>
227
- </label>
228
- </div>
229
- </li>
230
- {/each}
231
- </ul>
232
- </div>
222
+ <select bind:value={arrivalTerminal} class="indie_select_nor w100">
223
+ <option value={null}>{$t('flight.selectTerminal')}</option>
224
+ {#each terminals as terminal}
225
+ <option value={terminal}>{terminal}</option>
226
+ {/each}
227
+ </select>
228
+ {/if}
229
+ {:else}
230
+ <div class="indie_tab_square_01_wrapper">
231
+ <ul class="indie_tab_square_01">
232
+ {#if !!airport.iata}
233
+ <li class:on={type === 'AUTO'}><a href={null} on:click={() => changeType('AUTO')}>{$t('flight.selectFlightNo')}</a></li>
234
+ {/if}
235
+ <li class:on={type === 'MANUAL'}><a href={null} on:click={() => changeType('MANUAL')}>{$t('flight.editManually')}</a></li>
236
+ </ul>
237
+ </div>
233
238
 
234
- <div class="indie_flight_paing_box" in:fade={{ duration: 100, delay: 100 }}>
235
- <div class="indie_paging_b">
236
- <button
237
- type="button"
238
- class="pg_left"
239
- style:visibility={page > 1 ? 'visible' : 'hidden'}
240
- on:click={() => (page = page > 1 ? page - 1 : page)}>이전</button>
241
- <input readonly type="text" class="txt_paging" value={page} />
242
- <span>/</span>
243
- <span class="last">{totalPage}</span>
244
- <button
245
- type="button"
246
- class="pg_right"
247
- style:visibility={page < totalPage ? 'visible' : 'hidden'}
248
- on:click={() => (page = page < totalPage ? page + 1 : page)}>
249
- 다음
250
- </button>
239
+ {#if type === 'AUTO'}
240
+ <div class="indie_flight_name_top_infos">
241
+ <div class="infos">
242
+ <p class="sbj">{$t('flight.arrivalDate')}</p>
243
+ <p class="date">
244
+ <span>{dayjs(arrivalDate).format('ll')}</span>
245
+ <span>{dayjs(arrivalDate).format('HH:mm')}~{dayjs(arrivalDate).add(1, 'hour').format('HH:mm')}</span>
246
+ </p>
247
+ </div>
248
+ <div class="btns">
249
+ <button type="button" class="indie_btn_squre only prev" on:click={() => subtractHour()}>이전</button>
250
+ <button type="button" class="indie_btn_squre only next" on:click={() => addHour()}>다음</button>
251
251
  </div>
252
252
  </div>
253
- {/if}
254
- {:else if type === 'MANUAL'}
255
- <div class="indie_tab_squre_01_cont">
256
- <!-- 항공편 직접입력 -->
257
- <input bind:value={manualInput} maxlength="15" type="text" class="indie_text_nor lg w100 mgt10" placeholder={$t('flight.flightNo')} />
258
-
259
- <div class="indie_flight_direct_input">
260
- <p class="tit">{$t('flight.estimatedTimeOfArrival')}</p>
261
-
262
- <div class="gather_box">
263
- <div class="da_select_box">
264
- <button type="button" class="indie_btn_squre only prev" on:click={() => subtractDay()}>이전</button>
265
- <p class="date">{dayjs(estimateDate).format('YYYY.MM.DD')}</p>
266
- <button type="button" class="indie_btn_squre only next" on:click={() => addDay()}>다음</button>
267
- </div>
268
- <div class="indie_time_select_box triangle lg">
269
- <select bind:value={hour} on:change={() => onChangeEstimateTime()}>
270
- {#each range(0, 24, 1) as h}
271
- <option value={h}>{padStart(`${h}`, 2, '0')}</option>
272
- {/each}
273
- </select>
274
- <span>:</span>
275
- <select bind:value={minute} on:change={() => onChangeEstimateTime()}>
276
- {#each range(0, 60, 1) as m}
277
- <option value={m}>{padStart(`${m}`, 2, '0')}</option>
278
- {/each}
279
- </select>
253
+
254
+ {#if loading}
255
+ <div class="indie_loading_common_box">
256
+ <div class="indie_loader" />
257
+ </div>
258
+ {:else if !loading && flights.length === 0}
259
+ <div class="indie_search_none_common_box">
260
+ <p>{$t('flight.noFlightsWereFound')}</p>
261
+ </div>
262
+ {:else}
263
+ <div bind:this={contentsEl$} class="indie_tab_squre_01_cont" in:fade={{ duration: 100, delay: 100 }}>
264
+ <!-- 항공편 선택 -->
265
+ <ul class="indie_flight_name_select_list">
266
+ {#each flightsByPaging as item (item.name)}
267
+ <li in:fade={{ duration: 100, delay: 100 }}>
268
+ <div class="check">
269
+ <input
270
+ bind:group={flight}
271
+ value={item}
272
+ type="radio"
273
+ class="indie_radio_box xs flight_b"
274
+ name="f_choice"
275
+ id="ch_{item.name}" />
276
+ <label for="ch_{item.name}">
277
+ <p class="flight">{item.name}</p>
278
+ <div class="flight_time_box">
279
+ <dl class="start">
280
+ <dt>{item.departureAirport}</dt>
281
+ <dd>
282
+ <!-- TODO: 검색일 이전날짜인 경우 표현 -->
283
+ {#if dayjs(item.departure).isBefore(arrivalDate, 'day')}
284
+ <b>D-{arrivalDate.diff(dayjs(item.departure).format('YYYY-MM-DD'), 'd')}</b>
285
+ {/if}
286
+ {dayjs(item.departure).format('HH:mm')}
287
+ </dd>
288
+ </dl>
289
+
290
+ <dl class="end">
291
+ <dt>{item.arrivalAirport}</dt>
292
+ <dd>{dayjs(item.arrive).format('HH:mm')}</dd>
293
+ </dl>
294
+ </div>
295
+ </label>
296
+ </div>
297
+ </li>
298
+ {/each}
299
+ </ul>
300
+ </div>
301
+
302
+ <div class="indie_flight_paing_box" in:fade={{ duration: 100, delay: 100 }}>
303
+ <div class="indie_paging_b">
304
+ <button
305
+ type="button"
306
+ class="pg_left"
307
+ style:visibility={page > 1 ? 'visible' : 'hidden'}
308
+ on:click={() => (page = page > 1 ? page - 1 : page)}>이전</button>
309
+ <input readonly type="text" class="txt_paging" value={page} />
310
+ <span>/</span>
311
+ <span class="last">{totalPage}</span>
312
+ <button
313
+ type="button"
314
+ class="pg_right"
315
+ style:visibility={page < totalPage ? 'visible' : 'hidden'}
316
+ on:click={() => (page = page < totalPage ? page + 1 : page)}>
317
+ 다음
318
+ </button>
280
319
  </div>
281
320
  </div>
321
+ {/if}
322
+ {:else if type === 'MANUAL'}
323
+ <div class="indie_tab_squre_01_cont">
324
+ <!-- 항공편 직접입력 -->
325
+ <input bind:value={manualInput} maxlength="15" type="text" class="indie_text_nor w100 mgt10" placeholder={$t('flight.flightNo')} />
326
+
327
+ {#if loading}
328
+ <div class="indie_loading_common_box">
329
+ <div class="indie_loader" />
330
+ </div>
331
+ {:else}
332
+ <select bind:value={arrivalTerminal} class="indie_select_nor w100 mgt5">
333
+ <option value={null}>{$t('flight.selectTerminal')}</option>
334
+ {#each terminals as terminal}
335
+ <option value={terminal}>{terminal}</option>
336
+ {/each}
337
+ </select>
338
+ {/if}
339
+
340
+ <div class="indie_flight_direct_input">
341
+ <p class="tit">{$t('flight.estimatedTimeOfArrival')}</p>
342
+
343
+ <div class="gather_box">
344
+ <div class="da_select_box">
345
+ <button type="button" class="indie_btn_squre only prev" on:click={() => subtractDay()}>이전</button>
346
+ <p class="date">{dayjs(estimateDate).format('YYYY.MM.DD')}</p>
347
+ <button type="button" class="indie_btn_squre only next" on:click={() => addDay()}>다음</button>
348
+ </div>
349
+ <div class="indie_time_select_box triangle lg">
350
+ <select bind:value={hour} on:change={() => onChangeEstimateTime()}>
351
+ {#each range(0, 24, 1) as h}
352
+ <option value={h}>{padStart(`${h}`, 2, '0')}</option>
353
+ {/each}
354
+ </select>
355
+ <span>:</span>
356
+ <select bind:value={minute} on:change={() => onChangeEstimateTime()}>
357
+ {#each range(0, 60, 1) as m}
358
+ <option value={m}>{padStart(`${m}`, 2, '0')}</option>
359
+ {/each}
360
+ </select>
361
+ </div>
362
+ </div>
282
363
 
283
- <div class="indie_exclamation_mark_box sm black">
284
- <p class="normal">{$t('flight.directly')}</p>
364
+ <div class="indie_exclamation_mark_box sm black">
365
+ <p class="normal">{$t('flight.directly')}</p>
366
+ </div>
285
367
  </div>
286
368
  </div>
287
- </div>
369
+ {/if}
288
370
  {/if}
289
371
  </div>
290
372
 
@@ -88,6 +88,11 @@ function createBookingStore(bookingDTO: Awaited<ReturnType<typeof BookingAPI.get
88
88
  $availableExtraServices.some(extra => extra.type === ExtraServiceType.picket)
89
89
  )
90
90
 
91
+ const isFlightService = derived(
92
+ booking,
93
+ $booking => $booking?.serviceType === BookingServiceType.pickup || $booking?.serviceType === BookingServiceType.sending
94
+ )
95
+
91
96
  // 금액 정보
92
97
  const price = derived(booking, $booking => {
93
98
  const beforePrice = isNumber($booking?.price) ? $booking.price : null
@@ -334,6 +339,7 @@ function createBookingStore(bookingDTO: Awaited<ReturnType<typeof BookingAPI.get
334
339
  selectedPrice,
335
340
  isModifiable,
336
341
  priceDifference,
342
+ isFlightService,
337
343
 
338
344
  // subscribe & set
339
345
  hour,
@@ -6,6 +6,7 @@ interface BaseFlight {
6
6
  name: string
7
7
  iata: string
8
8
  selectType: 'AUTO' | 'MANUAL'
9
+ arrivalTerminal?: string
9
10
  }
10
11
 
11
12
  export interface FlightAuto extends BaseFlight {
@@ -17,7 +18,6 @@ export interface FlightAuto extends BaseFlight {
17
18
  arrivalAirport: string
18
19
  departureAirport: string
19
20
  delay: boolean
20
- arrivalTerminal: string
21
21
  }
22
22
 
23
23
  export interface FlightManual extends BaseFlight {