@movvjs/svelte-schedule-view 0.4.16 → 0.4.17-beta-4

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.
@@ -15,6 +15,7 @@ import PhoneNumberInput from "./PhoneNumberInput.svelte";
15
15
  import FileUploader from "./FileUploader.svelte";
16
16
  import CarSearch from "./CarSearch.svelte";
17
17
  import Calender from "./Calender.svelte";
18
+ import EmailList from "./EmailList.svelte";
18
19
  const { stdt, fullName, pax, extraServices, files, plans, isFlightService } = originalBooking;
19
20
  const {
20
21
  withPreserveAndPreview,
@@ -285,8 +286,17 @@ function openCalender() {
285
286
  <td>
286
287
  {#if !$isEdit}
287
288
  <p class="value-txt">{$originalBooking.email}</p>
289
+
290
+ {#each $originalBooking.emailList || [] as email}
291
+ {#if email?.trim()}
292
+ <p class="value-txt">{email}</p>
293
+ {/if}
294
+ {/each}
288
295
  {:else}
289
- <input bind:value={$copiedBooking.email} type="email" class="indie_text_nor xs3 white w100" placeholder="E-mail" />
296
+ <!-- <input bind:value={$copiedBooking.email} type="email" class="indie_text_nor xs3 white w100" placeholder="E-mail" /> -->
297
+ {#if $copiedBooking}
298
+ <EmailList bind:emailList={$copiedBooking.emailList} />
299
+ {/if}
290
300
  {/if}
291
301
  </td>
292
302
  </tr>
@@ -0,0 +1,33 @@
1
+ <script>export let emailList = [""];
2
+ export let required = true;
3
+ $:
4
+ if (!emailList || emailList.length === 0) {
5
+ emailList = [""];
6
+ }
7
+ function addEmail() {
8
+ emailList = [...emailList, ""];
9
+ }
10
+ function removeEmail(index) {
11
+ if (index === 0 && required)
12
+ return;
13
+ emailList = emailList.filter((_, i) => i !== index);
14
+ }
15
+ function updateEmail(index, value) {
16
+ emailList[index] = value;
17
+ emailList = [...emailList];
18
+ }
19
+ </script>
20
+
21
+ <div class="add_email_list">
22
+ {#each emailList as email, index}
23
+ <div class="item">
24
+ <input type="text" class="text_nor w100" placeholder="email" value={email} on:input={e => updateEmail(index, e.currentTarget.value)} />
25
+
26
+ {#if index === 0}
27
+ <button type="button" class="button_add" on:click={addEmail}> 추가 </button>
28
+ {:else}
29
+ <button type="button" class="button_minus" on:click={() => removeEmail(index)}> 삭제 </button>
30
+ {/if}
31
+ </div>
32
+ {/each}
33
+ </div>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ emailList?: string[];
5
+ required?: boolean;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type EmailListProps = typeof __propDef.props;
13
+ export type EmailListEvents = typeof __propDef.events;
14
+ export type EmailListSlots = typeof __propDef.slots;
15
+ export default class EmailList extends SvelteComponent<EmailListProps, EmailListEvents, EmailListSlots> {
16
+ }
17
+ export {};
@@ -170,10 +170,15 @@ export function close() {
170
170
  async function edit() {
171
171
  try {
172
172
  loader.show();
173
- $copiedBooking = await BookingAPI.modifyPreview($originalBooking);
173
+ const preview = await BookingAPI.modifyPreview($originalBooking);
174
+ if (!preview)
175
+ return;
176
+ const mergedEmailList = [preview.email, ...preview.emailList ?? []].filter(Boolean);
177
+ $copiedBooking = {
178
+ ...preview,
179
+ emailList: mergedEmailList
180
+ };
174
181
  $originalBooking = cloneDeep($copiedBooking);
175
- $availableWaypointZones = await BookingAPI.searchWaypoints({ type: $copiedBooking.serviceType, coordinate: $copiedBooking.origin, keyword: "" });
176
- $availableDestZones = await BookingAPI.searchDestinations({ type: $copiedBooking.serviceType, coordinate: $copiedBooking.dest, keyword: "" });
177
182
  $isEdit = true;
178
183
  } catch (e) {
179
184
  if ($originalBooking?.gdsSystemCode !== HERTZ && e?.errorCode === "E-0003")
@@ -195,6 +200,9 @@ async function save() {
195
200
  if (!$copiedBooking.tel) {
196
201
  throw new Error($t("error.pleaseEnterTelNumber"));
197
202
  }
203
+ const cleaned = $copiedBooking.emailList.map((e) => e?.trim()).filter(Boolean);
204
+ $copiedBooking.email = cleaned[0] ?? "";
205
+ $copiedBooking.emailList = cleaned.slice(1);
198
206
  loader.show();
199
207
  const modifiedBooking = await BookingAPI.modify({
200
208
  ...$copiedBooking,
@@ -17,6 +17,7 @@ export type BookingViewDTO = {
17
17
  tel: string;
18
18
  countryCode: string;
19
19
  email: string;
20
+ emailList: string[];
20
21
  serviceType: BookingServiceType;
21
22
  carInfo: CarInfo;
22
23
  status: BookingStatus;
@@ -95,6 +95,10 @@ export declare const originalBooking: {
95
95
  subscribe: (this: void, run: import("svelte/store").Subscriber<string>, invalidate?: import("svelte/store").Invalidator<string>) => import("svelte/store").Unsubscriber;
96
96
  set(ymd: string): void;
97
97
  };
98
+ emailList: {
99
+ subscribe: (this: void, run: import("svelte/store").Subscriber<string[]>, invalidate?: import("svelte/store").Invalidator<string[]>) => import("svelte/store").Unsubscriber;
100
+ set(list: string[]): void;
101
+ };
98
102
  };
99
103
  export declare const copiedBooking: {
100
104
  subscribe: (this: void, run: import("svelte/store").Subscriber<BookingViewDTO>, invalidate?: import("svelte/store").Invalidator<BookingViewDTO>) => import("svelte/store").Unsubscriber;
@@ -190,4 +194,8 @@ export declare const copiedBooking: {
190
194
  subscribe: (this: void, run: import("svelte/store").Subscriber<string>, invalidate?: import("svelte/store").Invalidator<string>) => import("svelte/store").Unsubscriber;
191
195
  set(ymd: string): void;
192
196
  };
197
+ emailList: {
198
+ subscribe: (this: void, run: import("svelte/store").Subscriber<string[]>, invalidate?: import("svelte/store").Invalidator<string[]>) => import("svelte/store").Unsubscriber;
199
+ set(list: string[]): void;
200
+ };
193
201
  };
@@ -282,6 +282,18 @@ function createBookingStore(bookingDTO) {
282
282
  return !viewOnly;
283
283
  }
284
284
  });
285
+ // 이메일 리스트
286
+ const emailList = {
287
+ subscribe: derived(booking, $booking => $booking?.emailList ?? []).subscribe,
288
+ set(list) {
289
+ withPreserveAndPreview(() => {
290
+ booking.update($booking => {
291
+ $booking.emailList = list;
292
+ return $booking;
293
+ });
294
+ });
295
+ }
296
+ };
285
297
  /**
286
298
  * 예약 정보 세팅
287
299
  * - name은 있는데, first / last가 없는 경우, name을 first로 세팅
@@ -371,7 +383,8 @@ function createBookingStore(bookingDTO) {
371
383
  isPicketService,
372
384
  isAeroService,
373
385
  addTime,
374
- ymd
386
+ ymd,
387
+ emailList
375
388
  };
376
389
  }
377
390
  export const originalBooking = createBookingStore(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movvjs/svelte-schedule-view",
3
- "version": "0.4.16",
3
+ "version": "0.4.17-beta-4",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "author": {