diff --git a/.env.development b/.env.development index 7ad87b6..1d5d633 100644 --- a/.env.development +++ b/.env.development @@ -2,6 +2,7 @@ NEXT_PUBLIC_ENV=dev NEXT_PUBLIC_API_BASE=http://localhost:3000/api ENV=dev +CONTACT_SERVER=http://localhost:4001 API_CONTACT_SERVER=http://localhost:4001/api/v1 API_INTRANET_SERVER=http://localhost:3031/api/v1 API_KART_SERVER=https://rapi.kric.com/api/v1 diff --git a/.env.local b/.env.local index db36704..fc8580d 100644 --- a/.env.local +++ b/.env.local @@ -2,6 +2,7 @@ NEXT_PUBLIC_ENV=local NEXT_PUBLIC_API_BASE=http://localhost:3000/api ENV=local +CONTACT_SERVER=http://localhost:4001 API_CONTACT_SERVER=http://localhost:4001/api/v1 API_INTRANET_SERVER=http://localhost:3031/api/v1 API_KART_SERVER=https://rapi.kric.com/api/v1 diff --git a/.env.production b/.env.production index 82d6537..92036b2 100644 --- a/.env.production +++ b/.env.production @@ -2,6 +2,7 @@ NEXT_PUBLIC_ENV=prod NEXT_PUBLIC_API_BASE=http://localhost:3000/api ENV=prod +CONTACT_SERVER=http://localhost:4001 API_CONTACT_SERVER=http://localhost:4001/api/v1 API_INTRANET_SERVER=http://localhost:3031/api/v1 API_KART_SERVER=https://rapi.kric.com/api/v1 diff --git a/next.config.ts b/next.config.ts index 66e1566..5565ca0 100644 --- a/next.config.ts +++ b/next.config.ts @@ -3,6 +3,15 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ reactCompiler: true, + + async rewrites() { + return [ + { + source: "/contact-senario/:path*", + destination: `${process.env.CONTACT_SERVER}/contact-senario/:path*`, + }, + ]; + }, }; export default nextConfig; diff --git a/package-lock.json b/package-lock.json index 5c3a5e0..2f1f922 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-dialog": "^1.1.15", + "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-label": "^2.1.8", "@radix-ui/react-popover": "^1.1.15", "@radix-ui/react-radio-group": "^1.3.8", @@ -18,17 +19,18 @@ "@radix-ui/react-slot": "^1.2.4", "@radix-ui/react-tabs": "^1.1.13", "@tanstack/react-table": "^8.21.3", - "@tiptap/extension-color": "^3.12.0", - "@tiptap/extension-image": "^3.12.0", + "@tiptap/extension-color": "^3.13.0", + "@tiptap/extension-highlight": "^3.13.0", + "@tiptap/extension-image": "^3.13.0", "@tiptap/extension-link": "^3.13.0", - "@tiptap/extension-placeholder": "^3.12.0", + "@tiptap/extension-placeholder": "^3.13.0", "@tiptap/extension-table": "^3.13.0", "@tiptap/extension-table-cell": "^3.13.0", "@tiptap/extension-table-header": "^3.13.0", "@tiptap/extension-table-row": "^3.13.0", "@tiptap/extension-text-align": "^3.13.0", - "@tiptap/extension-text-style": "^3.12.0", - "@tiptap/extension-underline": "^3.12.0", + "@tiptap/extension-text-style": "^3.13.0", + "@tiptap/extension-underline": "^3.13.0", "@tiptap/react": "^3.12.0", "@tiptap/starter-kit": "^3.12.0", "@types/lodash": "^4.17.21", @@ -1041,9 +1043,9 @@ } }, "node_modules/@next/env": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/env/-/env-16.0.7.tgz", - "integrity": "sha512-gpaNgUh5nftFKRkRQGnVi5dpcYSKGcZZkQffZ172OrG/XkrnS7UBTQ648YY+8ME92cC4IojpI2LqTC8sTDhAaw==" + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/env/-/env-16.0.10.tgz", + "integrity": "sha512-8tuaQkyDVgeONQ1MeT9Mkk8pQmZapMKFh5B+OrFUlG3rVmYTXcXlBetBgTurKXGaIZvkoqRT9JL5K3phXcgang==" }, "node_modules/@next/eslint-plugin-next": { "version": "16.0.7", @@ -1055,9 +1057,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.0.7.tgz", - "integrity": "sha512-LlDtCYOEj/rfSnEn/Idi+j1QKHxY9BJFmxx7108A6D8K0SB+bNgfYQATPk/4LqOl4C0Wo3LACg2ie6s7xqMpJg==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.0.10.tgz", + "integrity": "sha512-4XgdKtdVsaflErz+B5XeG0T5PeXKDdruDf3CRpnhN+8UebNa5N2H58+3GDgpn/9GBurrQ1uWW768FfscwYkJRg==", "cpu": [ "arm64" ], @@ -1070,9 +1072,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.0.7.tgz", - "integrity": "sha512-rtZ7BhnVvO1ICf3QzfW9H3aPz7GhBrnSIMZyr4Qy6boXF0b5E3QLs+cvJmg3PsTCG2M1PBoC+DANUi4wCOKXpA==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.0.10.tgz", + "integrity": "sha512-spbEObMvRKkQ3CkYVOME+ocPDFo5UqHb8EMTS78/0mQ+O1nqE8toHJVioZo4TvebATxgA8XMTHHrScPrn68OGw==", "cpu": [ "x64" ], @@ -1085,9 +1087,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.0.7.tgz", - "integrity": "sha512-mloD5WcPIeIeeZqAIP5c2kdaTa6StwP4/2EGy1mUw8HiexSHGK/jcM7lFuS3u3i2zn+xH9+wXJs6njO7VrAqww==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.0.10.tgz", + "integrity": "sha512-uQtWE3X0iGB8apTIskOMi2w/MKONrPOUCi5yLO+v3O8Mb5c7K4Q5KD1jvTpTF5gJKa3VH/ijKjKUq9O9UhwOYw==", "cpu": [ "arm64" ], @@ -1100,9 +1102,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.0.7.tgz", - "integrity": "sha512-+ksWNrZrthisXuo9gd1XnjHRowCbMtl/YgMpbRvFeDEqEBd523YHPWpBuDjomod88U8Xliw5DHhekBC3EOOd9g==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.0.10.tgz", + "integrity": "sha512-llA+hiDTrYvyWI21Z0L1GiXwjQaanPVQQwru5peOgtooeJ8qx3tlqRV2P7uH2pKQaUfHxI/WVarvI5oYgGxaTw==", "cpu": [ "arm64" ], @@ -1115,9 +1117,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.0.7.tgz", - "integrity": "sha512-4WtJU5cRDxpEE44Ana2Xro1284hnyVpBb62lIpU5k85D8xXxatT+rXxBgPkc7C1XwkZMWpK5rXLXTh9PFipWsA==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.0.10.tgz", + "integrity": "sha512-AK2q5H0+a9nsXbeZ3FZdMtbtu9jxW4R/NgzZ6+lrTm3d6Zb7jYrWcgjcpM1k8uuqlSy4xIyPR2YiuUr+wXsavA==", "cpu": [ "x64" ], @@ -1130,9 +1132,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.0.7.tgz", - "integrity": "sha512-HYlhqIP6kBPXalW2dbMTSuB4+8fe+j9juyxwfMwCe9kQPPeiyFn7NMjNfoFOfJ2eXkeQsoUGXg+O2SE3m4Qg2w==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.0.10.tgz", + "integrity": "sha512-1TDG9PDKivNw5550S111gsO4RGennLVl9cipPhtkXIFVwo31YZ73nEbLjNC8qG3SgTz/QZyYyaFYMeY4BKZR/g==", "cpu": [ "x64" ], @@ -1145,9 +1147,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.0.7.tgz", - "integrity": "sha512-EviG+43iOoBRZg9deGauXExjRphhuYmIOJ12b9sAPy0eQ6iwcPxfED2asb/s2/yiLYOdm37kPaiZu8uXSYPs0Q==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.0.10.tgz", + "integrity": "sha512-aEZIS4Hh32xdJQbHz121pyuVZniSNoqDVx1yIr2hy+ZwJGipeqnMZBJHyMxv2tiuAXGx6/xpTcQJ6btIiBjgmg==", "cpu": [ "arm64" ], @@ -1160,9 +1162,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.0.7.tgz", - "integrity": "sha512-gniPjy55zp5Eg0896qSrf3yB1dw4F/3s8VK1ephdsZZ129j2n6e1WqCbE2YgcKhW9hPB9TVZENugquWJD5x0ug==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.0.10.tgz", + "integrity": "sha512-E+njfCoFLb01RAFEnGZn6ERoOqhK1Gl3Lfz1Kjnj0Ulfu7oJbuMyvBKNj/bw8XZnenHDASlygTjZICQW+rYW1Q==", "cpu": [ "x64" ], @@ -1441,6 +1443,34 @@ } } }, + "node_modules/@radix-ui/react-dropdown-menu": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dropdown-menu/-/react-dropdown-menu-2.1.16.tgz", + "integrity": "sha512-1PLGQEynI/3OX/ftV54COn+3Sud/Mn8vALg2rWnBLnRaGtJDduNW/22XjlGgPdpcIbiQxjKtb7BkcjP00nqfJw==", + "dependencies": { + "@radix-ui/primitive": "1.1.3", + "@radix-ui/react-compose-refs": "1.1.2", + "@radix-ui/react-context": "1.1.2", + "@radix-ui/react-id": "1.1.1", + "@radix-ui/react-menu": "2.1.16", + "@radix-ui/react-primitive": "2.1.3", + "@radix-ui/react-use-controllable-state": "1.2.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-focus-guards": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@radix-ui/react-focus-guards/-/react-focus-guards-1.1.3.tgz", @@ -1540,6 +1570,62 @@ } } }, + "node_modules/@radix-ui/react-menu": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/@radix-ui/react-menu/-/react-menu-2.1.16.tgz", + "integrity": "sha512-72F2T+PLlphrqLcAotYPp0uJMr5SjP5SL01wfEspJbru5Zs5vQaSHb4VB3ZMJPimgHHCHG7gMOeOB9H3Hdmtxg==", + "dependencies": { + "@radix-ui/primitive": "1.1.3", + "@radix-ui/react-collection": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.2", + "@radix-ui/react-context": "1.1.2", + "@radix-ui/react-direction": "1.1.1", + "@radix-ui/react-dismissable-layer": "1.1.11", + "@radix-ui/react-focus-guards": "1.1.3", + "@radix-ui/react-focus-scope": "1.1.7", + "@radix-ui/react-id": "1.1.1", + "@radix-ui/react-popper": "1.2.8", + "@radix-ui/react-portal": "1.1.9", + "@radix-ui/react-presence": "1.1.5", + "@radix-ui/react-primitive": "2.1.3", + "@radix-ui/react-roving-focus": "1.1.11", + "@radix-ui/react-slot": "1.2.3", + "@radix-ui/react-use-callback-ref": "1.1.1", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.6.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-slot": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz", + "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.2" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-popover": { "version": "1.1.15", "resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.1.15.tgz", @@ -2471,15 +2557,15 @@ } }, "node_modules/@tiptap/extension-color": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@tiptap/extension-color/-/extension-color-3.12.0.tgz", - "integrity": "sha512-QyxZCrd48SV/iB9ZjKmyEmII1IBm/SpDjXeQXmM8H5pORqMEgJ3MdF/I88SGeKRYWNjBA9hkt6ZWv/sVYvFz8Q==", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-color/-/extension-color-3.13.0.tgz", + "integrity": "sha512-I+PTZ31p6GhCjUVpCh1qertTK6T07MVGuLm/LP+c14ByMoZ0L0nVgw0YbWhDqLYWbkI9davv0fuI3dQ0gKSPlA==", "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/extension-text-style": "^3.12.0" + "@tiptap/extension-text-style": "^3.13.0" } }, "node_modules/@tiptap/extension-document": { @@ -2557,6 +2643,18 @@ "@tiptap/core": "^3.12.0" } }, + "node_modules/@tiptap/extension-highlight": { + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-highlight/-/extension-highlight-3.13.0.tgz", + "integrity": "sha512-VlXyO8gWhWd0W5ln4Qyr/P1RoAVZkk9ge0jjNsb1bOc078wuvufQ9f6DquMxx0WpcaCXy+DBQLE0GUUqoLvjsQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^3.13.0" + } + }, "node_modules/@tiptap/extension-horizontal-rule": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-3.12.0.tgz", @@ -2571,15 +2669,15 @@ } }, "node_modules/@tiptap/extension-image": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@tiptap/extension-image/-/extension-image-3.12.0.tgz", - "integrity": "sha512-E+nQmMaHdR5SFDuIZUEdfaaNmRuO47V2KQIIOUT6BIxXkArixaKIIz/BKtzYq4pKySkHWL1niYe5lfZWVmEXaw==", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-image/-/extension-image-3.13.0.tgz", + "integrity": "sha512-223uzLUkIa1rkK7aQK3AcIXe6LbCtmnpVb7sY5OEp+LpSaSPyXwyrZ4A0EO1o98qXG68/0B2OqMntFtA9c5Fbw==", "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^3.12.0" + "@tiptap/core": "^3.13.0" } }, "node_modules/@tiptap/extension-italic": { @@ -2672,15 +2770,15 @@ } }, "node_modules/@tiptap/extension-placeholder": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@tiptap/extension-placeholder/-/extension-placeholder-3.12.0.tgz", - "integrity": "sha512-fYG48/nQ384BSVdfGm+GZW5Jly8Ey/XBjsFTAmNiOi77zhqGpifNBFEMi3PrkxyQSKNm5Mkif8ZuJDQmQ9MmwA==", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-placeholder/-/extension-placeholder-3.13.0.tgz", + "integrity": "sha512-Au4ktRBraQktX9gjSzGWyJV6kPof7+kOhzE8ej+rOMjIrHbx3DCHy1CJWftSO9BbqIyonjsFmm4nE+vjzZ3Z5Q==", "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/extensions": "^3.12.0" + "@tiptap/extensions": "^3.13.0" } }, "node_modules/@tiptap/extension-strike": { @@ -2769,40 +2867,40 @@ } }, "node_modules/@tiptap/extension-text-style": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@tiptap/extension-text-style/-/extension-text-style-3.12.0.tgz", - "integrity": "sha512-VjA7p34EKivogIW8z4EWCMu+1iDrzPcf1oUWPBMdD2OTISY2iNJT2RLmZTMtRSdlZHz4vCWlbBwfKHoFT/ba5g==", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-text-style/-/extension-text-style-3.13.0.tgz", + "integrity": "sha512-M7ob3pfYNYgFPihncEp33r9477hXQgC8j3iU8BsewvPlSx2bMSy5jp2XHDXyEX8dV6flr7acH4GkXXw+DHpaPA==", "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^3.12.0" + "@tiptap/core": "^3.13.0" } }, "node_modules/@tiptap/extension-underline": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-3.12.0.tgz", - "integrity": "sha512-Woh/nk1/7c31D14dIaU5i9d4NMK06TBeEA+uBidhZp+JAXVGMeQGm0K2iJxBXNvNrc6aKGlZ57W1o3CPUWOlWQ==", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-3.13.0.tgz", + "integrity": "sha512-VDQi+UYw0tFnfghpthJTFmtJ3yx90kXeDwFvhmT8G+O+si5VmP05xYDBYBmYCix5jqKigJxEASiBL0gYOgMDEg==", "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^3.12.0" + "@tiptap/core": "^3.13.0" } }, "node_modules/@tiptap/extensions": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.12.0.tgz", - "integrity": "sha512-N5ahZfeTBWROTNHFLmTW7sa6ZrZwvp/jJHyH7tcetXT+509vHVhX7yPoiLDt0fnXIDW7JrWI7jbRRmcKf79I2w==", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.13.0.tgz", + "integrity": "sha512-i7O0ptSibEtTy+2PIPsNKEvhTvMaFJg1W4Oxfnbuxvaigs7cJV9Q0lwDUcc7CPsNw2T1+44wcxg431CzTvdYoA==", "funding": { "type": "github", "url": "https://github.com/sponsors/ueberdosis" }, "peerDependencies": { - "@tiptap/core": "^3.12.0", - "@tiptap/pm": "^3.12.0" + "@tiptap/core": "^3.13.0", + "@tiptap/pm": "^3.13.0" } }, "node_modules/@tiptap/pm": { @@ -6339,11 +6437,11 @@ "dev": true }, "node_modules/next": { - "version": "16.0.7", - "resolved": "https://registry.npmjs.org/next/-/next-16.0.7.tgz", - "integrity": "sha512-3mBRJyPxT4LOxAJI6IsXeFtKfiJUbjCLgvXO02fV8Wy/lIhPvP94Fe7dGhUgHXcQy4sSuYwQNcOLhIfOm0rL0A==", + "version": "16.0.10", + "resolved": "https://registry.npmjs.org/next/-/next-16.0.10.tgz", + "integrity": "sha512-RtWh5PUgI+vxlV3HdR+IfWA1UUHu0+Ram/JBO4vWB54cVPentCD0e+lxyAYEsDTqGGMg7qpjhKh6dc6aW7W/sA==", "dependencies": { - "@next/env": "16.0.7", + "@next/env": "16.0.10", "@swc/helpers": "0.5.15", "caniuse-lite": "^1.0.30001579", "postcss": "8.4.31", @@ -6356,14 +6454,14 @@ "node": ">=20.9.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "16.0.7", - "@next/swc-darwin-x64": "16.0.7", - "@next/swc-linux-arm64-gnu": "16.0.7", - "@next/swc-linux-arm64-musl": "16.0.7", - "@next/swc-linux-x64-gnu": "16.0.7", - "@next/swc-linux-x64-musl": "16.0.7", - "@next/swc-win32-arm64-msvc": "16.0.7", - "@next/swc-win32-x64-msvc": "16.0.7", + "@next/swc-darwin-arm64": "16.0.10", + "@next/swc-darwin-x64": "16.0.10", + "@next/swc-linux-arm64-gnu": "16.0.10", + "@next/swc-linux-arm64-musl": "16.0.10", + "@next/swc-linux-x64-gnu": "16.0.10", + "@next/swc-linux-x64-musl": "16.0.10", + "@next/swc-win32-arm64-msvc": "16.0.10", + "@next/swc-win32-x64-msvc": "16.0.10", "sharp": "^0.34.4" }, "peerDependencies": { diff --git a/package.json b/package.json index 6ae6fb5..65f6fae 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-dialog": "^1.1.15", + "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-label": "^2.1.8", "@radix-ui/react-popover": "^1.1.15", "@radix-ui/react-radio-group": "^1.3.8", @@ -19,17 +20,18 @@ "@radix-ui/react-slot": "^1.2.4", "@radix-ui/react-tabs": "^1.1.13", "@tanstack/react-table": "^8.21.3", - "@tiptap/extension-color": "^3.12.0", - "@tiptap/extension-image": "^3.12.0", + "@tiptap/extension-color": "^3.13.0", + "@tiptap/extension-highlight": "^3.13.0", + "@tiptap/extension-image": "^3.13.0", "@tiptap/extension-link": "^3.13.0", - "@tiptap/extension-placeholder": "^3.12.0", + "@tiptap/extension-placeholder": "^3.13.0", "@tiptap/extension-table": "^3.13.0", "@tiptap/extension-table-cell": "^3.13.0", "@tiptap/extension-table-header": "^3.13.0", "@tiptap/extension-table-row": "^3.13.0", "@tiptap/extension-text-align": "^3.13.0", - "@tiptap/extension-text-style": "^3.12.0", - "@tiptap/extension-underline": "^3.12.0", + "@tiptap/extension-text-style": "^3.13.0", + "@tiptap/extension-underline": "^3.13.0", "@tiptap/react": "^3.12.0", "@tiptap/starter-kit": "^3.12.0", "@types/lodash": "^4.17.21", diff --git a/src/app/(pages)/(main)/page.tsx b/src/app/(pages)/(main)/page.tsx index 3a84a69..3896b90 100644 --- a/src/app/(pages)/(main)/page.tsx +++ b/src/app/(pages)/(main)/page.tsx @@ -109,7 +109,7 @@ const MainPage = () => { if (lastReqKeyRef.current === reqKey) return; lastReqKeyRef.current = reqKey; - const sort = sorting?.[0]; + const sort = sorting?.[0] ?? {id: "prjctIdx", desc: true}; const searchBody: ProjectListRequest = { prjctText: query?.prjctText || "", prjctStatusList: query?.prjctStatusList || [], @@ -117,8 +117,8 @@ const MainPage = () => { ownerFwList: query?.ownerFwList || [], pageIndex: pagination.pageIndex, pageSize: pagination.pageSize, - sortBy: sort?.id ?? "prjctIdx", - sortDir: sort?.desc ? "desc" : "asc" + sortBy: sort.id, + sortDir: sort.desc ? "desc" : "asc" } withLoadingAsync(() => diff --git a/src/app/(pages)/(main)/project/info/page.tsx b/src/app/(pages)/(main)/project/info/page.tsx index d523919..8ab18f3 100644 --- a/src/app/(pages)/(main)/project/info/page.tsx +++ b/src/app/(pages)/(main)/project/info/page.tsx @@ -1,6 +1,6 @@ 'use client' -import {useEffect, useState} from 'react' +import {useEffect, useState, useCallback, useRef} from 'react' import BodyTitle from '@/components/layout/BodyTitle' import {Button} from '@/components/ui/button' import {Input} from '@/components/ui/input' @@ -13,11 +13,11 @@ import {useDialog} from '@/hooks/useDialog' import ResultCodeDialog from '@/components/dialog/ResultCodeDialog' import {useMounted} from '@/hooks/useMounted' import {LoadingOverlay} from '@/components/common/LoadingOverlay' -import {KonKiwiProjectInfo, ProjectInfo} from "@/types/project"; +import {KonKiwiProjectInfo, ProjectInfo, ProjectUpdateRequest, ResultCode} from "@/types/project"; import { PROJECT_STATUS_LABEL, PROJECT_STATUS_ORDER, - ProjectStatus, + ProjectStatus, ResultCodeType, SURVEY_TYPE_LABEL, SURVEY_TYPE_ORDER, SurveyType @@ -31,20 +31,24 @@ import {UserInfo} from "@/types/user"; import {useDebouncedValue} from "@/hooks/useDebouncedValue"; import {useAuth} from "@/hooks/useAuth"; import {KriEditor} from "@/components/kri-editor"; +import _ from "lodash"; - -const defaultProjectInfo: Partial = { +const defaultProjectInfo: ProjectInfo = { + prjctIdx: 0, prjctCd: '', prjctName: '', - prjctStatus: 0, + itrntPrjctCd: '', + prjctStatus: ProjectStatus.WAITING, ownerDept: '', ownerFw: '', - surveyTy: 0, + surveyTy: SurveyType.NONE, surveyPrjctCd: '', surveyUrl: '', ff: false, useContactSenario: false, contactSenario: '', + regUser: '', + regDt: '', } type ExternalTab = 'redirect' | 'api' @@ -56,8 +60,10 @@ const ProjectInfoPage = () => { const { users, isLoading } = useItrntUserList(); const { auth } = useAuth(); - const [projectInfo, setProjectInfo] = useState>(defaultProjectInfo); + const [projectInfo, setProjectInfo] = useState(defaultProjectInfo); const [outsourceUserArray, setOutsourceUserArray] = useState([]); + const [resultCodeArray, setResultCodeArray] = useState([]); + const [changeResultCodeType, setChangeResultCodeType] = useState([]); const [outsourceOptionArray, setOutsourceOptionArray] = useState([]); const [deptArray, setDeptArray] = useState([]); @@ -68,6 +74,7 @@ const ProjectInfoPage = () => { const [surveyProjectArray, setSurveyProjectArray] = useState([]); const [externalTab, setExternalTab] = useState('redirect') + const sessionTempUrlsRef = useRef>(new Set()); const internalSurvey = [SurveyType.KON, SurveyType.KIWI]; const baseUrl = 'https://kcont.kric.com' @@ -92,6 +99,7 @@ const ProjectInfoPage = () => { const searchKonKiwiPrjct = async (keyword:string): Promise => { const surveyType = projectInfo.surveyTy ?? SurveyType.NONE; + if(internalSurvey.includes(surveyType) && userTeam){ const isKiwi = surveyType === SurveyType.KON? 0 : 1; const res = await nextApi.get( @@ -107,6 +115,19 @@ const ProjectInfoPage = () => { setProjectInfo((prev) => ({ ...prev, [field]: value })) } + const handleImageUpload = useCallback( + async (file: File): Promise<{ url: string }> => { + const formData = new FormData(); + formData.append("file", file); + + const url = await nextApi.putForm(`/project/senario-image/${projectInfo.prjctCd}`, formData); + + // 이 세션에서 업로드한 temp 파일 목록에 기록 + sessionTempUrlsRef.current.add(url); + + return { url } + }, [projectInfo.prjctCd]); + const handleResultCodeClick = () => { showDialog('resultCodeDialog') } @@ -116,7 +137,20 @@ const ProjectInfoPage = () => { alert('프로젝트명을 입력해주세요.') return } - // TODO: 저장 API + + const updateCodeArray = _.cloneDeep( + resultCodeArray.filter((rc) => changeResultCodeType.includes(rc.resultCdTy)) + ); + + const requestUpdateProject:ProjectUpdateRequest = { + projectInfo: projectInfo, + resultCodeList: updateCodeArray, + assignUserIdList: outsourceUserArray, + } +console.log(requestUpdateProject, projectInfo.prjctIdx) + await nextApi.patch(`/project/${projectInfo.prjctIdx}`, requestUpdateProject); + + alert("저장되었습니다."); } const handleDeleteClick = async () => { @@ -135,7 +169,10 @@ const ProjectInfoPage = () => { useEffect(() => { if(selectedProject){ nextApi.get(`/project/info/${selectedProject.prjctIdx}`) - .then((res) => { setProjectInfo(res)}); + .then((res) => setProjectInfo(res)); + + nextApi.get(`/project/result-code/${selectedProject.prjctIdx}`) + .then((res) => {setResultCodeArray(res)}); nextApi.get(`/user/outsource`) .then((res) => { @@ -170,6 +207,7 @@ const ProjectInfoPage = () => { } }, [projectInfo.surveyTy, projectInfo.surveyPrjctCd]) + useEffect(() => { let userTeams = Array.from(new Set(users.map(u => u.userTeam))); if(!userTeams.includes("T900")){ //TFT @@ -194,7 +232,6 @@ const ProjectInfoPage = () => { searchKonKiwiPrjct(keyword).then(); }, [debouncedKeyword, projectInfo.surveyTy, userTeam]); - if (!mounted) return return ( @@ -286,9 +323,10 @@ const ProjectInfoPage = () => { console.log(value)} + onChange={(value) => setOutsourceUserArray(value)} getValue={(item) => item.value} getLabel={(item) => item.label} + maxCount={2} placeholder="없음" heightClassName="h-9" widthClassName="w-full" @@ -438,10 +476,12 @@ const ProjectInfoPage = () => { {projectInfo.useContactSenario && (
{handleChange('contactSenario', str); console.log(str)}} + value={projectInfo.contactSenario ?? "

"} + onChange={(html: string) => handleChange("contactSenario", html)} placeholder="컨택 시나리오를 작성해 주세요" className="w-full" + debounceMs={600} // 기본 400ms, 원하면 늘리세요(예: 600~1000) + onImageUpload={async (file) => await handleImageUpload(file)} // 사용 시만 />
)} @@ -472,6 +512,10 @@ const ProjectInfoPage = () => { (open ? showDialog('resultCodeDialog') : hideDialog('resultCodeDialog'))} + changeCodeType={changeResultCodeType} + onChangeCodeType={setChangeResultCodeType} + sourceArray={resultCodeArray} + onSave={setResultCodeArray} /> ) diff --git a/src/app/(pages)/login/page.tsx b/src/app/(pages)/login/page.tsx index 399b152..b67f820 100644 --- a/src/app/(pages)/login/page.tsx +++ b/src/app/(pages)/login/page.tsx @@ -16,7 +16,6 @@ import {apiError} from "@/lib/http-util"; import {NONE_HTTP_ERROR} from "@/const/commonConst"; const LoginPage = () => { - const router = useRouter(); const searchParams = useSearchParams(); const { setFromLoginResponse } = useAuth(); const { withLoadingAsync } = useLoading(); @@ -63,7 +62,7 @@ const LoginPage = () => { console.warn("Failed to persist SeatNumber to secure storage:", e); } // 메인 페이지로 이동 (보호 라우트 진입) - router.replace("/"); + window.location.replace("/"); }).catch((e) => { const err = apiError(e); console.error(err.status, err.code, err.message); diff --git a/src/app/api/assign/[[...slug]]/route.ts b/src/app/api/assign/[[...slug]]/route.ts index 6922495..ae76317 100644 --- a/src/app/api/assign/[[...slug]]/route.ts +++ b/src/app/api/assign/[[...slug]]/route.ts @@ -19,28 +19,4 @@ export const GET = async (req: NextRequest, context: RouteContext) => { } catch (error: unknown) { return errorToResponse(error); } -}; - -export const PUT = async (req: NextRequest, context: RouteContext) => { - try { - const { slug = [] } = await context.params; - const [action] = slug ?? []; - const contactApi = await createContactApi(); - - if(!action){ - const body = await req.json().catch(() => null); - if (!body) { - return NextResponse.json( - { message: "요청 바디가 없습니다." }, - { status: 400 } - ); - } - - await contactApi.put(`/assign/prjct-outsource/${slug[1]}`, body); - return new NextResponse(null, { status: 204 }); - } - return NextResponse.json({ message: "Not found" }, { status: 404 }); - } catch (error: unknown) { - return errorToResponse(error); - } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/app/api/project/[[...slug]]/route.ts b/src/app/api/project/[[...slug]]/route.ts index 0e5feb1..fd3e485 100644 --- a/src/app/api/project/[[...slug]]/route.ts +++ b/src/app/api/project/[[...slug]]/route.ts @@ -2,7 +2,7 @@ import {NextRequest, NextResponse} from "next/server"; import {createContactApi, createIntranetApi} from "@/lib/server-api"; import {errorToResponse} from "@/lib/http-util"; import {PageResponse, RouteContext} from "@/types/common"; -import {IntranetProjectSearchResponse, ProjectInfo, ProjectOwnerResponse} from "@/types/project"; +import {IntranetProjectSearchResponse, ProjectInfo, ProjectOwnerResponse, ResultCode} from "@/types/project"; export const GET = async (req: NextRequest, context: RouteContext) => { try { @@ -32,6 +32,12 @@ export const GET = async (req: NextRequest, context: RouteContext) => { return NextResponse.json(result, { status: 200 }); } + if(action === "result-code" && slug.length === 2){ + const result = await contactApi.get(`/result-code/${slug[1]}`); + return NextResponse.json(result, { status: 200 }); + } + + return NextResponse.json({ message: "Not found" }, { status: 404 }); } catch (error: unknown) { return errorToResponse(error); @@ -57,6 +63,18 @@ export const POST = async (req: NextRequest, context: RouteContext) => { return NextResponse.json(result, { status: 200 }); } + if(action === "senario-image" && slug[1] === "clean" && slug.length === 3){ + const prjctCd = slug[2]; + const body = await req.json().catch(() => null); + + await contactApi.post( + `/project/senario-image/clean/${prjctCd}`, + body + ); + + return new NextResponse(null, { status: 204 }); + } + return NextResponse.json({ message: "Not found" }, { status: 404 }); } catch (error: unknown) { return errorToResponse(error); @@ -69,6 +87,27 @@ export const PUT = async (req: NextRequest, context: RouteContext) => { const [action] = slug; const contactApi = await createContactApi(); + if(action === "senario-image" && slug.length === 2){ + const prjctCd = slug[1]; + + const formData = await req.formData(); + const file = formData.get("file") as File | null; + + if (!file) { + return NextResponse.json( + { message: "file 필드가 없습니다." }, + { status: 400 } + ); + } + + const result = await contactApi.putForm( + `/project/senario-image/${prjctCd}`, + formData + ); + + return NextResponse.json(result, { status: 200 }); + } + if(!action){ const body = await req.json().catch(() => null); if (!body) { @@ -94,6 +133,24 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => { const [action] = slug; const contactApi = await createContactApi(); + if(slug.length === 1){ + const body = await req.json().catch(() => null); + + if (!body) { + return NextResponse.json( + { message: "요청 바디가 없습니다." }, + { status: 400 } + ); + } + + await contactApi.patch( + `/project/${slug[0]}`, + body + ); + + return new NextResponse(null, { status: 204 }); + } + return NextResponse.json({ message: "Not found" }, { status: 404 }); } catch (error: unknown) { return errorToResponse(error); diff --git a/src/app/globals.css b/src/app/globals.css index ce7a146..7f9f63a 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -188,3 +188,68 @@ @apply bg-background text-foreground; } } + +/*************************TipTap 이미지 Resize Node*******************************/ +.ProseMirror img { + cursor: pointer; +} + +.ProseMirror .ProseMirror-selectednode img { + outline: 5px solid #0ea5e9; + outline-offset: -5px; +} +/* 리사이즈 컨테이너 기본 배치 */ +.ProseMirror [data-resize-container] { + position: relative; + display: inline-block; +} + +/* 리사이즈 핸들 공통 스타일 */ +.ProseMirror [data-resize-handle] { + position: absolute; + width: 10px; + height: 10px; + box-sizing: border-box; + background: #ffffff; + border: 1px solid #0ea5e9; /* 하늘색 테두리 */ + z-index: 10; + + opacity: 0; /* 안 보이게 */ + pointer-events: none; /* 마우스 이벤트도 막기 */ + transition: opacity 0.12s ease-out; +} +/* 이 이미지 래퍼에 마우스가 올라갔을 때만, 해당 핸들만 보이기 */ +.ProseMirror [data-resize-container]:hover [data-resize-handle] { + opacity: 1; + pointer-events: auto; +} + +/* 각 방향별 위치 + 커서 모양 */ +.ProseMirror [data-resize-handle="bottom-right"] { + right: -5px; + bottom: -5px; + cursor: se-resize !important; +} + +.ProseMirror [data-resize-handle="bottom-left"] { + left: -5px; + bottom: -5px; + cursor: sw-resize !important; +} + +.ProseMirror [data-resize-handle="top-right"] { + right: -5px; + top: -5px; + cursor: ne-resize !important; +} + +.ProseMirror [data-resize-handle="top-left"] { + left: -5px; + top: -5px; + cursor: nw-resize !important; +} + +/* 리사이즈 중인 상태를 잡고 싶으면 */ +.ProseMirror [data-resize-container][data-resize-state="resizing"] { + outline: 1px dashed #0ea5e9; +} \ No newline at end of file diff --git a/src/components/dialog/ResultCodeDialog.tsx b/src/components/dialog/ResultCodeDialog.tsx index fea14ef..5d95ba4 100644 --- a/src/components/dialog/ResultCodeDialog.tsx +++ b/src/components/dialog/ResultCodeDialog.tsx @@ -1,6 +1,6 @@ 'use client' -import { useMemo, useState } from 'react' +import {useEffect, useMemo, useState} from 'react' import { Dialog, DialogContent, @@ -11,104 +11,161 @@ import { import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import {Trash2, Plus, Download, Search, XIcon} from 'lucide-react' - -export type ResultCode = { - code: string - label: string -} - -type Project = { - prjctCd: string - prjctName: string - resultCodes: ResultCode[] -} +import {ProjectInfo, ResultCode} from "@/types/project"; +import {nextApi} from "@/lib/http-client"; +import {PROJECT_SEARCH_COUNT, RESULT_CODE_TYPE_OPTIONS, ResultCodeType} from "@/const/projectConst"; +import {useDebouncedValue} from "@/hooks/useDebouncedValue"; +import {SelectedProject} from "@/store/jotai/project"; +import {KriSingleSelect} from "@/components/common/KriAutoComplete"; +import {useSelectedProject} from "@/hooks/useSelectedProject"; +import {useMounted} from "@/hooks/useMounted"; +import _ from "lodash"; type ResultCodeDialogProps = { open?: boolean onOpenChange?: (open: boolean) => void - onSave?: (codes: ResultCode[]) => void + changeCodeType: ResultCodeType[] + onChangeCodeType: (code: ResultCodeType[]) => void | Promise + sourceArray: ResultCode[] + onSave?: (codes: ResultCode[]) => void | Promise } -const ResultCodeDialog = ({ open, onOpenChange, onSave }: ResultCodeDialogProps) => { +const ResultCodeDialog = ({ + open, + onOpenChange, + changeCodeType, + onChangeCodeType, + sourceArray, + onSave, +}: ResultCodeDialogProps) => { + const mounted = useMounted(); + const { selectedProject } = useSelectedProject(); const [importMode, setImportMode] = useState(false) - const [selectedProject, setSelectedProject] = useState('') + const [resultCodeType, setResultCodeType] = useState(ResultCodeType.CONTACT) + const [resultCodeArray, setResultCodeArray] = useState([]) + const [importCodeArray, setImportCodeArray] = useState([]) - const [resultCodes, setResultCodes] = useState([ - { code: '0', label: '컨택 성공' }, - { code: '1', label: '통화 예약' }, - { code: '2', label: '비수신' }, - { code: '3', label: '부재' }, - { code: '4', label: '휴가' }, - { code: '5', label: '출장' }, - { code: '6', label: '단순 거절' }, - { code: '7', label: '강력 거절' }, - { code: '8', label: '그런 사람 아님' }, - { code: '9', label: '메일 발송' }, - { code: '10', label: '독려' }, - { code: '11', label: '퇴사' }, - { code: '12', label: '기타' }, - { code: '13', label: '조사 대상 아님' }, - { code: '14', label: '수신 거부' }, - ]) + const [searchKeyword, setSearchKeyword] = useState('') + const debouncedKeyword = useDebouncedValue(searchKeyword, 500); + const [projectArray, setProjectArray] = useState([]); + const [importProject, setImportProject] = useState(undefined) - // 샘플 프로젝트 목록 (실제로는 API에서 가져옴) - const projects: Project[] = [ - { - prjctCd: '250701yd', - prjctName: '250701yd', - resultCodes: [ - { code: '0', label: '완료' }, - { code: '1', label: '거절' }, - { code: '2', label: '진행중' }, - ], - }, - { - prjctCd: '1509013', - prjctName: '1509013_J2307KJC_KFB_저기 1차 카카오톡 AUTOAGI_#01250Group', - resultCodes: [ - { code: '0', label: '성공' }, - { code: '1', label: '실패' }, - { code: '2', label: '보류' }, - ], - }, - { - prjctCd: '1503013', - prjctName: '1503013_J2307KJC_KFB_저기 1차 카카오톡 AUTOAGI_그룹01테스트0', - resultCodes: [ - { code: '0', label: '승인' }, - { code: '1', label: '반려' }, - ], - }, - ] + const searchTopProject = async (keyword: string) => { + const res = await nextApi.get( + `/project/top/${PROJECT_SEARCH_COUNT}`, + { query: { keyword } } + ); - const [projectSearch, setProjectSearch] = useState('') - const filteredProjects = useMemo(() => { - const q = projectSearch.trim().toLowerCase() - if (!q) return projects - return projects.filter(p => - `${p.prjctCd} ${p.prjctName}`.toLowerCase().includes(q) - ) - }, [projectSearch]) + setProjectArray(res.filter((prjct) => prjct.prjctCd !== selectedProject?.prjctCd)); + }; - const selectedProjectData = useMemo( - () => projects.find(p => p.prjctCd === selectedProject), - [selectedProject] - ) + const handleSelectProject = (info:SelectedProject|null) => { + if(info === null) return; + + setImportProject(info); + } const handleAddCode = () => { - setResultCodes(prev => [...prev, { code: String(prev.length), label: '' }]) + if(resultCodeArray.length === 0) return setResultCodeArray([]); + + const lastCode = resultCodeArray[resultCodeArray.length - 1].resultCd; + setResultCodeArray(prev => [ + ...prev, + { + resultCdUUID: crypto.randomUUID(), + prjctIdx: selectedProject!.prjctIdx, + resultCdTy: resultCodeType, + resultCd: lastCode + 1, + resultCdLbl: '', + } + ]) } - const handleDeleteCode = (index: number) => { - setResultCodes(prev => prev.filter((_, i) => i !== index)) + const handleDeleteCode = (resultCd: number) => { + setResultCodeArray(prev => + prev.filter( + rc => !(rc.resultCdTy === resultCodeType && rc.resultCd === resultCd), + ), + ); + }; + + const handleCodeChange = (resultCdUUID: string, field: keyof ResultCode, value: string) => { + let replaceValue:string|number = value; + + if(field === 'resultCd'){ + value = value.replace(/[^0-9]/g, ''); + replaceValue = Number(value); + } + + setResultCodeArray(prev => { + const idx = prev.findIndex( + rc => rc.resultCdUUID === resultCdUUID, + ); + + if (idx === -1) return prev; // 못 찾으면 그대로 + + const next = [...prev]; + next[idx] = { + ...next[idx], + [field]: replaceValue, + }; + return next; + }); + + if (!changeCodeType.includes(resultCodeType)) { + onChangeCodeType([...changeCodeType, resultCodeType]); + } } - const handleCodeChange = (index: number, field: keyof ResultCode, value: string) => { - setResultCodes(prev => { - const next = [...prev] - next[index] = { ...next[index], [field]: value } - return next - }) + const checkAllDuplicate = (): boolean => { + const map = new Map(); + + for (const row of resultCodeArray) { + if (row.resultCd === undefined || row.resultCd === null) continue; + if (!row.resultCdTy) continue; + + const key = `${row.resultCdTy}-${row.resultCd}`; + + const list = map.get(key) ?? []; + list.push(row); + map.set(key, list); + } + + // 타입별/코드별로 2개 이상 있는 것만 추려내기 + const duplicatedList: string[] = []; + + for (const [key, list] of map.entries()) { + if (list.length > 1) { + const [ty, cd] = key.split("-"); + duplicatedList.push(`(${ty}) ${cd}`); + } + } + + if (duplicatedList.length > 0) { + alert(`중복된 코드가 있습니다:\n${duplicatedList.join(", ")}`); + return false; + } + return true; + }; + + const checkDuplicate = ( + resultCdUUID: string, + resultCd: number, + target: HTMLInputElement + ) => { + const hasDup = resultCodeArray.some( + (rc) => rc.resultCdTy === resultCodeType && rc.resultCd === resultCd && rc.resultCdUUID !== resultCdUUID + ); + if (hasDup) { + alert("코드가 중복됩니다."); + // 바로 focus()를 호출하면 blur 연쇄가 생길 수 있어 살짝 지연 + setTimeout(() => { + target.focus(); + target.select(); // 선택까지 해주면 바로 수정하기 편함 + }, 50); + return false; + } + return true; } const handleImportClick = () => { @@ -116,38 +173,67 @@ const ResultCodeDialog = ({ open, onOpenChange, onSave }: ResultCodeDialogProps) } const handleImportApply = () => { - if (selectedProjectData) { - setResultCodes(selectedProjectData.resultCodes) - setImportMode(false) - setSelectedProject('') - setProjectSearch('') + if (importProject) { + setResultCodeArray(_.cloneDeep(importCodeArray.filter(rc => rc.resultCdTy === resultCodeType))); + + if (!changeCodeType.includes(resultCodeType)) { + onChangeCodeType([...changeCodeType, resultCodeType]); + } + + clearImport(); } } const handleImportCancel = () => { - setImportMode(false) - setSelectedProject('') - setProjectSearch('') + clearImport(); } const handleSave = () => { - onSave?.(resultCodes) + const dupOk = checkAllDuplicate(); + if (!dupOk) { + return; + } + + onSave?.(resultCodeArray) onOpenChange?.(false) - setImportMode(false) - setSelectedProject('') - setProjectSearch('') } const handleClose = () => { onOpenChange?.(false) - setImportMode(false) - setSelectedProject('') - setProjectSearch('') } + const clearImport = () => { + setImportMode(false); + setImportProject(undefined); + setSearchKeyword(''); + } + + useEffect(() => { + if(open){ + setResultCodeType(ResultCodeType.CONTACT); + setResultCodeArray(sourceArray); + } + else{ + clearImport(); + } + + }, [open]); + + useEffect(() => { + if(importProject){ + nextApi.get(`/project/result-code/${importProject.prjctIdx}`) + .then((res) => setImportCodeArray(res)); + } + }, [importProject]); + + useEffect(() => { + const keyword = debouncedKeyword.trim(); + searchTopProject(keyword); + }, [debouncedKeyword]); + return ( - {/* ✅ importMode일 때 더 넓게(그리고 애니메이션으로 부드럽게) */} + {/* importMode일 때 더 넓게(그리고 애니메이션으로 부드럽게) */}
- - setProjectSearch(e.target.value)} - placeholder="프로젝트 코드/이름 검색..." - className="h-9 pl-9" - /> + + items={projectArray} + value={String(importProject?.prjctIdx || "")} + onChange={() => {}} + withInfo + onItemChange={handleSelectProject} + searchMode="inputOnly" + onSearchValueChange={setSearchKeyword} + placeholder="프로젝트 검색..." + widthClassName="w-full" + heightClassName="h-9" + preventDeselect + hideOptionCheck + getLabel={(item) => `${item.prjctCd}_${item.prjctName}`} + getValue={(item) => String(item.prjctIdx)} + />
)} - +
+ {RESULT_CODE_TYPE_OPTIONS + .filter((opt) => opt.value !== ResultCodeType.SURVEY) + .map((opt) => ( + + ))} +
{/* 본문 */}
{/* 왼쪽: 결과 코드 */} -
+
결과 코드 목록
@@ -205,9 +316,9 @@ const ResultCodeDialog = ({ open, onOpenChange, onSave }: ResultCodeDialogProps) )}
-
+
- + @@ -215,20 +326,23 @@ const ResultCodeDialog = ({ open, onOpenChange, onSave }: ResultCodeDialogProps) - {resultCodes.map((code, index) => ( + {resultCodeArray + .filter((rc) => rc.resultCdTy === resultCodeType) + .map((code, index) => (
코드 레이블
handleCodeChange(index, 'code', e.target.value)} + value={code.resultCd} + onChange={(e) => handleCodeChange(code.resultCdUUID, 'resultCd', e.target.value)} + onBlur={(e) => checkDuplicate(code.resultCdUUID, Number(e.target.value), e.target)} className="h-9" disabled={importMode} /> handleCodeChange(index, 'label', e.target.value)} + value={code.resultCdLbl} + onChange={(e) => handleCodeChange(code.resultCdUUID, 'resultCdLbl', e.target.value)} className="h-9" disabled={importMode} /> @@ -268,20 +382,22 @@ const ResultCodeDialog = ({ open, onOpenChange, onSave }: ResultCodeDialogProps)
미리보기
-
- {selectedProjectData ? ( +
+ {importProject ? ( - + - {selectedProjectData.resultCodes.map((code, idx) => ( + {importCodeArray + .filter((rc) => rc.resultCdTy === resultCodeType) + .map((code, idx) => ( - - + + ))} @@ -301,7 +417,7 @@ const ResultCodeDialog = ({ open, onOpenChange, onSave }: ResultCodeDialogProps) - diff --git a/src/components/kri-editor/KriEditor.tsx b/src/components/kri-editor/KriEditor.tsx index c01fe88..70cd21b 100644 --- a/src/components/kri-editor/KriEditor.tsx +++ b/src/components/kri-editor/KriEditor.tsx @@ -1,196 +1,19 @@ "use client"; -import * as React from "react"; -import { EditorContent, useEditor } from "@tiptap/react"; -import StarterKit from "@tiptap/starter-kit"; -import Underline from "@tiptap/extension-underline"; -import TiptapImage from "@tiptap/extension-image"; -import Placeholder from "@tiptap/extension-placeholder"; -import Link from "@tiptap/extension-link"; -import TextAlign from "@tiptap/extension-text-align"; +import type { KriEditorProps, KriEditorMode } from "./types"; +import { KriEditorHtmlOnly } from "./KriEditorHtmlOnly"; +import { KriEditorWysiwyg } from "./KriEditorWysiwyg"; -import { Table } from "@tiptap/extension-table"; -import TableRow from "@tiptap/extension-table-row"; -import TableHeader from "@tiptap/extension-table-header"; -import TableCell from "@tiptap/extension-table-cell"; +function resolveMode(mode?: KriEditorMode, editorMode?: KriEditorMode): KriEditorMode { + return mode ?? editorMode ?? "wysiwyg"; +} -import { toast } from "sonner"; -import { cn } from "@/lib/utils"; +export function KriEditor(props: KriEditorProps) { + const mode = resolveMode(props.mode, props.editorMode); -import { compressImage } from "./utils/imageCompression"; -import { Toolbar } from "./toolbar/Toolbar"; + if (mode === "html") { + return ; + } -export type UploadResult = { url: string }; - -export type KriEditorProps = { - value: string; - onChange: (html: string) => void; - - placeholder?: string; - className?: string; - - onImageUpload?: (file: File) => Promise; - - maxImageBytes?: number; - imageMaxWidth?: number; - imageMaxHeight?: number; - imageQuality?: number; - imageMimeType?: "image/webp" | "image/jpeg"; - - allowBase64?: boolean; -}; - -export const KriEditor: React.FC = ({ - value, - onChange, - placeholder = "내용을 입력하세요…", - className, - - onImageUpload, - - maxImageBytes = 5 * 1024 * 1024, - imageMaxWidth = 1600, - imageMaxHeight = 1600, - imageQuality = 0.82, - imageMimeType = "image/webp", - - allowBase64 = false, -}) => { - const fileRef = React.useRef(null); - - const editor = useEditor( - { - immediatelyRender: false, - extensions: [ - StarterKit.configure({ - blockquote: false, - codeBlock: false, - code: false, - }), - Underline, - Link.configure({ - openOnClick: false, - autolink: true, - linkOnPaste: true, - HTMLAttributes: { - class: "text-blue-600 underline underline-offset-2", - }, - }), - TextAlign.configure({ types: ["heading", "paragraph"] }), - - Table.configure({ - resizable: true, - HTMLAttributes: { - class: "w-full table-fixed border-collapse border border-border my-2", - }, - }), - TableRow, - TableHeader.configure({ - HTMLAttributes: { - class: "border border-border bg-muted px-2 py-1 font-semibold align-top", - }, - }), - TableCell.configure({ - HTMLAttributes: { - class: "border border-border px-2 py-1 align-top min-w-[80px]", - }, - }), - - TiptapImage.configure({ allowBase64 }), - Placeholder.configure({ placeholder }), - ], - content: value || "

", - onUpdate: ({ editor }) => onChange(editor.getHTML()), - editorProps: { - attributes: { - class: - "prose prose-sm max-w-none focus:outline-none min-h-[220px] px-0 py-2 " + - "prose-headings:mt-6 prose-headings:mb-3 " + - "prose-p:my-2 prose-ul:my-2 prose-ol:my-2", - }, - }, - }, - [placeholder, allowBase64] - ); - - React.useEffect(() => { - if (!editor) return; - const current = editor.getHTML(); - if (value != null && value != current) { - editor.commands.setContent(value, { - emitUpdate: false, - parseOptions: { preserveWhitespace: "full" }, - }); - } - }, [value, editor]); - - const canImageUpload = Boolean(onImageUpload); - - const handlePickImage = () => { - if (!canImageUpload) return; - fileRef.current?.click(); - }; - - const handleFile = async (e: React.ChangeEvent) => { - try { - const file = e.target.files?.[0]; - e.target.value = ""; - if (!file || !editor) return; - if (!canImageUpload || !onImageUpload) return; - - if (!file.type.startsWith("image/")) { - toast.error("이미지 파일만 업로드할 수 있습니다."); - return; - } - - const compressed = await compressImage(file, { - maxBytes: maxImageBytes, - maxWidth: imageMaxWidth, - maxHeight: imageMaxHeight, - mimeType: imageMimeType, - quality: imageQuality, - }); - - if (compressed.size > maxImageBytes) { - toast.error("이미지 용량이 제한을 초과합니다.", { - description: `최대 ${(maxImageBytes / (1024 * 1024)).toFixed(0)}MB`, - }); - return; - } - - const { url } = await onImageUpload(compressed); - - if (!url || typeof url !== "string") { - toast.error("이미지 업로드 응답이 올바르지 않습니다."); - return; - } - - editor.chain().focus().setImage({ src: url }).run(); - } catch (err) { - toast.error("이미지 업로드에 실패했습니다."); - console.error(err); - } - }; - - if (!editor) return
에디터 로딩 중…
; - - return ( -
-
- - -
- -
- -
-
- ); -}; + return ; +} diff --git a/src/components/kri-editor/KriEditorHtmlOnly.tsx b/src/components/kri-editor/KriEditorHtmlOnly.tsx new file mode 100644 index 0000000..e415043 --- /dev/null +++ b/src/components/kri-editor/KriEditorHtmlOnly.tsx @@ -0,0 +1,164 @@ +"use client"; + +import * as React from "react"; +import { cn } from "@/lib/utils"; +import type { KriEditorProps } from "./types"; +import { useDebouncedChange } from "./hooks/useDebouncedChange"; +import { sanitizeHtmlForPreview } from "./utils/sanitizeHtml"; + +type HtmlOnlyProps = Omit & { + mode: "html"; +}; + +export function KriEditorHtmlOnly(props: HtmlOnlyProps) { + const { + label, + value, + onChange, + placeholder = "HTML을 입력하세요...", + className, + showPreview, + previewClassName, + rows = 14, + onImageUpload, + onImageUploadError, + debounceMs = 350, + } = props; + + const [html, setHtml] = React.useState(value || ""); + const textareaRef = React.useRef(null); + const fileInputRef = React.useRef(null); + const latestHtmlRef = React.useRef(html); + latestHtmlRef.current = html; + + const flushChange = useDebouncedChange(onChange, debounceMs); + + // 외부 value 변경 시 동기화 + React.useEffect(() => { + if ((value || "") !== latestHtmlRef.current) { + setHtml(value || ""); + latestHtmlRef.current = value || ""; + } + }, [value]); + + const handleTextChange = (e: React.ChangeEvent) => { + const next = e.target.value; + setHtml(next); + latestHtmlRef.current = next; + flushChange(next); + }; + + const handleBlur = () => { + flushChange(latestHtmlRef.current); + }; + + const handleClickImageButton = () => { + if (!onImageUpload) return; + fileInputRef.current?.click(); + }; + + const handleFileChange = async ( + e: React.ChangeEvent, + ) => { + const file = e.target.files?.[0]; + if (!file || !onImageUpload) return; + + try { + const url = await onImageUpload(file); + if (!url) return; + + setHtml((prev) => { + const current = prev ?? ""; + const textarea = textareaRef.current; + const imgTag = ``; + + if (!textarea) { + const next = current + imgTag; + latestHtmlRef.current = next; + flushChange(next); + return next; + } + + const { selectionStart, selectionEnd } = textarea; + const before = current.slice(0, selectionStart); + const after = current.slice(selectionEnd); + const next = before + imgTag + after; + + latestHtmlRef.current = next; + flushChange(next); + + // 커서 위치를 이미지 태그 뒤로 이동 + window.requestAnimationFrame(() => { + const pos = before.length + imgTag.length; + textarea.focus(); + textarea.setSelectionRange(pos, pos); + }); + + return next; + }); + } catch (error) { + onImageUploadError?.(error); + } finally { + if (fileInputRef.current) { + fileInputRef.current.value = ""; + } + } + }; + + const sanitizedHtml = React.useMemo( + () => sanitizeHtmlForPreview(html || ""), + [html], + ); + + return ( +
+ {label && ( +
+ {label} +
+ )} + +
+
+ HTML 모드 + {onImageUpload && ( + + )} +
+ +
코드 레이블
{code.code}{code.label}{code.resultCd}{code.resultCdLbl}