From a3aa1cd21601b82e1d3964fc51c042aaf74f3113 Mon Sep 17 00:00:00 2001 From: basssy Date: Fri, 7 Feb 2025 12:25:23 +0900 Subject: [PATCH] =?UTF-8?q?alert=20->=20swalFire=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/estimate/Estimate.jsx | 31 +++++++++++---- src/components/main/ChangePasswordPop.jsx | 38 +++++++++++++++---- .../estimate/useEstimateController.js | 12 +++++- 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 01600c62..e0a58406 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -19,10 +19,10 @@ import { convertNumberToPriceDecimal, convertNumberToPriceDecimalToFixed } from import ProductFeaturesPop from './popup/ProductFeaturesPop' import { v4 as uuidv4 } from 'uuid' import { correntObjectNoState } from '@/store/settingAtom' -import { useRouter, useSearchParams } from 'next/navigation' -import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider' +import { useSearchParams } from 'next/navigation' import { usePlan } from '@/hooks/usePlan' import { usePopup } from '@/hooks/usePopup' +import { useSwal } from '@/hooks/useSwal' export default function Estimate({}) { const [uniqueData, setUniqueData] = useState([]) @@ -33,6 +33,8 @@ export default function Estimate({}) { const [objectNo, setObjectNo] = useState('') //물건번호 const [planNo, setPlanNo] = useState('') //플랜번호 + const { swalFire } = useSwal() + const [files, setFiles] = useState([]) // 보내는 첨부파일 const [originFiles, setOriginFiles] = useState([]) //기존 첨부파일 @@ -347,7 +349,11 @@ export default function Estimate({}) { setEstimateContextState({ originFiles: originFiles, }) - alert(getMessage('estimate.detail.alert.delFile')) + + swalFire({ + text: getMessage('estimate.detail.alert.delFile'), + type: 'alert', + }) } //가격표시 option 목록 최초세팅 && 주문분류 변경시 @@ -359,7 +365,6 @@ export default function Estimate({}) { docTpCd: estimateContextState?.estimateType, } - // console.log('param::::::::::', param) const apiUrl = `/api/estimate/price/store-price-list?${queryStringFormatter(param)}` get({ url: apiUrl }).then((res) => { if (isNotEmptyArray(res?.data)) { @@ -477,7 +482,11 @@ export default function Estimate({}) { if (!pass) { //Pricing이 누락된 아이템이 있습니다. Pricing을 진행해주세요. - return alert(getMessage('estimate.detail.showPrice.pricingBtn.noItemId')) + return swalFire({ + text: getMessage('estimate.detail.showPrice.pricingBtn.noItemId'), + type: 'alert', + icon: 'warning', + }) } } @@ -788,7 +797,11 @@ export default function Estimate({}) { const removeItem = () => { const array = [...selection] if (isEmptyArray(array)) { - return alert(getMessage('estimate.detail.alert.selectDelItem')) + return swalFire({ + text: getMessage('estimate.detail.alert.selectDelItem'), + type: 'alert', + icon: 'warning', + }) } let delList = [] estimateContextState.itemList.filter((row) => { @@ -818,7 +831,11 @@ export default function Estimate({}) { }) if (delCnt === updateList.length) { - return alert(getMessage('estimate.detail.save.requiredItem')) + return swalFire({ + text: getMessage('estimate.detail.save.requiredItem'), + type: 'alert', + icon: 'warning', + }) } setEstimateContextState({ diff --git a/src/components/main/ChangePasswordPop.jsx b/src/components/main/ChangePasswordPop.jsx index 323b332d..83b2baf3 100644 --- a/src/components/main/ChangePasswordPop.jsx +++ b/src/components/main/ChangePasswordPop.jsx @@ -6,9 +6,12 @@ import { useRecoilValue, useRecoilState } from 'recoil' import { useAxios } from '@/hooks/useAxios' import { globalLocaleStore } from '@/store/localeAtom' import { logout, setSession, login } from '@/lib/authActions' +import { useSwal } from '@/hooks/useSwal' + export default function ChangePasswordPop(props) { const globalLocaleState = useRecoilValue(globalLocaleStore) + const { swalFire } = useSwal() const { patch } = useAxios(globalLocaleState) const { getMessage } = useMessage() const [sessionState, setSessionState] = useRecoilState(sessionStore) @@ -55,22 +58,38 @@ export default function ChangePasswordPop(props) { //비밀번호 미입력시 if (_password1.trim() === '') { - alert(getMessage('main.popup.login.validate3')) + swalFire({ + title: getMessage('main.popup.login.validate3'), + type: 'alert', + icon: 'error', + }) return false } if (_password2.trim() === '') { - alert(getMessage('main.popup.login.validate3')) + swalFire({ + title: getMessage('main.popup.login.validate3'), + type: 'alert', + icon: 'error', + }) return false } if (_password1 !== _password2) { - alert(getMessage('main.popup.login.validate1')) + swalFire({ + title: getMessage('main.popup.login.validate4'), + type: 'alert', + icon: 'error', + }) return false } - //패스워드 길이수 체크 - if (checkLength(_password1) > 10) { - return alert(getMessage('main.popup.login.validate2')) + //패스워드 길이수 체크 빈각10 = 전각20 + if (checkLength(_password1) > 20) { + swalFire({ + title: getMessage('main.popup.login.validate1'), + type: 'alert', + icon: 'error', + }) } const param = { @@ -83,7 +102,10 @@ export default function ChangePasswordPop(props) { .then((res) => { if (res?.result?.code === 200) { if (res?.result?.resultCode === 'S') { - alert(getMessage('main.popup.login.success')) + swalFire({ + title: getMessage('main.popup.login.success'), + type: 'alert', + }) const result = { ...sessionState, pwdInitYn: 'Y' } setSession(result) setSessionState(result) @@ -130,6 +152,7 @@ export default function ChangePasswordPop(props) { autoComplete="off" onChange={checkValue} onKeyUp={checkValue} + maxLength={20} /> @@ -150,6 +173,7 @@ export default function ChangePasswordPop(props) { autoComplete="off" onChange={checkValue} onKeyUp={checkValue} + maxLength={20} /> diff --git a/src/hooks/floorPlan/estimate/useEstimateController.js b/src/hooks/floorPlan/estimate/useEstimateController.js index 74c35800..c87e77de 100644 --- a/src/hooks/floorPlan/estimate/useEstimateController.js +++ b/src/hooks/floorPlan/estimate/useEstimateController.js @@ -410,11 +410,19 @@ export const useEstimateController = (planNo) => { */ const handleEstimateCopy = async (sendPlanNo, copyReceiveUser, saleStoreId, otherSaleStoreId) => { if (saleStoreId === '') { - return alert(getMessage('estimate.detail.productFeaturesPopup.requiredStoreId')) + return swalFire({ + text: getMessage('estimate.detail.productFeaturesPopup.requiredStoreId'), + type: 'alert', + icon: 'warning', + }) } if (copyReceiveUser.trim().length === 0) { - return alert(getMessage('estimate.detail.productFeaturesPopup.requiredReceiveUser')) + return swalFire({ + text: getMessage('estimate.detail.productFeaturesPopup.requiredReceiveUser'), + type: 'alert', + icon: 'warning', + }) } const params = { saleStoreId: session.storeId,