diff --git a/src/apps/定期申込予約/index.tsx b/src/apps/定期申込予約/index.tsx index 0dcfb7c..a84028b 100644 --- a/src/apps/定期申込予約/index.tsx +++ b/src/apps/定期申込予約/index.tsx @@ -1,7 +1,8 @@ import { AppID } from "@/common/appids"; import { setHeaderButton } from "@/common/header-button"; -import { CancelError } from "@/exception"; +import { CancelError, Message } from "@/exception"; import { + ErrorDialog, ShowConfirmDialog, SuccessDialog, WarningDialog, @@ -52,9 +53,15 @@ import { 申込 } from "./自動承認"; } catch (e) { if (e instanceof CancelError) { console.log("canceled"); - } else { - throw e; + return; + } else if (e instanceof Message) { + ErrorDialog.fire({ + text: e.message, + }); + return; } + ErrorDialog.fire(); + throw e; } }); } diff --git a/src/apps/定期申込予約/自動承認.ts b/src/apps/定期申込予約/自動承認.ts index 8e0ce64..984a058 100644 --- a/src/apps/定期申込予約/自動承認.ts +++ b/src/apps/定期申込予約/自動承認.ts @@ -28,7 +28,7 @@ import { 車室契約情報, 車室契約情報フィールド名 } from "@/type import { 車室情報2 } from "@/types/車室情報2"; import { 顧客マスタフィールド名 } from "@/types/顧客マスタ"; import { sprintf } from "sprintf"; -import { CancelError } from "../../exception"; +import { CancelError, Message } from "../../exception"; import { 入金予定結果フィールド名 } from "@/types/入金予定結果"; import { dateParse, now } from "@/common/datetime"; @@ -93,7 +93,7 @@ export class 申込 { private async 契約対象車室取得() { if (!this.定期申込予約.駐車場.value) { - throw new Error("駐車場名の設定をしてください"); + throw new Message("駐車場名の設定をしてください"); } this.車室一覧 = await get車室情報一覧({ @@ -102,7 +102,7 @@ export class 申込 { } private async 契約情報取得() { if (!this.定期申込予約.駐車場.value) { - throw new Error("駐車場名の設定をしてください"); + throw new Message("駐車場名の設定をしてください"); } this.契約一覧 = await get車室契約情報一覧({ 駐車場名: this.定期申込予約.駐車場.value, @@ -111,7 +111,7 @@ export class 申込 { } private async 自動承認グループ取得() { if (!this.定期申込予約.定期駐車場プラン.value) { - throw new Error("プラン名の設定をしてください"); + throw new Message("プラン名の設定をしてください"); } this.自動承認グループ = await get自動承認グループ( this.定期申込予約.定期駐車場プラン.value @@ -143,7 +143,7 @@ export class 申込 { .find(() => true); if (!target) { - throw new Error("空き車室がありません"); + throw new Message("空き車室がありません"); } const 車室番号 = Number(target.value.車室番号.value); @@ -151,7 +151,7 @@ export class 申込 { return Number(room.車室番号.value) === 車室番号; }); if (!車室) { - throw new Error("車室がありません"); + throw new Message("車室がありません"); } return 車室; @@ -240,7 +240,7 @@ export class 申込 { private get契約開始日() { const 利用開始希望日 = this.定期申込予約.利用開始希望日.value; - if (!利用開始希望日) throw new Error("利用開始希望日不正"); + if (!利用開始希望日) throw new Message("利用開始希望日不正"); return 利用開始希望日; } diff --git a/src/exception/index.ts b/src/exception/index.ts index 72e75ce..8eb556b 100644 --- a/src/exception/index.ts +++ b/src/exception/index.ts @@ -1 +1,2 @@ export class CancelError extends Error {} +export class Message extends Error {} diff --git a/src/middleware/swal.ts b/src/middleware/swal.ts index 40fae89..568fd4a 100644 --- a/src/middleware/swal.ts +++ b/src/middleware/swal.ts @@ -6,11 +6,17 @@ export const SuccessDialog = Swal.mixin({ timer: 1000, title: "成功しました", showConfirmButton: false, + didOpen: () => { + Swal.hideLoading(); + }, }); export const ErrorDialog = Swal.mixin({ icon: "error", title: "エラーが発生しました", + didOpen: () => { + Swal.hideLoading(); + }, }); export const WarningDialog = Swal.mixin({ icon: "warning", @@ -21,6 +27,9 @@ export const ConfirmDialog = Swal.mixin({ showCancelButton: true, confirmButtonText: "実行", cancelButtonText: "キャンセル", + didOpen: () => { + Swal.hideLoading(); + }, }); export const ShowConfirmDialog = (param: SweetAlertOptions) => {