From 05f01a78286b5a57b4c5e07f83b82ff6ef796522 Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Tue, 4 Jun 2024 10:52:44 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AF=E3=83=AC=E3=82=B8=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=82=AB=E3=83=BC=E3=83=89=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/apps/入金予定結果/index.tsx | 3 +- ...ジットカード登録承認ボタン.ts | 66 +++++++++++++++++++ .../buttons/口座変更承認ボタン.ts | 33 +++++----- ...車場利用方法変更承認ボタン.ts | 9 +-- src/apps/各種申請/index.tsx | 4 +- src/common/message.ts | 4 +- src/common/rest-api-client.ts | 2 +- src/mypage/lib.ts | 2 +- src/mypage/メール.ts | 1 + src/rest-api/bulk.ts | 2 +- src/rest-api/url.ts | 2 +- src/rest-api/顧客マスタ.ts | 2 +- src/types/入金予定結果.ts | 4 +- src/types/各種申請.ts | 6 ++ tsconfig.json | 5 +- webpack.config.js | 7 ++ yarn.lock | 9 ++- 18 files changed, 128 insertions(+), 34 deletions(-) create mode 100644 src/apps/各種申請/buttons/クレジットカード登録承認ボタン.ts diff --git a/package.json b/package.json index ecf0c13..f3ca5fa 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "eslint": "^6.8.0", "fork-ts-checker-webpack-plugin": "^5.2.0", "glob": "^7.1.6", + "lodash-webpack-plugin": "^0.11.6", "ts-loader": "^8.0.17", "tsconfig-paths-webpack-plugin": "^4.1.0", "typescript": "^4.1.2", diff --git a/src/apps/入金予定結果/index.tsx b/src/apps/入金予定結果/index.tsx index 3f990cb..d00a63f 100644 --- a/src/apps/入金予定結果/index.tsx +++ b/src/apps/入金予定結果/index.tsx @@ -19,7 +19,8 @@ import { 定期申込予約フィールド名 } from "@/types/定期申込予約 import { 顧客マスタフィールド名 } from "@/types/顧客マスタ"; import { KintoneRestAPIClient } from "@kintone/rest-api-client"; import { addDays, format, setHours } from "date-fns"; -import { get, set } from "lodash"; +import get from "lodash/get"; +import set from "lodash/set"; import Swal from "sweetalert2"; const client = new KintoneRestAPIClient(); diff --git a/src/apps/各種申請/buttons/クレジットカード登録承認ボタン.ts b/src/apps/各種申請/buttons/クレジットカード登録承認ボタン.ts new file mode 100644 index 0000000..3a3b8bc --- /dev/null +++ b/src/apps/各種申請/buttons/クレジットカード登録承認ボタン.ts @@ -0,0 +1,66 @@ +import { apptemplate } from "@/common/app-template"; +import { AppID } from "@/common/appids"; +import { now } from "@/common/datetime"; +import { setHeaderButton } from "@/common/header-button"; +import { makeDatetimeStr, makeRecordData } from "@/common/rest-api-client"; +import { Message } from "@/exception"; +import { ShowConfirmDialog, SuccessDialog } from "@/middleware/swal"; +import { EmailID, sendEmail } from "@/mypage/メール"; +import bulkRequest from "@/rest-api/bulk"; +import { get顧客マスタ } from "@/rest-api/顧客マスタ"; +import { + 各種申請, + 各種申請フィールド名, + 状況Dropdown, + 申請種別Dropdown, +} from "@/types/各種申請"; +import { addHours } from "date-fns"; +import { v4 as uuidV4 } from "uuid"; +import { 各種申請完了 } from "./common"; + +export const クレジットカード登録承認ボタン = (record: 各種申請) => { + if ( + record.状況.value !== 状況Dropdown.完了 && + record.申請種別.value === 申請種別Dropdown.クレジット支払変更申請 + ) { + setHeaderButton( + "クレジット支払変更申請 承認", + apptemplate(async ({ needReloadAtEnd }) => { + const confirm = await ShowConfirmDialog({ title: "承認しますか" }); + if (!confirm.isConfirmed) return; + // 顧客マスタへの反映 + const customer = await get顧客マスタ({ + 顧客コード: Number(record.顧客コード.value), + }); + if (customer === null) throw new Error("顧客不正"); + + bulkRequest.update({ + app: AppID.各種申請, + id: record.$id.value, + record: makeRecordData({ + [各種申請フィールド名.クレジット支払変更申請_トークン]: uuidV4(), + [各種申請フィールド名.クレジット支払変更申請_有効期限]: + makeDatetimeStr(addHours(now(), 24)), + }), + }); + + // 申請の完了 + await 各種申請完了(record); + + // データ保存 + await bulkRequest.save(); + + // メールの送信 + const email = await sendEmail(EmailID.クレジットカード登録, { + application_no: record.申請番号.value, + }); + if (!email) { + throw new Message("メール送信失敗 データは反映済み"); + } + + await SuccessDialog.fire(); + needReloadAtEnd(true); + }) + ); + } +}; diff --git a/src/apps/各種申請/buttons/口座変更承認ボタン.ts b/src/apps/各種申請/buttons/口座変更承認ボタン.ts index d288b73..1914e1e 100644 --- a/src/apps/各種申請/buttons/口座変更承認ボタン.ts +++ b/src/apps/各種申請/buttons/口座変更承認ボタン.ts @@ -25,26 +25,27 @@ export const 口座変更承認ボタン = (record: 各種申請) => { }); if (customer === null) throw new Error("顧客不正"); + let updateData = makeRecordData({ + [顧客マスタフィールド名.口座登録催促予定日時]: "", + [顧客マスタフィールド名.銀行支店コード]: + record.口座変更申請_変更後_銀行支店ID.value, + [顧客マスタフィールド名.引落預金種別]: + record.口座変更申請_変更後_口座種目.value, + [顧客マスタフィールド名.引落口座名義人カナ]: + record.口座変更申請_変更後_口座名義カナ.value, + [顧客マスタフィールド名.引落口座番号]: + record.口座変更申請_変更後_口座番号.value, + [顧客マスタフィールド名.ゆうちょ口座記号]: + record.口座変更申請_変更後_ゆうちょ口座記号.value, + [顧客マスタフィールド名.ゆうちょ口座番号]: + record.口座変更申請_変更後_ゆうちょ口座番号.value, + }); + // 顧客マスタへの反映 await bulkRequest.update({ app: AppID.顧客マスタ, id: customer.$id.value, - record: makeRecordData({ - [顧客マスタフィールド名.支払方法]: "口座振替", - [顧客マスタフィールド名.口座登録催促予定日時]: "", - [顧客マスタフィールド名.銀行支店コード]: - record.口座変更申請_変更後_銀行支店ID.value, - [顧客マスタフィールド名.引落預金種別]: - record.口座変更申請_変更後_口座種目.value, - [顧客マスタフィールド名.引落口座名義人カナ]: - record.口座変更申請_変更後_口座名義カナ.value, - [顧客マスタフィールド名.引落口座番号]: - record.口座変更申請_変更後_口座番号.value, - [顧客マスタフィールド名.ゆうちょ口座記号]: - record.口座変更申請_変更後_ゆうちょ口座記号.value, - [顧客マスタフィールド名.ゆうちょ口座番号]: - record.口座変更申請_変更後_ゆうちょ口座番号.value, - }), + record: updateData, }); // 各種申請の完了 diff --git a/src/apps/各種申請/buttons/駐車場利用方法変更承認ボタン.ts b/src/apps/各種申請/buttons/駐車場利用方法変更承認ボタン.ts index f21b870..ed3d3d0 100644 --- a/src/apps/各種申請/buttons/駐車場利用方法変更承認ボタン.ts +++ b/src/apps/各種申請/buttons/駐車場利用方法変更承認ボタン.ts @@ -1,24 +1,21 @@ import { apptemplate } from "@/common/app-template"; import { AppID } from "@/common/appids"; import { setHeaderButton } from "@/common/header-button"; +import { MessageBag } from "@/common/message"; import { makeRecordData } from "@/common/rest-api-client"; import { 契約情報更新イベント } from "@/event/契約情報更新"; +import { Message } from "@/exception"; import { - ErrorDialog, - FormDialog, ShowConfirmDialog, ShowFormDialog, SuccessDialog, } from "@/middleware/swal"; -import { EmailID, sendEmail } from "@/mypage/メール"; +import { 定期契約更新 } from "@/mypage/IC定期"; import bulkRequest from "@/rest-api/bulk"; import { get車室情報管理 } from "@/rest-api/車室情報管理"; import { 各種申請, 状況Dropdown, 申請種別Dropdown } from "@/types/各種申請"; import { 車室情報管理フィールド名 } from "@/types/車室情報管理"; import { 各種申請完了 } from "./common"; -import { 定期契約更新 } from "@/mypage/IC定期"; -import { Message } from "@/exception"; -import { MessageBag } from "@/common/message"; export const 駐車場利用方法変更承認ボタン = (record: 各種申請) => { if ( diff --git a/src/apps/各種申請/index.tsx b/src/apps/各種申請/index.tsx index dbf7006..74c35e3 100644 --- a/src/apps/各種申請/index.tsx +++ b/src/apps/各種申請/index.tsx @@ -2,7 +2,7 @@ import { eventHnalder } from "@/common/app-template"; import { initMenuBox } from "@/common/header-button"; import { KintoneEvent } from "@/common/kintone-event"; import { 各種申請, 申請詳細グループ } from "@/types/各種申請"; -import { get } from "lodash"; +import get from "lodash/get"; import { setup } from ".."; import { 口座変更承認ボタン } from "./buttons/口座変更承認ボタン"; import { 解約承認ボタン } from "./buttons/解約承認ボタン"; @@ -10,6 +10,7 @@ import { 利用者情報変更承認ボタン } from "./buttons/利用者情報 import { 車両番号変更承認ボタン } from "./buttons/車両番号変更承認ボタン"; import { 車庫証明発行手数料入金予定作成ボタン } from "./buttons/車庫証明発行手数料入金予定作成ボタン"; import { 駐車場利用方法変更承認ボタン } from "./buttons/駐車場利用方法変更承認ボタン"; +import { クレジットカード登録承認ボタン } from "./buttons/クレジットカード登録承認ボタン"; setup(() => { kintone.events.on( @@ -25,6 +26,7 @@ setup(() => { 車両番号変更承認ボタン(record); 車庫証明発行手数料入金予定作成ボタン(record); 駐車場利用方法変更承認ボタン(record); + クレジットカード登録承認ボタン(record); }) ); diff --git a/src/common/message.ts b/src/common/message.ts index 8dbc283..9ed1815 100644 --- a/src/common/message.ts +++ b/src/common/message.ts @@ -1,4 +1,6 @@ -import { Dictionary } from "lodash"; +interface Dictionary { + [index: string]: T; +} export class MessageBag { private generalMessage: string = ""; diff --git a/src/common/rest-api-client.ts b/src/common/rest-api-client.ts index 893ca44..e60415c 100644 --- a/src/common/rest-api-client.ts +++ b/src/common/rest-api-client.ts @@ -1,4 +1,4 @@ -import { get } from "lodash"; +import get from "lodash/get"; import { formatDateStr } from "./datetime"; export type Field = { diff --git a/src/mypage/lib.ts b/src/mypage/lib.ts index 6625a8a..df9d575 100644 --- a/src/mypage/lib.ts +++ b/src/mypage/lib.ts @@ -1,7 +1,7 @@ import { myPageConfig } from "@/config/mypage"; import { MyPageApiID } from "."; import { MessageBag } from "@/common/message"; -import { get } from "lodash"; +import get from "lodash/get"; type MyPageApiResponse = { result: "SUCCESS" | "FAILED"; diff --git a/src/mypage/メール.ts b/src/mypage/メール.ts index 86bd314..ba5bf5a 100644 --- a/src/mypage/メール.ts +++ b/src/mypage/メール.ts @@ -14,6 +14,7 @@ export const EmailID = { 定期選考_当選のお知らせ: "定期選考_当選のお知らせ", 定期選考_落選のお知らせ: "定期選考_落選のお知らせ", 口座振替_未納者通知: "口座振替・未納者通知", + クレジットカード登録: "クレジットカード登録", } as const; export type EmailID = (typeof EmailID)[keyof typeof EmailID]; diff --git a/src/rest-api/bulk.ts b/src/rest-api/bulk.ts index b8b728d..ea7abbe 100644 --- a/src/rest-api/bulk.ts +++ b/src/rest-api/bulk.ts @@ -1,7 +1,7 @@ import { AppID } from "@/common/appids"; import { Field } from "@/common/rest-api-client"; import { KintoneRestAPIClient } from "@kintone/rest-api-client"; -import { chunk } from "lodash"; +import chunk from "lodash/chunk"; const UPDATE_PARAM = { method: "PUT", diff --git a/src/rest-api/url.ts b/src/rest-api/url.ts index e8b89a4..ad7f29a 100644 --- a/src/rest-api/url.ts +++ b/src/rest-api/url.ts @@ -1,5 +1,5 @@ import { AppID } from "@/common/appids"; -import { get } from "lodash"; +import get from "lodash/get"; import { sprintf } from "sprintf"; export const getDetailUrl = (app: AppID, レコード番号: string | number) => { diff --git a/src/rest-api/顧客マスタ.ts b/src/rest-api/顧客マスタ.ts index ec708ca..fc41c65 100644 --- a/src/rest-api/顧客マスタ.ts +++ b/src/rest-api/顧客マスタ.ts @@ -4,7 +4,7 @@ import { 顧客マスタ, 顧客マスタフィールド名 } from "@/types/顧 import { KintoneRestAPIClient } from "@kintone/rest-api-client"; import { sprintf } from "sprintf"; import { QueryBuilder } from "./query"; -import { max } from "lodash"; +import max from "lodash/max"; const client = new KintoneRestAPIClient(); diff --git a/src/types/入金予定結果.ts b/src/types/入金予定結果.ts index 972d2ec..7212be6 100644 --- a/src/types/入金予定結果.ts +++ b/src/types/入金予定結果.ts @@ -1,6 +1,8 @@ import { KintoneRecordField } from "@kintone/rest-api-client"; import { AppRecord } from "."; -import { get, has, set } from "lodash"; +import get from "lodash/get"; +import set from "lodash/set"; +import has from "lodash/has"; const F = { 車室情報管理レコード番号: "contract_record_number", diff --git a/src/types/各種申請.ts b/src/types/各種申請.ts index c9448eb..797d871 100644 --- a/src/types/各種申請.ts +++ b/src/types/各種申請.ts @@ -5,6 +5,8 @@ const F = { 申請種別: "申請種別", 申請番号: "申請番号", 状況: "状況", + クレジット支払変更申請_トークン: "クレジット支払変更申請_トークン", + クレジット支払変更申請_有効期限: "クレジット支払変更申請_有効期限", } as const; export const 状況Dropdown = { @@ -24,6 +26,7 @@ export const 申請種別Dropdown = { 口座変更申請: "口座変更申請", プラン変更: "プラン変更", IC定期_駐車場利用方法変更申請: "IC定期_駐車場利用方法変更申請", + クレジット支払変更申請: "クレジット支払変更申請", } as const; export type 申請種別Dropdown = (typeof 申請種別Dropdown)[keyof typeof 申請種別Dropdown]; @@ -46,6 +49,7 @@ export const 申請詳細グループ = { [申請種別Dropdown.プラン変更]: "プラン変更申請", [申請種別Dropdown.IC定期_駐車場利用方法変更申請]: "IC定期_駐車場利用方法変更申請", + [申請種別Dropdown.クレジット支払変更申請]: "クレジット支払変更申請", } as const; export type 申請詳細グループ = (typeof 申請詳細グループ)[keyof typeof 申請詳細グループ]; @@ -133,4 +137,6 @@ export type 各種申請 = AppRecord & { IC定期_駐車場利用方法変更申請_変更前: KintoneRecordField.SingleLineText; IC定期_駐車場利用方法変更申請_変更後: KintoneRecordField.SingleLineText; IC定期_駐車場利用方法変更申請_備考: KintoneRecordField.MultiLineText; + [F.クレジット支払変更申請_トークン]: KintoneRecordField.SingleLineText; + [F.クレジット支払変更申請_有効期限]: KintoneRecordField.DateTime; }; diff --git a/tsconfig.json b/tsconfig.json index 8252bce..29caa7b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,12 +2,13 @@ "compilerOptions": { "sourceMap": true, // TSはECMAScript 5に変換 - "target": "ES2015", + "target": "ESNext", // TSのモジュールはES Modulesとして出力 - "module": "ES2015", + "module": "ES6", // 厳密モードとして設定 "strict": true, "allowJs": true, + "allowSyntheticDefaultImports": true, "moduleResolution": "node", "baseUrl": ".", "paths": { diff --git a/webpack.config.js b/webpack.config.js index d13677c..0409159 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,6 +5,8 @@ const { exec } = require('child_process'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; +const LodashModuleReplacementPlugin = require('lodash-webpack-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); const Dotenv = require('dotenv-webpack'); const dotenv = require('dotenv'); const { format } = require('date-fns'); @@ -23,6 +25,10 @@ const entries = glob.sync('*/index.+(js|ts|tsx)', { cwd: basePath }).reduce( ); module.exports = { + optimization: { + minimize: true, + minimizer: [new TerserPlugin()], + }, entry: entries, cache: false, resolve: { @@ -70,6 +76,7 @@ module.exports = { // new Dotenv({ systemvars: true }), new ForkTsCheckerWebpackPlugin(), // new BundleAnalyzerPlugin(), + new LodashModuleReplacementPlugin(), new webpack.DefinePlugin({ 'process.env.BUILD_TIME': JSON.stringify(format(new Date(), 'yyyy-MM-dd HH:mm:ss')), }), diff --git a/yarn.lock b/yarn.lock index fdd7da5..dd4fe94 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4229,12 +4229,19 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" +lodash-webpack-plugin@^0.11.6: + version "0.11.6" + resolved "https://registry.yarnpkg.com/lodash-webpack-plugin/-/lodash-webpack-plugin-0.11.6.tgz#8204c6b78beb62ce5211217dfe783c21557ecd33" + integrity sha512-nsHN/+IxZK/C425vGC8pAxkKJ8KQH2+NJnhDul14zYNWr6HJcA95w+oRR7Cp0oZpOdMplDZXmjVROp8prPk7ig== + dependencies: + lodash "^4.17.20" + lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow== -lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21: +lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==